How to control reasoning
This guide turns the reasoning of thinking models (Qwen3, Qwen3.5, DeepSeek-R1…) on or off, limits it, and decides whether clients see it. It assumes a server running with a reasoning model, e.g. mlx-community/Qwen3-4B-4bit.
Turn it on or off for one request
Send one of these fields (with the openai library, in extra_body):
| Field | Thinking |
|---|---|
"reasoning_effort": "low", "medium" or "high" |
on |
"reasoning_effort": "none" or "minimal" |
off |
"chat_template_kwargs": {"enable_thinking": true} |
on (wins over reasoning_effort) |
answer = client.chat.completions.create(
model="mlx-community/Qwen3-4B-4bit",
messages=[{"role": "user", "content": "Is 391 a prime number?"}],
extra_body={"reasoning_effort": "high"},
)
print(answer.choices[0].message.reasoning_content) # the reasoning
print(answer.choices[0].message.content) # the answer only
low, medium and high behave the same: the model either thinks or not.
Turn it on by default
defaults:
thinking: true # every model…
models:
- id: fast
source: mlx-community/Qwen3-4B-4bit
defaults: { thinking: false } # …except this one
Without configuration, models do not think unless a request asks for it.
Limit how long it thinks
Per request: "thinking_budget": 256 (a razorbill extension). In the configuration:
defaults:
thinking_budget: 512
locked:
thinking_budget: 2048 # a ceiling clients cannot exceed
When the budget is spent, the model is made to close its reasoning and answer. The reasoning counts in max_tokens: keep max_tokens well above the budget. Models with no known reasoning protocol (Llama, Gemma) refuse a budget with a 400.
Hide the reasoning from clients
- One request:
"include_reasoning": false. - Always:
locked: { show_reasoning: false }in the configuration.
The model still thinks; reasoning_content is left out, and usage.completion_tokens_details.reasoning_tokens still counts it.
Variants
- Streaming: the reasoning arrives in
delta.reasoning_contentbefore the answer'sdelta.content. - Clients that only read
contentsee the answer without the reasoning, which is what most chat UIs expect. - Structured output or tool calls: the model thinks freely, then the constraint applies to the answer.
See also
- The fields: HTTP API reference and configuration reference.
- How reasoning is separated and limited: reasoning models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|