feat(ai): add fast mode support for claude-opus-5 and claude-opus-4-8 - #924
feat(ai): add fast mode support for claude-opus-5 and claude-opus-4-8#924Xsidz wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Anthropic “fast mode” plumbing for claude-opus-5 and claude-opus-4-8 (beta header + beta endpoint + speed: "fast" request param), plus model capability detection, tests, and changelog entries.
Changes:
- Expanded
supportsFastMode()to include Anthropic Opus 5 / Opus 4.8 onanthropic-messages. - Added
speed?: "fast"toAnthropicOptionsand routed fast-mode requests throughclient.beta.messages.createwith thefast-mode-2026-02-01beta header andspeed: "fast"param. - Added test coverage for the new Anthropic fast-mode model capability checks and updated changelogs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ai/src/models.ts | Expands fast-mode capability detection to Anthropic Opus 5 / 4.8. |
| packages/ai/src/providers/anthropic.ts | Implements fast-mode request wiring (beta header, beta endpoint, request speed). |
| packages/ai/test/fast-mode.test.ts | Adds unit tests for Anthropic fast-mode capability detection. |
| packages/ai/CHANGELOG.md | Documents the new Anthropic fast-mode support in the AI package. |
| packages/coding-agent/CHANGELOG.md | Adds a coding-agent changelog entry referencing the new fast-mode support. |
Suppressed comments (2)
packages/ai/src/providers/anthropic.ts:543
- The beta endpoint routing should be gated the same way as the fast-mode header/body param, otherwise
speed: "fast"on unsupported models/providers will route through the beta client and may fail unexpectedly.
const createFn =
options?.speed === "fast"
? (client.beta.messages.create.bind(client.beta.messages) as typeof client.messages.create)
: client.messages.create.bind(client.messages);
packages/ai/src/providers/anthropic.ts:1079
speed: "fast"is currently added to the request params for any model when the option is set. This should be restricted to the supported Claude API models to avoid sending an unknown top-level field to other providers/models handled by this stream implementation.
if (options?.speed === "fast") {
// speed is in the beta MessageCreateParamsStreaming but not yet in the base type
(params as MessageCreateParamsStreaming & { speed?: "fast" }).speed = "fast";
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Add supportsAnthropicFastMode() separate from supportsFastMode() to avoid incorrectly gating serviceTier:"priority" on Anthropic models - Guard all three fast-mode paths in anthropic.ts with the new check so unsupported providers/models are never affected - Update tests to use the new function and assert supportsFastMode() still returns false for Anthropic models - Clarify coding-agent CHANGELOG entry Addresses review feedback on PR PrimeIntellect-ai#924
Xsidz
left a comment
There was a problem hiding this comment.
Fixed in af98c34d:
- Added
supportsAnthropicFastMode()as a separate function fromsupportsFastMode()— Anthropic fast mode (speed="fast") and the Codex priority service tier (serviceTier="priority") are unrelated features. The existingsupportsFastModegate forserviceTieris unchanged. - All three fast-mode paths in
anthropic.ts(beta header,speedbody param,client.beta.messagesrouting) are now guarded withsupportsAnthropicFastMode(model), so unsupported providers and models are never affected. - Updated the coding-agent CHANGELOG to clarify this is an AI SDK addition.
|
Two things worth checking before this merges. Pricing. Fast mode bills at $10/MTok input and $50/MTok output, against Opus 5's catalog entry of Reachability. The diff touches no coding-agent source, so nothing sets The model set looks right. Opus 4.7 returns an error for I had a branch for #867 going before I saw this one. Not opening it; happy to send the pricing multiplier and the wiring as a follow-up if that is useful. |
…x pricing - serviceTier="priority" on claude-opus-5/4-8 now activates fast mode (same UX as Codex models, no new toggle needed) - Apply 2x cost multiplier at both calculateCost call sites since catalog rates are $5/$25 but fast mode bills at $10/$50 - Import supportsAnthropicFastMode in agent-session.ts and sdk.ts; update all four supportsFastMode gates to also pass through priority tier for Anthropic fast-mode models - Update CHANGELOG to accurately describe the user-visible change Addresses maintainer feedback on PR PrimeIntellect-ai#924
|
Good catches, both of them. Fixed in f937323. Pricing: added a 2x multiplier after both calculateCost call sites in anthropic.ts, the same pattern applyServiceTierPricing uses for Codex. The catalog entry stays at $5/$25 since that's the standard rate; the multiplier only fires when fast mode is actually active. Reachability: serviceTier="priority" on claude-opus-5 and claude-opus-4-8 now passes through all four supportsFastMode gates in agent-session.ts and sdk.ts by also checking supportsAnthropicFastMode, so the existing priority toggle in the UI activates fast mode without needing a new option. The CHANGELOG now describes the user-visible behavior rather than the internal plumbing. Happy to add a follow-up if there's anything I missed. |
d3afc9f to
306b217
Compare
When speed='fast': - Adds fast-mode-2026-02-01 beta header via createClient - Routes through client.beta.messages.create - Sets speed='fast' in the request body Also extends supportsFastMode() to return true for the two Anthropic models that support it. Part of fixes PrimeIntellect-ai#867
Verifies claude-opus-5 and claude-opus-4-8 are supported, other Anthropic models are rejected, and API mismatches are rejected. Part of fixes PrimeIntellect-ai#867
- Add supportsAnthropicFastMode() separate from supportsFastMode() so serviceTier:"priority" only passes through for Anthropic fast models, not for Codex-only gate - serviceTier="priority" on claude-opus-5/4-8 now activates fast mode - Apply 2x cost multiplier after calculateCost for fast requests - Update coding-agent CHANGELOG with accurate user-visible description Part of fixes PrimeIntellect-ai#867
306b217 to
04d3c82
Compare
|
Both fixes came through the restructure intact, and splitting One thing worth thinking about before this lands: fast mode is a gated research preview. The docs say access is granted per account ("contact your account manager", otherwise a waitlist), so most accounts cannot use it today. On current The existing degradation at A couple of options depending on how defensive you want to be. Catching the access error once and retrying without One smaller naming point: the Anthropic docs state fast mode is not available alongside a Priority Tier commitment. Prime Agent's |
Summary
Adds fast mode support for `claude-opus-5` and `claude-opus-4-8` on the Anthropic API (Claude API only — not Bedrock, Vertex, or Foundry).
Fast mode enables up to 2.5× higher output tokens/second at premium pricing. Per the Anthropic docs, three things are required:
Changes:
Test plan
Fixes #867
Note
Add fast mode support for
claude-opus-5andclaude-opus-4-8on AnthropicsupportsAnthropicFastMode()helper in models.ts that identifies eligible models (claude-opus-5,claude-opus-4-8) on theanthropic-messagesAPI.AnthropicOptionswith an optionalspeed: "fast"field; when set (or whenserviceTieris"priority"), requests are routed through thefast-mode-2026-02-01beta endpoint withspeed: "fast"in the payload.AgentSessionandcreateAgentSessionin the coding agent to preserve thepriorityservice tier for fast-mode-capable models instead of downgrading todefault.Macroscope summarized 04d3c82.