Skip to content

Commit 477b85d

Browse files
roomote[bot]roomotedaniel-lxs
authored
feat: add support for Claude Opus 4.1 (claude-opus-4-1-20250805) (#6728)
Co-authored-by: Roo Code <[email protected]> Co-authored-by: Daniel Riccio <[email protected]>
1 parent c632b22 commit 477b85d

File tree

10 files changed

+85
-1
lines changed

10 files changed

+85
-1
lines changed

.changeset/add-opus-4-1-model.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@roo-code/types": patch
3+
"roo-code": patch
4+
---
5+
6+
Add support for Claude Opus 4.1 (claude-opus-4-1-20250805)
7+
8+
- Added claude-opus-4-1-20250805 to anthropicModels with 8192 max tokens and reasoning budget support
9+
- Added support across all providers: Anthropic, Claude Code, Bedrock, Vertex AI, OpenRouter, and LiteLLM
10+
- Updated anthropic.ts provider to handle prompt caching for the new model
11+
- Pricing: $15/M input tokens, $75/M output tokens, $18.75/M cache writes, $1.5/M cache reads

packages/types/src/providers/anthropic.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ export const anthropicModels = {
1818
cacheReadsPrice: 0.3, // $0.30 per million tokens
1919
supportsReasoningBudget: true,
2020
},
21+
"claude-opus-4-1-20250805": {
22+
maxTokens: 8192,
23+
contextWindow: 200_000,
24+
supportsImages: true,
25+
supportsComputerUse: true,
26+
supportsPromptCache: true,
27+
inputPrice: 15.0, // $15 per million input tokens
28+
outputPrice: 75.0, // $75 per million output tokens
29+
cacheWritesPrice: 18.75, // $18.75 per million tokens
30+
cacheReadsPrice: 1.5, // $1.50 per million tokens
31+
supportsReasoningBudget: true,
32+
},
2133
"claude-opus-4-20250514": {
2234
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
2335
contextWindow: 200_000,

packages/types/src/providers/bedrock.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ export const bedrockModels = {
8282
maxCachePoints: 4,
8383
cachableFields: ["system", "messages", "tools"],
8484
},
85+
"anthropic.claude-opus-4-1-20250805-v1:0": {
86+
maxTokens: 8192,
87+
contextWindow: 200_000,
88+
supportsImages: true,
89+
supportsComputerUse: true,
90+
supportsPromptCache: true,
91+
supportsReasoningBudget: true,
92+
inputPrice: 15.0,
93+
outputPrice: 75.0,
94+
cacheWritesPrice: 18.75,
95+
cacheReadsPrice: 1.5,
96+
minTokensPerCachePoint: 1024,
97+
maxCachePoints: 4,
98+
cachableFields: ["system", "messages", "tools"],
99+
},
85100
"anthropic.claude-opus-4-20250514-v1:0": {
86101
maxTokens: 8192,
87102
contextWindow: 200_000,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ export const claudeCodeModels = {
4848
supportsReasoningBudget: false,
4949
requiredReasoningBudget: false,
5050
},
51+
"claude-opus-4-1-20250805": {
52+
...anthropicModels["claude-opus-4-1-20250805"],
53+
supportsImages: false,
54+
supportsPromptCache: true, // Claude Code does report cache tokens
55+
supportsReasoningEffort: false,
56+
supportsReasoningBudget: false,
57+
requiredReasoningBudget: false,
58+
},
5159
"claude-opus-4-20250514": {
5260
...anthropicModels["claude-opus-4-20250514"],
5361
supportsImages: false,

packages/types/src/providers/lite-llm.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const litellmDefaultModelInfo: ModelInfo = {
1717

1818
export const LITELLM_COMPUTER_USE_MODELS = new Set([
1919
"claude-3-5-sonnet-latest",
20+
"claude-opus-4-1-20250805",
2021
"claude-opus-4-20250514",
2122
"claude-sonnet-4-20250514",
2223
"claude-3-7-sonnet-latest",
@@ -26,22 +27,26 @@ export const LITELLM_COMPUTER_USE_MODELS = new Set([
2627
"vertex_ai/claude-3-5-sonnet-v2",
2728
"vertex_ai/claude-3-5-sonnet-v2@20241022",
2829
"vertex_ai/claude-3-7-sonnet@20250219",
30+
"vertex_ai/claude-opus-4-1@20250805",
2931
"vertex_ai/claude-opus-4@20250514",
3032
"vertex_ai/claude-sonnet-4@20250514",
3133
"openrouter/anthropic/claude-3.5-sonnet",
3234
"openrouter/anthropic/claude-3.5-sonnet:beta",
3335
"openrouter/anthropic/claude-3.7-sonnet",
3436
"openrouter/anthropic/claude-3.7-sonnet:beta",
37+
"anthropic.claude-opus-4-1-20250805-v1:0",
3538
"anthropic.claude-opus-4-20250514-v1:0",
3639
"anthropic.claude-sonnet-4-20250514-v1:0",
3740
"anthropic.claude-3-7-sonnet-20250219-v1:0",
3841
"anthropic.claude-3-5-sonnet-20241022-v2:0",
3942
"us.anthropic.claude-3-5-sonnet-20241022-v2:0",
4043
"us.anthropic.claude-3-7-sonnet-20250219-v1:0",
44+
"us.anthropic.claude-opus-4-1-20250805-v1:0",
4145
"us.anthropic.claude-opus-4-20250514-v1:0",
4246
"us.anthropic.claude-sonnet-4-20250514-v1:0",
4347
"eu.anthropic.claude-3-5-sonnet-20241022-v2:0",
4448
"eu.anthropic.claude-3-7-sonnet-20250219-v1:0",
49+
"eu.anthropic.claude-opus-4-1-20250805-v1:0",
4550
"eu.anthropic.claude-opus-4-20250514-v1:0",
4651
"eu.anthropic.claude-sonnet-4-20250514-v1:0",
4752
"snowflake/claude-3-5-sonnet",

packages/types/src/providers/openrouter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const OPEN_ROUTER_PROMPT_CACHING_MODELS = new Set([
3939
"anthropic/claude-3.7-sonnet:thinking",
4040
"anthropic/claude-sonnet-4",
4141
"anthropic/claude-opus-4",
42+
"anthropic/claude-opus-4.1",
4243
"google/gemini-2.5-flash-preview",
4344
"google/gemini-2.5-flash-preview:thinking",
4445
"google/gemini-2.5-flash-preview-05-20",
@@ -59,6 +60,7 @@ export const OPEN_ROUTER_COMPUTER_USE_MODELS = new Set([
5960
"anthropic/claude-3.7-sonnet:thinking",
6061
"anthropic/claude-sonnet-4",
6162
"anthropic/claude-opus-4",
63+
"anthropic/claude-opus-4.1",
6264
])
6365

6466
// When we first launched these models we didn't have support for
@@ -77,6 +79,7 @@ export const OPEN_ROUTER_REQUIRED_REASONING_BUDGET_MODELS = new Set([
7779
export const OPEN_ROUTER_REASONING_BUDGET_MODELS = new Set([
7880
"anthropic/claude-3.7-sonnet:beta",
7981
"anthropic/claude-opus-4",
82+
"anthropic/claude-opus-4.1",
8083
"anthropic/claude-sonnet-4",
8184
"google/gemini-2.5-pro-preview",
8285
"google/gemini-2.5-pro",

packages/types/src/providers/vertex.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ export const vertexModels = {
175175
cacheReadsPrice: 0.3,
176176
supportsReasoningBudget: true,
177177
},
178+
"claude-opus-4-1@20250805": {
179+
maxTokens: 8192,
180+
contextWindow: 200_000,
181+
supportsImages: true,
182+
supportsComputerUse: true,
183+
supportsPromptCache: true,
184+
inputPrice: 15.0,
185+
outputPrice: 75.0,
186+
cacheWritesPrice: 18.75,
187+
cacheReadsPrice: 1.5,
188+
supportsReasoningBudget: true,
189+
},
178190
"claude-opus-4@20250514": {
179191
maxTokens: 8192,
180192
contextWindow: 200_000,

src/api/providers/anthropic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
4747

4848
switch (modelId) {
4949
case "claude-sonnet-4-20250514":
50+
case "claude-opus-4-1-20250805":
5051
case "claude-opus-4-20250514":
5152
case "claude-3-7-sonnet-20250219":
5253
case "claude-3-5-sonnet-20241022":
@@ -105,6 +106,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
105106
// Then check for models that support prompt caching
106107
switch (modelId) {
107108
case "claude-sonnet-4-20250514":
109+
case "claude-opus-4-1-20250805":
108110
case "claude-opus-4-20250514":
109111
case "claude-3-7-sonnet-20250219":
110112
case "claude-3-5-sonnet-20241022":

src/api/providers/fetchers/__tests__/openrouter.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe("OpenRouter API", () => {
3232
"google/gemini-2.5-pro-preview", // Excluded due to lag issue (#4487)
3333
"google/gemini-2.5-flash", // OpenRouter doesn't report this as supporting prompt caching
3434
"google/gemini-2.5-flash-lite-preview-06-17", // OpenRouter doesn't report this as supporting prompt caching
35+
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
3536
])
3637

3738
const ourCachingModels = Array.from(OPEN_ROUTER_PROMPT_CACHING_MODELS).filter(
@@ -48,12 +49,20 @@ describe("OpenRouter API", () => {
4849

4950
expect(ourCachingModels.sort()).toEqual(expectedCachingModels)
5051

52+
const excludedComputerUseModels = new Set([
53+
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
54+
])
55+
56+
const expectedComputerUseModels = Array.from(OPEN_ROUTER_COMPUTER_USE_MODELS)
57+
.filter((id) => !excludedComputerUseModels.has(id))
58+
.sort()
59+
5160
expect(
5261
Object.entries(models)
5362
.filter(([_, model]) => model.supportsComputerUse)
5463
.map(([id, _]) => id)
5564
.sort(),
56-
).toEqual(Array.from(OPEN_ROUTER_COMPUTER_USE_MODELS).sort())
65+
).toEqual(expectedComputerUseModels)
5766

5867
expect(
5968
Object.entries(models)
@@ -67,6 +76,7 @@ describe("OpenRouter API", () => {
6776
"anthropic/claude-3.7-sonnet:beta",
6877
"anthropic/claude-3.7-sonnet:thinking",
6978
"anthropic/claude-opus-4",
79+
// "anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
7080
"anthropic/claude-sonnet-4",
7181
"arliai/qwq-32b-arliai-rpr-v1:free",
7282
"cognitivecomputations/dolphin3.0-r1-mistral-24b:free",
@@ -122,6 +132,7 @@ describe("OpenRouter API", () => {
122132
"google/gemini-2.5-flash",
123133
"google/gemini-2.5-flash-lite-preview-06-17",
124134
"google/gemini-2.5-pro",
135+
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
125136
])
126137

127138
const expectedReasoningBudgetModels = Array.from(OPEN_ROUTER_REASONING_BUDGET_MODELS)

src/api/providers/fetchers/openrouter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ export const parseOpenRouterModel = ({
232232
modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219:thinking"].maxTokens
233233
}
234234

235+
// Set claude-opus-4.1 model to use the correct configuration
236+
if (id === "anthropic/claude-opus-4.1") {
237+
modelInfo.maxTokens = anthropicModels["claude-opus-4-1-20250805"].maxTokens
238+
}
239+
235240
// Set horizon-alpha model to 32k max tokens
236241
if (id === "openrouter/horizon-alpha") {
237242
modelInfo.maxTokens = 32768

0 commit comments

Comments
 (0)