Add Claude Opus 5 (`claude-opus-5`) support

Merged
DS
4mo ago
+293-28

This pull request was posted by Claude Code using claude-opus-4-8 on behalf of David.

David steered the scope decisions in this PR (how to model the Opus 5 divergence, and to ground-truth the pre-existing claims rather than trust the docs) but has not reviewed the diff line by line.

Adds claude-opus-5, released 2026-07-24. No issue — same as the Claude Sonnet 5 add (#6161).

The /v1/models endpoint exposes exactly one new id, claude-opus-5, with no dated snapshot; Anthropic's model docs confirm that is intentional ("starting with the Claude 4.6 generation, model IDs use a dateless format that is also a pinned snapshot").

Capabilities — probed live, not mirrored

Every profile flag was verified against the API by probing claude-opus-5 side by side with claude-opus-4-8 rather than copying 4.8's profile. It matches 4.8 on: adaptive thinking (and rejects budget thinking), rejects temperature/top_p, effort incl. xhigh, task budgets, fast mode, json-schema output, forced tool_choice, tool search, advisor (as executor and as advisor), code execution 20260120, and web search/fetch 20260209.

It is not a pure 4.8 mirror. Opus 5 returns a 400 for xhigh/max effort while thinking is explicitly disabled, where 4.8 accepts the same request:

thinking={'type':'disabled'} + effortclaude-opus-5claude-opus-4-8
xhigh400 output_config.effort 'xhigh' is not supported when thinking is disabled on this modelaccepted
max400accepted
high / unsetacceptedaccepted

Modeled as anthropic_disallows_top_effort_when_thinking_disabled with a fail-fast UserError, mirroring how _validate_task_budget_vs_context_management already handles a known-bad combination instead of forwarding an opaque 400.

Two probe results worth calling out, because reading the response alone would mislead:

  • Fast mode — both claude-opus-5 and claude-opus-4-8 return an identical 429 (this org has zero fast-mode quota), which on its own proves nothing. The signal is the contrast with models that genuinely lack it: claude-opus-4-5, claude-sonnet-5, and claude-opus-4-1 all return a clean 400 does not support the 'speed' parameter. A 429 means the request reached quota enforcement, i.e. the parameter is supported.
  • Advisor — the first probe failed with 'claude-opus-4-8' cannot be used as an advisor when the request model is 'claude-opus-5', which is a pairing rejection, not an executor-capability one. Re-probed across pairs: claude-opus-5 is valid as an executor (advisor claude-opus-5), and valid as an advisor for claude-opus-4-8, claude-sonnet-5, and claude-haiku-4-5 executors.

Also in this PR

Stale copy that this change would otherwise have contradicted:

  • AnthropicModelSettings.anthropic_speed docstring didn't list Opus 5, while its profile twin and docs/models/anthropic.md did. The same miss was caught by review on the Opus 4.8 add (#5709).
  • The task-budget docstring and _get_task_budget's UserError enumerated claude-opus-4-7/4-8 only — already stale for Sonnet 5 and Fable 5. Rather than extend a fourth copy of the list, both now point at the anthropic_supports_task_budgets profile flag and the Anthropic docs, so there's one source of truth.
  • Guarded Bedrock structured output on claude-opus-5 in bedrock_structured_output_unsupported. Without it, BedrockProvider.model_profile('us.anthropic.claude-opus-5') flips supports_json_schema_output to True — reachable today, since BedrockModelName is Literal[...] | str. This matches #5709, which added claude-opus-4-8 to that tuple before any Bedrock id existed, and is exactly the defect #5581 filed.

Deliberate omissions

  • No Bedrock/Heroku model ids. Only the structured-output guard above. heroku: is enforced against Heroku's live catalog by test_known_model_names, so a speculative entry would fail CI; Bedrock ids land in their own refresh PR (#6318), not in per-model adds.
  • No SDK floor bump. anthropic 0.109.0 lacks the id, so it goes on the existing AnthropicModelName bridge Literal, per the established bridge-then-drop pattern (#5849).
  • Not added to the claude-opus-4-7/4-8 parametrize lists. test_model_profile_opus_5 asserts every flag those cover, so adding the id would be duplicate coverage.

Two claims flagged during review as provider-doc contradictions were ground-truthed and left alone, because the API disagrees with the docs: Sonnet 5 does accept task budgets (200, though the docs table says "Not supported"), and Opus 4.7 fast mode is still live (429 quota, not the documented removal). Changing either would have broken working behavior.

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • PR title is fit for the release changelog.