Skip to content

OpenRouter models with mandatory reasoning reject requests with reasoning:{enabled:false} #1238

Description

@fegloff

Problem

Models like stepfun/step-3.5-flash:free on OpenRouter require reasoning to always be enabled. When Claude Code sends a non-thinking request (background tasks, subagents), it includes thinking:{type:"disabled"} in the Anthropic format.

The openrouter transformer converts this to reasoning:{enabled:false}, which these models reject with:

API Error: 400 {"error":{"message":"Error from provider(openrouter,stepfun/step-3.5-flash:free: 400): {"error":{"message":"Reasoning is mandatory for this endpoint and
cannot be disabled.","code":400,"metadata":{"provider_name":null}}}Error: Error from provider(openrouter,stepfun/step-3.5-flash:free: 400):
{"error":{"message":"Reasoning is mandatory for this endpoint and cannot be disabled.","code":400,"metadata":{"provider_name":null}}}\n at qn
(/Users/userName/.nvm/versions/node/v23.11.1/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:582:7451)\n at fD
(/Users/userName/.nvm/versions/node/v23.11.1/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:582:11338)\n at process.processTicksAndRejections
(node:internal/process/task_queues:105:5)\n at async cN
(/Users/userName/.nvm/versions/node/v23.11.1/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:582:8659)","type":"api_error","code":"provider_response_error"}}

Root Cause

In dist/cli.js, the openrouter transformer's transformRequestIn:

// Current (broken for mandatory-reasoning models)
e.thinking && (r.reasoning = {effort: EN(e.thinking.budget_tokens), enabled: e.thinking.type === "enabled"})
When thinking.type === "disabled", this sends reasoning:{enabled:false}  which mandatory-reasoning models reject.

Fix
Only forward the reasoning parameter when thinking is explicitly enabled. When disabled, omit it entirely so the model uses its default:


// Fixed
e.thinking && e.thinking.type === "enabled" && (r.reasoning = {effort: EN(e.thinking.budget_tokens), enabled: true})
Steps to Reproduce
Set stepfun/step-3.5-flash:free as the router model for any route
Trigger a background/subagent task (e.g. Task tool in Claude Code)
Observe 400 error from OpenRouter
Environment
CCR version: 2.0.0
Model: stepfun/step-3.5-flash:free via OpenRouter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions