feat: add support for Claude Opus 4.1 (claude-opus-4-1-20250805) (#6728)

Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
This commit is contained in:
roomote[bot] 2025-08-05 10:55:03 -07:00 committed by GitHub
parent c632b22e56
commit 477b85de03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 85 additions and 1 deletions

View file

@ -0,0 +1,11 @@
---
"@roo-code/types": patch
"roo-code": patch
---
Add support for Claude Opus 4.1 (claude-opus-4-1-20250805)
- Added claude-opus-4-1-20250805 to anthropicModels with 8192 max tokens and reasoning budget support
- Added support across all providers: Anthropic, Claude Code, Bedrock, Vertex AI, OpenRouter, and LiteLLM
- Updated anthropic.ts provider to handle prompt caching for the new model
- Pricing: $15/M input tokens, $75/M output tokens, $18.75/M cache writes, $1.5/M cache reads

View file

@ -18,6 +18,18 @@ export const anthropicModels = {
cacheReadsPrice: 0.3, // $0.30 per million tokens
supportsReasoningBudget: true,
},
"claude-opus-4-1-20250805": {
maxTokens: 8192,
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-20250514": {
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
contextWindow: 200_000,

View file

@ -82,6 +82,21 @@ export const bedrockModels = {
maxCachePoints: 4,
cachableFields: ["system", "messages", "tools"],
},
"anthropic.claude-opus-4-1-20250805-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-20250514-v1:0": {
maxTokens: 8192,
contextWindow: 200_000,

View file

@ -48,6 +48,14 @@ export const claudeCodeModels = {
supportsReasoningBudget: false,
requiredReasoningBudget: false,
},
"claude-opus-4-1-20250805": {
...anthropicModels["claude-opus-4-1-20250805"],
supportsImages: false,
supportsPromptCache: true, // Claude Code does report cache tokens
supportsReasoningEffort: false,
supportsReasoningBudget: false,
requiredReasoningBudget: false,
},
"claude-opus-4-20250514": {
...anthropicModels["claude-opus-4-20250514"],
supportsImages: false,

View file

@ -17,6 +17,7 @@ export const litellmDefaultModelInfo: ModelInfo = {
export const LITELLM_COMPUTER_USE_MODELS = new Set([
"claude-3-5-sonnet-latest",
"claude-opus-4-1-20250805",
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
"claude-3-7-sonnet-latest",
@ -26,22 +27,26 @@ export const LITELLM_COMPUTER_USE_MODELS = new Set([
"vertex_ai/claude-3-5-sonnet-v2",
"vertex_ai/claude-3-5-sonnet-v2@20241022",
"vertex_ai/claude-3-7-sonnet@20250219",
"vertex_ai/claude-opus-4-1@20250805",
"vertex_ai/claude-opus-4@20250514",
"vertex_ai/claude-sonnet-4@20250514",
"openrouter/anthropic/claude-3.5-sonnet",
"openrouter/anthropic/claude-3.5-sonnet:beta",
"openrouter/anthropic/claude-3.7-sonnet",
"openrouter/anthropic/claude-3.7-sonnet:beta",
"anthropic.claude-opus-4-1-20250805-v1:0",
"anthropic.claude-opus-4-20250514-v1:0",
"anthropic.claude-sonnet-4-20250514-v1:0",
"anthropic.claude-3-7-sonnet-20250219-v1:0",
"anthropic.claude-3-5-sonnet-20241022-v2:0",
"us.anthropic.claude-3-5-sonnet-20241022-v2:0",
"us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"us.anthropic.claude-opus-4-1-20250805-v1:0",
"us.anthropic.claude-opus-4-20250514-v1:0",
"us.anthropic.claude-sonnet-4-20250514-v1:0",
"eu.anthropic.claude-3-5-sonnet-20241022-v2:0",
"eu.anthropic.claude-3-7-sonnet-20250219-v1:0",
"eu.anthropic.claude-opus-4-1-20250805-v1:0",
"eu.anthropic.claude-opus-4-20250514-v1:0",
"eu.anthropic.claude-sonnet-4-20250514-v1:0",
"snowflake/claude-3-5-sonnet",

View file

@ -39,6 +39,7 @@ export const OPEN_ROUTER_PROMPT_CACHING_MODELS = new Set([
"anthropic/claude-3.7-sonnet:thinking",
"anthropic/claude-sonnet-4",
"anthropic/claude-opus-4",
"anthropic/claude-opus-4.1",
"google/gemini-2.5-flash-preview",
"google/gemini-2.5-flash-preview:thinking",
"google/gemini-2.5-flash-preview-05-20",
@ -59,6 +60,7 @@ export const OPEN_ROUTER_COMPUTER_USE_MODELS = new Set([
"anthropic/claude-3.7-sonnet:thinking",
"anthropic/claude-sonnet-4",
"anthropic/claude-opus-4",
"anthropic/claude-opus-4.1",
])
// 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([
export const OPEN_ROUTER_REASONING_BUDGET_MODELS = new Set([
"anthropic/claude-3.7-sonnet:beta",
"anthropic/claude-opus-4",
"anthropic/claude-opus-4.1",
"anthropic/claude-sonnet-4",
"google/gemini-2.5-pro-preview",
"google/gemini-2.5-pro",

View file

@ -175,6 +175,18 @@ export const vertexModels = {
cacheReadsPrice: 0.3,
supportsReasoningBudget: true,
},
"claude-opus-4-1@20250805": {
maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,
supportsComputerUse: true,
supportsPromptCache: true,
inputPrice: 15.0,
outputPrice: 75.0,
cacheWritesPrice: 18.75,
cacheReadsPrice: 1.5,
supportsReasoningBudget: true,
},
"claude-opus-4@20250514": {
maxTokens: 8192,
contextWindow: 200_000,

View file

@ -47,6 +47,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
switch (modelId) {
case "claude-sonnet-4-20250514":
case "claude-opus-4-1-20250805":
case "claude-opus-4-20250514":
case "claude-3-7-sonnet-20250219":
case "claude-3-5-sonnet-20241022":
@ -105,6 +106,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
// Then check for models that support prompt caching
switch (modelId) {
case "claude-sonnet-4-20250514":
case "claude-opus-4-1-20250805":
case "claude-opus-4-20250514":
case "claude-3-7-sonnet-20250219":
case "claude-3-5-sonnet-20241022":

View file

@ -32,6 +32,7 @@ describe("OpenRouter API", () => {
"google/gemini-2.5-pro-preview", // Excluded due to lag issue (#4487)
"google/gemini-2.5-flash", // OpenRouter doesn't report this as supporting prompt caching
"google/gemini-2.5-flash-lite-preview-06-17", // OpenRouter doesn't report this as supporting prompt caching
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
])
const ourCachingModels = Array.from(OPEN_ROUTER_PROMPT_CACHING_MODELS).filter(
@ -48,12 +49,20 @@ describe("OpenRouter API", () => {
expect(ourCachingModels.sort()).toEqual(expectedCachingModels)
const excludedComputerUseModels = new Set([
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
])
const expectedComputerUseModels = Array.from(OPEN_ROUTER_COMPUTER_USE_MODELS)
.filter((id) => !excludedComputerUseModels.has(id))
.sort()
expect(
Object.entries(models)
.filter(([_, model]) => model.supportsComputerUse)
.map(([id, _]) => id)
.sort(),
).toEqual(Array.from(OPEN_ROUTER_COMPUTER_USE_MODELS).sort())
).toEqual(expectedComputerUseModels)
expect(
Object.entries(models)
@ -67,6 +76,7 @@ describe("OpenRouter API", () => {
"anthropic/claude-3.7-sonnet:beta",
"anthropic/claude-3.7-sonnet:thinking",
"anthropic/claude-opus-4",
// "anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
"anthropic/claude-sonnet-4",
"arliai/qwq-32b-arliai-rpr-v1:free",
"cognitivecomputations/dolphin3.0-r1-mistral-24b:free",
@ -122,6 +132,7 @@ describe("OpenRouter API", () => {
"google/gemini-2.5-flash",
"google/gemini-2.5-flash-lite-preview-06-17",
"google/gemini-2.5-pro",
"anthropic/claude-opus-4.1", // Not yet available in OpenRouter API
])
const expectedReasoningBudgetModels = Array.from(OPEN_ROUTER_REASONING_BUDGET_MODELS)

View file

@ -232,6 +232,11 @@ export const parseOpenRouterModel = ({
modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219:thinking"].maxTokens
}
// Set claude-opus-4.1 model to use the correct configuration
if (id === "anthropic/claude-opus-4.1") {
modelInfo.maxTokens = anthropicModels["claude-opus-4-1-20250805"].maxTokens
}
// Set horizon-alpha model to 32k max tokens
if (id === "openrouter/horizon-alpha") {
modelInfo.maxTokens = 32768