Skip to main content
Reasoning models are trained to think step-by-step before responding with an answer. Given an input prompt, they first produce a chain of thought, visible as tokens in the reasoning output field, and then output a final answer in the content field.

Supported models

Reasoning models fall into a few behavioral types:
  • Reasoning only: Always produces reasoning tokens. Cannot be toggled off.
  • Hybrid: Supports both reasoning and non-reasoning modes via reasoning={"enabled": True/False}.
  • Adjustable effort: Supports the reasoning_effort parameter to control reasoning depth ("low", "medium", or "high").
The following models support reasoning on serverless inference: Additional reasoning models, including DeepSeek-R1 and its distillations, Qwen QwQ-32B, and DeepSeek V3.1 (hybrid), are available for dedicated model inference.

Quickstart

Most reasoning models return a separate reasoning field alongside content in the response. Reasoning models produce longer outputs, so streaming is recommended:
The response contains both the model’s reasoning process and the final answer:
DeepSeek-R1 uses a different format. It outputs reasoning inside <think> tags within the content field rather than a separate reasoning field. See Handle reasoning tokens for details.

Enable and disable reasoning

Hybrid models let you toggle reasoning on or off using the reasoning parameter. This is useful when you want reasoning for complex queries but want faster, cheaper responses for simple ones.
Alternatively, you can enable or disable reasoning using chat_template_kwargs:
GLM-5 has thinking enabled by default. Pass reasoning={"enabled": False} to disable it for simple tasks where reasoning overhead isn’t needed.
For the list of hybrid models, see Supported models.
For DeepSeek V3.1, function calling only works in non-reasoning mode (reasoning={"enabled": False}).

Reasoning effort

GPT-OSS models support a reasoning_effort parameter that controls how much computation the model spends on reasoning. This lets you balance accuracy against cost and latency.
  • "low": Faster responses for simpler tasks with reduced reasoning depth.
  • "medium": Balanced performance for most use cases (recommended default).
  • "high": Maximum reasoning for complex problems. Set max_tokens to ~30,000 with this setting.
DeepSeek-V4-Pro accepts only "high" and "max" for reasoning_effort. Other values are mapped automatically:
  • "low" and "medium" map to "high".
  • "high" and "xhigh" map to "max".
Nemotron 3 Ultra 550B A55B defaults to high reasoning effort. To switch to medium effort, pass chat_template_kwargs={"medium_effort": True}:

Controlling reasoning depth via prompting

For models that don’t support a reasoning_effort parameter, you can influence how much the model thinks by including instructions in your prompt. This is a simple way to reduce token usage and latency when the problem doesn’t warrant deep reasoning. Ask the model to keep its thinking concise:
You can also suggest an approximate budget for the reasoning process:
This technique works across all reasoning models. The model won’t hit an exact word count, but it reliably produces shorter or longer reasoning chains in response to the guidance. Combine it with max_tokens for a hard ceiling on total output.

Thinking modes

GLM-5 supports advanced thinking modes that control how reasoning integrates with tool calling and multi-turn conversations.

Interleaved thinking

The default mode. The model reasons between tool calls and after receiving tool results, enabling complex step-by-step reasoning where it interprets each tool output before deciding what to do next.
In this mode, the model will reason about which tool to call first, interpret the result, then reason again before making the next call.

Preserved thinking

The model retains reasoning content from previous assistant turns in the conversation context, improving reasoning continuity and cache hit rates. This is ideal for coding agents and multi-turn agentic workflows. Enable preserved thinking by setting clear_thinking to false:
When using preserved thinking, include the unmodified reasoning from previous turns back in the conversation:
When using preserved thinking, all consecutive reasoning blocks must exactly match the original sequence generated by the model. Don’t reorder or edit these blocks. Otherwise, performance may degrade and cache hit rates will drop.

Turn-level thinking

Control reasoning on a per-turn basis within the same session. Enable thinking for hard turns (planning, debugging) and disable it for simple ones (facts, rewording) to save cost. For a complete tool-calling example with GLM-5.2 thinking modes, see the GLM-5.2 Quickstart.

Handle reasoning tokens

There are two patterns for accessing reasoning tokens, depending on the model.

Separate reasoning field

Most models (Kimi K2.6, GLM-5, DeepSeek-V4-Pro, GPT-OSS) return reasoning in a dedicated reasoning field on the response message or streaming delta:
Use the reasoning field for both input and output. The model returns its chain of thought in reasoning (or delta.reasoning when streaming), and you pass it back under the same reasoning key when you send a prior assistant turn to the API for preserved thinking or multi-turn tool calling. The older reasoning_content key is still accepted on input for backward compatibility.

<think> tags in content

DeepSeek-R1 embeds reasoning directly in the content field using <think> tags:
To extract the reasoning and answer separately:

Structured outputs with reasoning models

Reasoning models can return JSON that conforms to a schema, the same way non-reasoning models do. The model still produces its chain of thought in the reasoning field, then writes the structured answer to content. Example: have Kimi K2.6 solve a math problem and return the steps as typed JSON.
Python
Example output:
JSON
For the full structured-outputs reference, see Structured outputs.

Prompting best practices

Prompt reasoning models differently than standard models:

When not to use reasoning

Non-reasoning models are a better fit when:
  • Latency is critical: Real-time voice agents, instant-response chatbots, or other applications that need fast responses.
  • Tasks are straightforward: Simple classification, basic text generation, factual lookups, or quick summaries don’t benefit from extended reasoning.
  • Cost is the priority: High-volume pipelines processing many simple queries. Reasoning tokens significantly increase per-query costs.
For these use cases, consider faster non-reasoning models like Llama 3.3 70B or Qwen3.5 9B.

Manage costs and latency

Reasoning tokens can vary from a few hundred for simple problems to tens of thousands for complex challenges. Strategies to keep costs and latency in check:
  • Count reasoning tokens: Reasoning output is billed as completion tokens and reported under usage.completion_tokens_details.reasoning_tokens. See OpenAI compatibility for the full usage-object shape, which varies by model.
  • Use max_tokens: Set a token limit to cap total output. This reduces costs but may truncate reasoning on complex problems, find the right balance for your use case.
  • Toggle reasoning on hybrid models: Use reasoning={"enabled": False} for simple queries and only enable it when the task benefits from deeper analysis.
  • Use reasoning effort levels: On GPT-OSS, use reasoning_effort="low" for routine tasks and "high" for critical decisions.
  • Use turn-level thinking: On GLM-5, disable thinking for simple turns and enable it only for complex ones within the same session.
  • Prompt for shorter reasoning: Include instructions like “Please be succinct in your thinking” to reduce reasoning token usage on simpler problems. See Controlling reasoning depth via prompting.
  • Stream responses: Since reasoning models produce longer outputs, streaming with stream=True provides a better user experience by showing partial results as they arrive.