Skip to content

Commit 8f3d0bd

Browse files
committed
More fixes
1 parent ff34cde commit 8f3d0bd

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe("OpenRouter API", () => {
4949
"agentica-org/deepcoder-14b-preview:free",
5050
"aion-labs/aion-1.0",
5151
"aion-labs/aion-1.0-mini",
52-
"anthropic/claude-3.7-sonnet",
5352
"anthropic/claude-3.7-sonnet:beta",
5453
"anthropic/claude-3.7-sonnet:thinking",
5554
"anthropic/claude-opus-4",
@@ -110,7 +109,6 @@ describe("OpenRouter API", () => {
110109
.map(([id, _]) => id)
111110
.sort(),
112111
).toEqual([
113-
"anthropic/claude-3.7-sonnet",
114112
"anthropic/claude-3.7-sonnet:beta",
115113
"anthropic/claude-3.7-sonnet:thinking",
116114
"anthropic/claude-opus-4",
@@ -125,7 +123,7 @@ describe("OpenRouter API", () => {
125123
).toEqual(["anthropic/claude-3.7-sonnet:thinking"])
126124

127125
expect(models["anthropic/claude-3.7-sonnet"]).toEqual({
128-
maxTokens: 64000,
126+
maxTokens: 8192,
129127
contextWindow: 200000,
130128
supportsImages: true,
131129
supportsPromptCache: true,
@@ -135,9 +133,8 @@ describe("OpenRouter API", () => {
135133
cacheReadsPrice: 0.3,
136134
description: expect.any(String),
137135
supportsComputerUse: true,
138-
supportsReasoningBudget: true,
139-
requiredReasoningBudget: false,
140-
supportsReasoningEffort: true,
136+
supportsReasoningBudget: false,
137+
supportsReasoningEffort: false,
141138
supportedParameters: ["max_tokens", "temperature", "reasoning", "include_reasoning"],
142139
})
143140

@@ -178,7 +175,7 @@ describe("OpenRouter API", () => {
178175
{ id: "anthropic/claude-3.5-sonnet-20240620", maxTokens: 8192 },
179176
{ id: "anthropic/claude-3.5-sonnet-20240620:beta", maxTokens: 8192 },
180177
{ id: "anthropic/claude-3.5-sonnet:beta", maxTokens: 8192 },
181-
{ id: "anthropic/claude-3.7-sonnet", maxTokens: 64000 },
178+
{ id: "anthropic/claude-3.7-sonnet", maxTokens: 8192 },
182179
{ id: "anthropic/claude-3.7-sonnet:beta", maxTokens: 128000 },
183180
{ id: "anthropic/claude-3.7-sonnet:thinking", maxTokens: 128000 },
184181
])
@@ -205,7 +202,6 @@ describe("OpenRouter API", () => {
205202
description: undefined,
206203
supportsReasoningBudget: false,
207204
supportsReasoningEffort: undefined,
208-
requiredReasoningBudget: false,
209205
supportedParameters: undefined,
210206
},
211207
"Google AI Studio": {
@@ -220,7 +216,6 @@ describe("OpenRouter API", () => {
220216
description: undefined,
221217
supportsReasoningBudget: false,
222218
supportsReasoningEffort: undefined,
223-
requiredReasoningBudget: false,
224219
supportedParameters: undefined,
225220
},
226221
})

src/api/providers/fetchers/openrouter.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ export const parseOpenRouterModel = ({
197197
id.startsWith("anthropic/claude-3.7") ||
198198
id.startsWith("anthropic/claude-sonnet-4") ||
199199
id.startsWith("anthropic/claude-opus-4"),
200-
requiredReasoningBudget: id === "anthropic/claude-3.7-sonnet:thinking",
201200
supportsReasoningEffort: supportedParameters ? supportedParameters.includes("reasoning") : undefined,
202201
supportedParameters: supportedParameters ? supportedParameters.filter(isModelParameter) : undefined,
203202
}
@@ -208,10 +207,19 @@ export const parseOpenRouterModel = ({
208207
modelInfo.supportsComputerUse = true
209208
}
210209

211-
// Special case: Claude 3.7 Sonnet Thinking supports up to 128k tokens if
212-
// a beta flag is enabled (which we do).
210+
// For backwards compatibility with the old model definitions we will
211+
// continue to disable extending thinking for anthropic/claude-3.7-sonnet
212+
// and force it for anthropic/claude-3.7-sonnet:thinking.
213+
214+
if (id === "anthropic/claude-3.7-sonnet") {
215+
modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219"].maxTokens
216+
modelInfo.supportsReasoningBudget = false
217+
modelInfo.supportsReasoningEffort = false
218+
}
219+
213220
if (id === "anthropic/claude-3.7-sonnet:thinking") {
214221
modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219:thinking"].maxTokens
222+
modelInfo.requiredReasoningBudget = true
215223
}
216224

217225
return modelInfo

src/shared/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type AnthropicModelId = keyof typeof anthropicModels
1010
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-7-sonnet-20250219"
1111
export const anthropicModels = {
1212
"claude-sonnet-4-20250514": {
13-
maxTokens: 8192,
13+
maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false.
1414
contextWindow: 200_000,
1515
supportsImages: true,
1616
supportsComputerUse: true,
@@ -22,7 +22,7 @@ export const anthropicModels = {
2222
supportsReasoningBudget: true,
2323
},
2424
"claude-opus-4-20250514": {
25-
maxTokens: 8192,
25+
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
2626
contextWindow: 200_000,
2727
supportsImages: true,
2828
supportsComputerUse: true,
@@ -34,7 +34,7 @@ export const anthropicModels = {
3434
supportsReasoningBudget: true,
3535
},
3636
"claude-3-7-sonnet-20250219:thinking": {
37-
maxTokens: 128_000,
37+
maxTokens: 128_000, // Unlocked by passing `beta` flag to the model. Otherwise, it's 64k.
3838
contextWindow: 200_000,
3939
supportsImages: true,
4040
supportsComputerUse: true,
@@ -47,7 +47,7 @@ export const anthropicModels = {
4747
requiredReasoningBudget: true,
4848
},
4949
"claude-3-7-sonnet-20250219": {
50-
maxTokens: 8192,
50+
maxTokens: 8192, // Since we already have a `:thinking` virtual model we aren't setting `supportsReasoningBudget: true` here.
5151
contextWindow: 200_000,
5252
supportsImages: true,
5353
supportsComputerUse: true,

0 commit comments

Comments
 (0)