Skip to content

Commit 8a961f2

Browse files
committed
feat: add Claude 4.5 Sonnet and Opus models across all providers
- Added claude-sonnet-4-5-20250514 and claude-opus-4-5-20250514 to Anthropic provider - Added same models to claude-code provider (imports from anthropic) - Added anthropic.claude-sonnet-4-5-20250514-v1:0 and anthropic.claude-opus-4-5-20250514-v1:0 to Bedrock - Added claude-sonnet-4-5@20250514 and claude-opus-4-5@20250514 to Vertex AI - Updated provider implementations to support new models - Added support for 1M context beta flag for Claude 4.5 Sonnet - Added comprehensive test coverage for new models
1 parent 40d6155 commit 8a961f2

File tree

7 files changed

+156
-5
lines changed

7 files changed

+156
-5
lines changed

packages/types/src/providers/anthropic.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ export type AnthropicModelId = keyof typeof anthropicModels
66
export const anthropicDefaultModelId: AnthropicModelId = "claude-sonnet-4-20250514"
77

88
export const anthropicModels = {
9+
"claude-sonnet-4-5-20250514": {
10+
maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false.
11+
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
12+
supportsImages: true,
13+
supportsComputerUse: true,
14+
supportsPromptCache: true,
15+
inputPrice: 3.0, // $3 per million input tokens (≤200K context)
16+
outputPrice: 15.0, // $15 per million output tokens (≤200K context)
17+
cacheWritesPrice: 3.75, // $3.75 per million tokens
18+
cacheReadsPrice: 0.3, // $0.30 per million tokens
19+
supportsReasoningBudget: true,
20+
// Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07')
21+
tiers: [
22+
{
23+
contextWindow: 1_000_000, // 1M tokens with beta flag
24+
inputPrice: 6.0, // $6 per million input tokens (>200K context)
25+
outputPrice: 22.5, // $22.50 per million output tokens (>200K context)
26+
cacheWritesPrice: 7.5, // $7.50 per million tokens (>200K context)
27+
cacheReadsPrice: 0.6, // $0.60 per million tokens (>200K context)
28+
},
29+
],
30+
},
931
"claude-sonnet-4-20250514": {
1032
maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false.
1133
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
@@ -28,6 +50,18 @@ export const anthropicModels = {
2850
},
2951
],
3052
},
53+
"claude-opus-4-5-20250514": {
54+
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
55+
contextWindow: 200_000,
56+
supportsImages: true,
57+
supportsComputerUse: true,
58+
supportsPromptCache: true,
59+
inputPrice: 15.0, // $15 per million input tokens
60+
outputPrice: 75.0, // $75 per million output tokens
61+
cacheWritesPrice: 18.75, // $18.75 per million tokens
62+
cacheReadsPrice: 1.5, // $1.50 per million tokens
63+
supportsReasoningBudget: true,
64+
},
3165
"claude-opus-4-1-20250805": {
3266
maxTokens: 8192,
3367
contextWindow: 200_000,

packages/types/src/providers/bedrock.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ export const bedrockModels = {
6767
maxCachePoints: 1,
6868
cachableFields: ["system"],
6969
},
70+
"anthropic.claude-sonnet-4-5-20250514-v1:0": {
71+
maxTokens: 8192,
72+
contextWindow: 200_000,
73+
supportsImages: true,
74+
supportsComputerUse: true,
75+
supportsPromptCache: true,
76+
supportsReasoningBudget: true,
77+
inputPrice: 3.0,
78+
outputPrice: 15.0,
79+
cacheWritesPrice: 3.75,
80+
cacheReadsPrice: 0.3,
81+
minTokensPerCachePoint: 1024,
82+
maxCachePoints: 4,
83+
cachableFields: ["system", "messages", "tools"],
84+
},
7085
"anthropic.claude-sonnet-4-20250514-v1:0": {
7186
maxTokens: 8192,
7287
contextWindow: 200_000,
@@ -82,6 +97,21 @@ export const bedrockModels = {
8297
maxCachePoints: 4,
8398
cachableFields: ["system", "messages", "tools"],
8499
},
100+
"anthropic.claude-opus-4-5-20250514-v1:0": {
101+
maxTokens: 8192,
102+
contextWindow: 200_000,
103+
supportsImages: true,
104+
supportsComputerUse: true,
105+
supportsPromptCache: true,
106+
supportsReasoningBudget: true,
107+
inputPrice: 15.0,
108+
outputPrice: 75.0,
109+
cacheWritesPrice: 18.75,
110+
cacheReadsPrice: 1.5,
111+
minTokensPerCachePoint: 1024,
112+
maxCachePoints: 4,
113+
cachableFields: ["system", "messages", "tools"],
114+
},
85115
"anthropic.claude-opus-4-1-20250805-v1:0": {
86116
maxTokens: 8192,
87117
contextWindow: 200_000,

packages/types/src/providers/claude-code.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export function getClaudeCodeModelId(baseModelId: ClaudeCodeModelId, useVertex =
4040
}
4141

4242
export const claudeCodeModels = {
43+
"claude-sonnet-4-5-20250514": {
44+
...anthropicModels["claude-sonnet-4-5-20250514"],
45+
supportsImages: false,
46+
supportsPromptCache: true, // Claude Code does report cache tokens
47+
supportsReasoningEffort: false,
48+
supportsReasoningBudget: false,
49+
requiredReasoningBudget: false,
50+
},
4351
"claude-sonnet-4-20250514": {
4452
...anthropicModels["claude-sonnet-4-20250514"],
4553
supportsImages: false,
@@ -48,6 +56,14 @@ export const claudeCodeModels = {
4856
supportsReasoningBudget: false,
4957
requiredReasoningBudget: false,
5058
},
59+
"claude-opus-4-5-20250514": {
60+
...anthropicModels["claude-opus-4-5-20250514"],
61+
supportsImages: false,
62+
supportsPromptCache: true, // Claude Code does report cache tokens
63+
supportsReasoningEffort: false,
64+
supportsReasoningBudget: false,
65+
requiredReasoningBudget: false,
66+
},
5167
"claude-opus-4-1-20250805": {
5268
...anthropicModels["claude-opus-4-1-20250805"],
5369
supportsImages: false,

packages/types/src/providers/vertex.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ export const vertexModels = {
163163
inputPrice: 1.25,
164164
outputPrice: 5,
165165
},
166+
"claude-sonnet-4-5@20250514": {
167+
maxTokens: 8192,
168+
contextWindow: 200_000,
169+
supportsImages: true,
170+
supportsComputerUse: true,
171+
supportsPromptCache: true,
172+
inputPrice: 3.0,
173+
outputPrice: 15.0,
174+
cacheWritesPrice: 3.75,
175+
cacheReadsPrice: 0.3,
176+
supportsReasoningBudget: true,
177+
},
166178
"claude-sonnet-4@20250514": {
167179
maxTokens: 8192,
168180
contextWindow: 200_000,
@@ -175,6 +187,18 @@ export const vertexModels = {
175187
cacheReadsPrice: 0.3,
176188
supportsReasoningBudget: true,
177189
},
190+
"claude-opus-4-5@20250514": {
191+
maxTokens: 8192,
192+
contextWindow: 200_000,
193+
supportsImages: true,
194+
supportsComputerUse: true,
195+
supportsPromptCache: true,
196+
inputPrice: 15.0,
197+
outputPrice: 75.0,
198+
cacheWritesPrice: 18.75,
199+
cacheReadsPrice: 1.5,
200+
supportsReasoningBudget: true,
201+
},
178202
"claude-opus-4-1@20250805": {
179203
maxTokens: 8192,
180204
contextWindow: 200_000,

src/api/providers/__tests__/anthropic.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,41 @@ describe("AnthropicHandler", () => {
264264
expect(result.reasoningBudget).toBeUndefined()
265265
expect(result.temperature).toBe(0)
266266
})
267+
268+
it("should handle Claude 4.5 Sonnet model correctly", () => {
269+
const handler = new AnthropicHandler({
270+
apiKey: "test-api-key",
271+
apiModelId: "claude-sonnet-4-5-20250514",
272+
})
273+
const model = handler.getModel()
274+
expect(model.id).toBe("claude-sonnet-4-5-20250514")
275+
expect(model.info.maxTokens).toBe(64000)
276+
expect(model.info.contextWindow).toBe(200000)
277+
expect(model.info.supportsReasoningBudget).toBe(true)
278+
})
279+
280+
it("should handle Claude 4.5 Opus model correctly", () => {
281+
const handler = new AnthropicHandler({
282+
apiKey: "test-api-key",
283+
apiModelId: "claude-opus-4-5-20250514",
284+
})
285+
const model = handler.getModel()
286+
expect(model.id).toBe("claude-opus-4-5-20250514")
287+
expect(model.info.maxTokens).toBe(32000)
288+
expect(model.info.contextWindow).toBe(200000)
289+
expect(model.info.supportsReasoningBudget).toBe(true)
290+
})
291+
292+
it("should enable 1M context for Claude 4.5 Sonnet when beta flag is set", () => {
293+
const handler = new AnthropicHandler({
294+
apiKey: "test-api-key",
295+
apiModelId: "claude-sonnet-4-5-20250514",
296+
anthropicBeta1MContext: true,
297+
})
298+
const model = handler.getModel()
299+
expect(model.info.contextWindow).toBe(1000000)
300+
expect(model.info.inputPrice).toBe(6.0)
301+
expect(model.info.outputPrice).toBe(22.5)
302+
})
267303
})
268304
})

src/api/providers/anthropic.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
4545
const cacheControl: CacheControlEphemeral = { type: "ephemeral" }
4646
let { id: modelId, betas = [], maxTokens, temperature, reasoning: thinking } = this.getModel()
4747

48-
// Add 1M context beta flag if enabled for Claude Sonnet 4
49-
if (modelId === "claude-sonnet-4-20250514" && this.options.anthropicBeta1MContext) {
48+
// Add 1M context beta flag if enabled for Claude Sonnet 4 and 4.5
49+
if (
50+
(modelId === "claude-sonnet-4-20250514" || modelId === "claude-sonnet-4-5-20250514") &&
51+
this.options.anthropicBeta1MContext
52+
) {
5053
betas.push("context-1m-2025-08-07")
5154
}
5255

5356
switch (modelId) {
57+
case "claude-sonnet-4-5-20250514":
5458
case "claude-sonnet-4-20250514":
59+
case "claude-opus-4-5-20250514":
5560
case "claude-opus-4-1-20250805":
5661
case "claude-opus-4-20250514":
5762
case "claude-3-7-sonnet-20250219":
@@ -110,7 +115,9 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
110115

111116
// Then check for models that support prompt caching
112117
switch (modelId) {
118+
case "claude-sonnet-4-5-20250514":
113119
case "claude-sonnet-4-20250514":
120+
case "claude-opus-4-5-20250514":
114121
case "claude-opus-4-1-20250805":
115122
case "claude-opus-4-20250514":
116123
case "claude-3-7-sonnet-20250219":
@@ -243,8 +250,11 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
243250
let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId
244251
let info: ModelInfo = anthropicModels[id]
245252

246-
// If 1M context beta is enabled for Claude Sonnet 4, update the model info
247-
if (id === "claude-sonnet-4-20250514" && this.options.anthropicBeta1MContext) {
253+
// If 1M context beta is enabled for Claude Sonnet 4 or 4.5, update the model info
254+
if (
255+
(id === "claude-sonnet-4-20250514" || id === "claude-sonnet-4-5-20250514") &&
256+
this.options.anthropicBeta1MContext
257+
) {
248258
// Use the tier pricing for 1M context
249259
const tier = info.tiers?.[0]
250260
if (tier) {

webview-ui/src/components/settings/providers/Anthropic.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const Anthropic = ({ apiConfiguration, setApiConfigurationField }: Anthro
2222
const [anthropicBaseUrlSelected, setAnthropicBaseUrlSelected] = useState(!!apiConfiguration?.anthropicBaseUrl)
2323

2424
// Check if the current model supports 1M context beta
25-
const supports1MContextBeta = selectedModel?.id === "claude-sonnet-4-20250514"
25+
const supports1MContextBeta =
26+
selectedModel?.id === "claude-sonnet-4-20250514" || selectedModel?.id === "claude-sonnet-4-5-20250514"
2627

2728
const handleInputChange = useCallback(
2829
<K extends keyof ProviderSettings, E>(

0 commit comments

Comments
 (0)