-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add Claude 4.5 Sonnet model across all providers #8007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
64c1dea
40d6155
8a961f2
049f239
5e01840
ad518b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,28 @@ export type AnthropicModelId = keyof typeof anthropicModels | |
| export const anthropicDefaultModelId: AnthropicModelId = "claude-sonnet-4-20250514" | ||
|
|
||
| export const anthropicModels = { | ||
| "claude-sonnet-4-5-20250514": { | ||
| maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false. | ||
| contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07' | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| inputPrice: 3.0, // $3 per million input tokens (≤200K context) | ||
| outputPrice: 15.0, // $15 per million output tokens (≤200K context) | ||
| cacheWritesPrice: 3.75, // $3.75 per million tokens | ||
| cacheReadsPrice: 0.3, // $0.30 per million tokens | ||
| supportsReasoningBudget: true, | ||
| // Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07') | ||
| tiers: [ | ||
| { | ||
| contextWindow: 1_000_000, // 1M tokens with beta flag | ||
| inputPrice: 6.0, // $6 per million input tokens (>200K context) | ||
| outputPrice: 22.5, // $22.50 per million output tokens (>200K context) | ||
| cacheWritesPrice: 7.5, // $7.50 per million tokens (>200K context) | ||
| cacheReadsPrice: 0.6, // $0.60 per million tokens (>200K context) | ||
| }, | ||
| ], | ||
| }, | ||
| "claude-sonnet-4-20250514": { | ||
| maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false. | ||
| contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07' | ||
|
|
@@ -28,6 +50,18 @@ export const anthropicModels = { | |
| }, | ||
| ], | ||
| }, | ||
| "claude-opus-4-5-20250514": { | ||
| maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false. | ||
|
||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| inputPrice: 15.0, // $15 per million input tokens | ||
| outputPrice: 75.0, // $75 per million output tokens | ||
| cacheWritesPrice: 18.75, // $18.75 per million tokens | ||
| cacheReadsPrice: 1.5, // $1.50 per million tokens | ||
| supportsReasoningBudget: true, | ||
| }, | ||
| "claude-opus-4-1-20250805": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,21 @@ export const bedrockModels = { | |
| maxCachePoints: 1, | ||
| cachableFields: ["system"], | ||
| }, | ||
| "anthropic.claude-sonnet-4-5-20250514-v1:0": { | ||
| maxTokens: 8192, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The maxTokens value for Claude 4.5 models is 8,192 here but 64,000/32,000 in the anthropic.ts file. Is this intentional due to Bedrock limitations, or should these values be aligned? |
||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| inputPrice: 3.0, | ||
| outputPrice: 15.0, | ||
| cacheWritesPrice: 3.75, | ||
| cacheReadsPrice: 0.3, | ||
| minTokensPerCachePoint: 1024, | ||
| maxCachePoints: 4, | ||
| cachableFields: ["system", "messages", "tools"], | ||
| }, | ||
| "anthropic.claude-sonnet-4-20250514-v1:0": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
|
|
@@ -82,6 +97,21 @@ export const bedrockModels = { | |
| maxCachePoints: 4, | ||
| cachableFields: ["system", "messages", "tools"], | ||
| }, | ||
| "anthropic.claude-opus-4-5-20250514-v1:0": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsComputerUse: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningBudget: true, | ||
| inputPrice: 15.0, | ||
| outputPrice: 75.0, | ||
| cacheWritesPrice: 18.75, | ||
| cacheReadsPrice: 1.5, | ||
| minTokensPerCachePoint: 1024, | ||
| maxCachePoints: 4, | ||
| cachableFields: ["system", "messages", "tools"], | ||
| }, | ||
| "anthropic.claude-opus-4-1-20250805-v1:0": { | ||
| maxTokens: 8192, | ||
| contextWindow: 200_000, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,14 @@ export function getClaudeCodeModelId(baseModelId: ClaudeCodeModelId, useVertex = | |
| } | ||
|
|
||
| export const claudeCodeModels = { | ||
| "claude-sonnet-4-5-20250514": { | ||
|
||
| ...anthropicModels["claude-sonnet-4-5-20250514"], | ||
| supportsImages: false, | ||
| supportsPromptCache: true, // Claude Code does report cache tokens | ||
| supportsReasoningEffort: false, | ||
| supportsReasoningBudget: false, | ||
| requiredReasoningBudget: false, | ||
| }, | ||
| "claude-sonnet-4-20250514": { | ||
| ...anthropicModels["claude-sonnet-4-20250514"], | ||
| supportsImages: false, | ||
|
|
@@ -48,6 +56,14 @@ export const claudeCodeModels = { | |
| supportsReasoningBudget: false, | ||
| requiredReasoningBudget: false, | ||
| }, | ||
| "claude-opus-4-5-20250514": { | ||
| ...anthropicModels["claude-opus-4-5-20250514"], | ||
| supportsImages: false, | ||
| supportsPromptCache: true, // Claude Code does report cache tokens | ||
| supportsReasoningEffort: false, | ||
| supportsReasoningBudget: false, | ||
| requiredReasoningBudget: false, | ||
| }, | ||
| "claude-opus-4-1-20250805": { | ||
| ...anthropicModels["claude-opus-4-1-20250805"], | ||
| supportsImages: false, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,5 +264,41 @@ describe("AnthropicHandler", () => { | |
| expect(result.reasoningBudget).toBeUndefined() | ||
| expect(result.temperature).toBe(0) | ||
| }) | ||
|
|
||
| it("should handle Claude 4.5 Sonnet model correctly", () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good test coverage for the Anthropic provider! However, could we also add test coverage for the other providers (Bedrock, Claude Code, Vertex) that received the new Claude 4.5 models? This would ensure all integrations work correctly. |
||
| const handler = new AnthropicHandler({ | ||
| apiKey: "test-api-key", | ||
| apiModelId: "claude-sonnet-4-5-20250514", | ||
| }) | ||
| const model = handler.getModel() | ||
| expect(model.id).toBe("claude-sonnet-4-5-20250514") | ||
| expect(model.info.maxTokens).toBe(64000) | ||
| expect(model.info.contextWindow).toBe(200000) | ||
| expect(model.info.supportsReasoningBudget).toBe(true) | ||
| }) | ||
|
|
||
| it("should handle Claude 4.5 Opus model correctly", () => { | ||
| const handler = new AnthropicHandler({ | ||
| apiKey: "test-api-key", | ||
| apiModelId: "claude-opus-4-5-20250514", | ||
| }) | ||
| const model = handler.getModel() | ||
| expect(model.id).toBe("claude-opus-4-5-20250514") | ||
| expect(model.info.maxTokens).toBe(32000) | ||
| expect(model.info.contextWindow).toBe(200000) | ||
| expect(model.info.supportsReasoningBudget).toBe(true) | ||
| }) | ||
|
|
||
| it("should enable 1M context for Claude 4.5 Sonnet when beta flag is set", () => { | ||
| const handler = new AnthropicHandler({ | ||
| apiKey: "test-api-key", | ||
| apiModelId: "claude-sonnet-4-5-20250514", | ||
| anthropicBeta1MContext: true, | ||
| }) | ||
| const model = handler.getModel() | ||
| expect(model.info.contextWindow).toBe(1000000) | ||
| expect(model.info.inputPrice).toBe(6.0) | ||
| expect(model.info.outputPrice).toBe(22.5) | ||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains unrelated changes to the ZAi provider that should be in a separate PR. The ZaiApiLine enum and related changes are not related to adding Claude 4.5 models. Could we move these changes to a separate PR to keep this one focused?