mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Add Claude Sonnet 4 and Claude Opus 4 models with thinking variants (#3844)
Co-authored-by: cte <cestreich@gmail.com>
This commit is contained in:
parent
edcaa15438
commit
8a8fadd407
2 changed files with 143 additions and 3 deletions
|
|
@ -36,6 +36,8 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
|
|||
let { id: modelId, maxTokens, thinking, temperature, virtualId } = this.getModel()
|
||||
|
||||
switch (modelId) {
|
||||
case "claude-sonnet-4-20250514":
|
||||
case "claude-opus-4-20250514":
|
||||
case "claude-3-7-sonnet-20250219":
|
||||
case "claude-3-5-sonnet-20241022":
|
||||
case "claude-3-5-haiku-20241022":
|
||||
|
|
@ -92,13 +94,16 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
|
|||
|
||||
const betas = []
|
||||
|
||||
// Check for the thinking-128k variant first
|
||||
// Enable extended thinking for Claude 3.7 Sonnet only.
|
||||
// https://docs.anthropic.com/en/docs/about-claude/models/migrating-to-claude-4#extended-output-no-longer-supported
|
||||
if (virtualId === "claude-3-7-sonnet-20250219:thinking") {
|
||||
betas.push("output-128k-2025-02-19")
|
||||
}
|
||||
|
||||
// Then check for models that support prompt caching
|
||||
switch (modelId) {
|
||||
case "claude-sonnet-4-20250514":
|
||||
case "claude-opus-4-20250514":
|
||||
case "claude-3-7-sonnet-20250219":
|
||||
case "claude-3-5-sonnet-20241022":
|
||||
case "claude-3-5-haiku-20241022":
|
||||
|
|
@ -202,11 +207,14 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
|
|||
// Track the original model ID for special variant handling
|
||||
const virtualId = id
|
||||
|
||||
// The `:thinking` variant is a virtual identifier for the
|
||||
// `claude-3-7-sonnet-20250219` model with a thinking budget.
|
||||
// The `:thinking` variants are virtual identifiers for models with a thinking budget.
|
||||
// We can handle this more elegantly in the future.
|
||||
if (id === "claude-3-7-sonnet-20250219:thinking") {
|
||||
id = "claude-3-7-sonnet-20250219"
|
||||
} else if (id === "claude-sonnet-4-20250514:thinking") {
|
||||
id = "claude-sonnet-4-20250514"
|
||||
} else if (id === "claude-opus-4-20250514:thinking") {
|
||||
id = "claude-opus-4-20250514"
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,54 @@ export type ApiHandlerOptions = Omit<ProviderSettings, "apiProvider" | "id">
|
|||
export type AnthropicModelId = keyof typeof anthropicModels
|
||||
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-7-sonnet-20250219"
|
||||
export const anthropicModels = {
|
||||
"claude-sonnet-4-20250514:thinking": {
|
||||
maxTokens: 64_000,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 3.0, // $3 per million input tokens
|
||||
outputPrice: 15.0, // $15 per million output tokens
|
||||
cacheWritesPrice: 3.75, // $3.75 per million tokens
|
||||
cacheReadsPrice: 0.3, // $0.30 per million tokens
|
||||
thinking: true,
|
||||
},
|
||||
"claude-sonnet-4-20250514": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 3.0, // $3 per million input tokens
|
||||
outputPrice: 15.0, // $15 per million output tokens
|
||||
cacheWritesPrice: 3.75, // $3.75 per million tokens
|
||||
cacheReadsPrice: 0.3, // $0.30 per million tokens
|
||||
thinking: false,
|
||||
},
|
||||
"claude-opus-4-20250514:thinking": {
|
||||
maxTokens: 64_000,
|
||||
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
|
||||
thinking: true,
|
||||
},
|
||||
"claude-opus-4-20250514": {
|
||||
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
|
||||
thinking: false,
|
||||
},
|
||||
"claude-3-7-sonnet-20250219:thinking": {
|
||||
maxTokens: 128_000,
|
||||
contextWindow: 200_000,
|
||||
|
|
@ -160,6 +208,34 @@ export const bedrockModels = {
|
|||
maxCachePoints: 1,
|
||||
cachableFields: ["system"],
|
||||
},
|
||||
"anthropic.claude-sonnet-4-20250514-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 3.0,
|
||||
outputPrice: 15.0,
|
||||
cacheWritesPrice: 3.75,
|
||||
cacheReadsPrice: 0.3,
|
||||
minTokensPerCachePoint: 1024,
|
||||
maxCachePoints: 4,
|
||||
cachableFields: ["system", "messages", "tools"],
|
||||
},
|
||||
"anthropic.claude-opus-4-20250514-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 15.0,
|
||||
outputPrice: 75.0,
|
||||
cacheWritesPrice: 18.75,
|
||||
cacheReadsPrice: 1.5,
|
||||
minTokensPerCachePoint: 1024,
|
||||
maxCachePoints: 4,
|
||||
cachableFields: ["system", "messages", "tools"],
|
||||
},
|
||||
"anthropic.claude-3-7-sonnet-20250219-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
|
|
@ -582,6 +658,54 @@ export const vertexModels = {
|
|||
inputPrice: 1.25,
|
||||
outputPrice: 5,
|
||||
},
|
||||
"claude-sonnet-4-20250514:thinking": {
|
||||
maxTokens: 64_000,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 3.0,
|
||||
outputPrice: 15.0,
|
||||
cacheWritesPrice: 3.75,
|
||||
cacheReadsPrice: 0.3,
|
||||
thinking: true,
|
||||
},
|
||||
"claude-sonnet-4-20250514": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 3.0,
|
||||
outputPrice: 15.0,
|
||||
cacheWritesPrice: 3.75,
|
||||
cacheReadsPrice: 0.3,
|
||||
thinking: false,
|
||||
},
|
||||
"claude-opus-4-20250514:thinking": {
|
||||
maxTokens: 64_000,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 15.0,
|
||||
outputPrice: 75.0,
|
||||
cacheWritesPrice: 18.75,
|
||||
cacheReadsPrice: 1.5,
|
||||
thinking: true,
|
||||
},
|
||||
"claude-opus-4-20250514": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 200_000,
|
||||
supportsImages: true,
|
||||
supportsComputerUse: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 15.0,
|
||||
outputPrice: 75.0,
|
||||
cacheWritesPrice: 18.75,
|
||||
cacheReadsPrice: 1.5,
|
||||
thinking: false,
|
||||
},
|
||||
"claude-3-7-sonnet@20250219:thinking": {
|
||||
maxTokens: 64_000,
|
||||
contextWindow: 200_000,
|
||||
|
|
@ -1797,6 +1921,10 @@ export const PROMPT_CACHING_MODELS = new Set([
|
|||
"anthropic/claude-3.7-sonnet",
|
||||
"anthropic/claude-3.7-sonnet:beta",
|
||||
"anthropic/claude-3.7-sonnet:thinking",
|
||||
"anthropic/claude-sonnet-4-20250514",
|
||||
"anthropic/claude-sonnet-4-20250514:thinking",
|
||||
"anthropic/claude-opus-4-20250514",
|
||||
"anthropic/claude-opus-4-20250514:thinking",
|
||||
"google/gemini-2.5-pro-preview",
|
||||
"google/gemini-2.5-flash-preview",
|
||||
"google/gemini-2.5-flash-preview:thinking",
|
||||
|
|
@ -1814,6 +1942,10 @@ export const COMPUTER_USE_MODELS = new Set([
|
|||
"anthropic/claude-3.7-sonnet",
|
||||
"anthropic/claude-3.7-sonnet:beta",
|
||||
"anthropic/claude-3.7-sonnet:thinking",
|
||||
"anthropic/claude-sonnet-4-20250514",
|
||||
"anthropic/claude-sonnet-4-20250514:thinking",
|
||||
"anthropic/claude-opus-4-20250514",
|
||||
"anthropic/claude-opus-4-20250514:thinking",
|
||||
])
|
||||
|
||||
const routerNames = ["openrouter", "requesty", "glama", "unbound", "litellm"] as const
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue