fix(provider): support openrouter reasoning budgets

This commit is contained in:
Aiden Cline 2026-06-30 16:59:56 -05:00
commit e9c243cb67
2 changed files with 23 additions and 0 deletions

View file

@ -751,6 +751,9 @@ function reasoningOptionVariants(model: Provider.Model): Record<string, Record<s
if (!budget) return {}
switch (model.api.npm) {
case "@openrouter/ai-sdk-provider":
return reasoningBudgetVariants(budget, (max_tokens) => ({ reasoning: { max_tokens } }), model.limit.output)
case "@ai-sdk/gateway":
if (idIncludes(model, "anthropic")) {
return reasoningBudgetVariants(

View file

@ -3133,6 +3133,26 @@ describe("ProviderTransform.variants", () => {
expect(Object.keys(result)).toEqual(["low", "high"])
expect(result.low).toEqual({ reasoning: { effort: "low" } })
})
test("budget token reasoning_options use max_tokens", () => {
const result = ProviderTransform.variants(
createMockModel({
id: "openrouter/anthropic/claude-sonnet-4.5",
providerID: "openrouter",
api: {
id: "anthropic/claude-sonnet-4.5",
url: "https://openrouter.ai",
npm: "@openrouter/ai-sdk-provider",
},
reasoning_options: [{ type: "budget_tokens", min: 1024, max: 63999 }],
limit: { context: 1_000_000, output: 64_000 },
}),
)
expect(result).toEqual({
high: { reasoning: { max_tokens: 16_000 } },
max: { reasoning: { max_tokens: 63_999 } },
})
})
})
describe("@ai-sdk/gateway", () => {