Reasoning
Reasoning lets supported models spend additional tokens planning before they answer. Use it for multi-step coding, math, analysis, tool-use planning, and other tasks where a slower request is worth a better final answer.
Gateway treats reasoning as a vendor-route capability. The same canonical model can expose different reasoning behavior depending on the vendor that serves the request, so check the exact route before sending reasoning controls.
Reasoning can increase latency and output-token cost. Some providers also return thinking by default for specific routes. Use /v1/models to inspect behavior before enabling reasoning broadly.
How reasoning works
Gateway supports two reasoning patterns:
- Gateway-controlled thinking uses the top-level
thinkingrequest field. Gateway translates it for routes that support that request style. - Provider-native reasoning controls use provider-specific fields such as
reasoning_effort, when the selected route advertises that control.
In responses, Gateway normalizes separate provider reasoning into thinking content blocks.
Always render or log these blocks separately from final text. Some providers treat reasoning text as intermediate output, and some applications should hide it from end users.
signature is populated on Anthropic routes and is null on providers that do not sign reasoning (Gemini thought summaries, for example). It is not decorative: if you send the assistant turn back in a later request, the signature must come back with it. See Replay reasoning in multi-round tool loops.
Discover support
Use GET /v1/models and inspect the vendor route you plan to use.
A reasoning-capable route has supports_reasoning: true and a reasoning object.
Check the route you will actually execute. If you use a routing policy, inspect every candidate route that policy can select.
Enable Gateway-controlled thinking
Use the thinking field when the route supports Gateway-controlled thinking. The budget_tokens value is required when type is "enabled" because providers that support explicit thinking need a budget.
Pick a reasoning budget that leaves enough room for the final answer. If you set max_tokens: 4096 and budget_tokens: 1024, the provider still needs remaining output capacity for visible text.
Use provider-native controls
Some routes advertise provider-native controls instead of the top-level thinking field. For example, GPT-OSS routes may expose reasoning_effort.
Only send provider-native controls when /v1/models lists them under reasoning.controls.
Provider-native controls are not interchangeable. A control that works on one vendor route can be ignored or stripped on another route for the same canonical model.
Disable reasoning
If a route advertises disable_supported: true, you can request thinking.type: "disabled".
Use disable controls for latency-sensitive requests, short classification tasks, or prompts where reasoning tokens are not worth the extra cost. If the route does not advertise disable_supported, Gateway may strip unsupported disable fields before sending the request upstream.
Read thinking blocks
Reasoning output appears as thinking content blocks before or alongside text blocks.
In code, branch on content.type.
Some providers may include reasoning-like text inside a normal text block. Treat the public /v1/models route metadata as the source of truth for whether Gateway expects separate reasoning blocks.
Replay reasoning in multi-round tool loops
A tool loop sends the model’s previous turn back on the next request. When reasoning is enabled on an Anthropic route, that turn contains a signed thinking block, and the signature has to travel with it.
Anthropic rejects a thinking block whose signature is missing with 400 thinking.signature: Field required. Gateway drops unsigned blocks before dispatch to prevent that error, so a lost signature does not fail the request — the model silently loses its own prior reasoning on every later round, and you are still billed for the thinking tokens. Echo the signature back and the reasoning is preserved.
Each surface exposes the signature differently, because the OpenAI wire format has no field for provider reasoning.
On the native and Anthropic surfaces, echo the assistant content blocks back verbatim and the signature travels with them. On the OpenAI-shaped surfaces, both fields are Gateway extensions, so your client has to carry them explicitly.
Claude produces reasoning on the first assistant turn of a request. After a tool result is returned it typically answers without a new thinking block, so a long loop usually carries one signed block rather than one per round. That is provider behavior, not a Gateway limitation.
Redacted reasoning
Anthropic sometimes encrypts reasoning instead of returning it in the clear. Gateway preserves those blocks, and they carry the same replay requirement.
On /v1/anthropic the block keeps its provider shape:
On /v1/responses it arrives as a thinking block with empty text and the payload on redacted_data:
There is nothing readable to show a user. Pass it back unchanged with the rest of the turn.
Reasoning with routing policies
Routing policies can choose among multiple vendors and models. If a request includes thinking, every route that might serve the request must support Gateway-controlled reasoning, or the request can fail during capability checks.
For deterministic behavior, pin model and vendor when you need a specific reasoning mode.
Use a routing policy when you only need a reasoning-capable route, not a specific provider behavior. In that case, configure the policy with models whose selected vendor routes all support the same reasoning control.
Streaming
Reasoning works with stream: true on supported routes. Gateway accumulates provider reasoning deltas and returns them as thinking content in the streamed response.
Streaming can delay visible text because the model may spend tokens on thinking before it emits final answer text.
Reasoning composes with streaming, structured output, and tool calling at the same time. None of those features is non-streaming-only.
How reasoning arrives depends on the surface:
/v1/responsesstreams cumulative frames. Each chunk carries the wholethinkingblock accumulated so far, not a delta, so read the latest frame rather than concatenating. The signature appears once the block is complete./v1/anthropicstreamsthinking_deltaevents, then asignature_deltacarrying the signature, matching Anthropic’s own stream. Redacted blocks arrive as a completecontent_block_startof typeredacted_thinking, since there is nothing to stream incrementally./v1/openai/chat/completionsand/v1/ai-sdk/chat/completionsstream reasoning text ondelta.thinkingand deliverdelta.thinking_signatureon the final chunk, because the signature only exists once the block is finished.
Common errors
The model does not support Gateway-controlled reasoning
The selected route does not support the thinking field. Use GET /v1/models, inspect vendors.<vendor>.capabilities.reasoning.controls, and choose a route that supports thinking.budget_tokens or another compatible control.
budget_tokens is required when thinking is enabled
Add a positive budget_tokens value when thinking.type is "enabled". Use a smaller budget for latency-sensitive requests and a larger budget for complex analysis.
The response has no thinking block
The route may not have produced separate reasoning for that prompt, the route may expose reasoning as normal text, or the selected vendor may not be the route you expected. Include include_routing_metadata: true while debugging and verify routing.vendor_used.