Skip to main content
Some models think through a problem before giving a final answer. This makes them stronger at math, code, and logic-heavy tasks. Models with the reasoning capability (Deepshi’s own models and most frontier models) can return their thinking alongside the answer. See Chat models for which models support reasoning.

Control reasoning

Set reasoning_effort to control how much a reasoning model thinks: none, low, medium, or high. Use none to skip reasoning and answer directly, or a higher level for more thorough reasoning. Omit it to use the model’s default.

Reading the reasoning trace

On a reasoning model, the assistant message can carry extra fields next to content:
  • message.reasoning: the reasoning text.
  • message.reasoning_details: a structured array of reasoning segments.
If you only want the final answer, read message.content and ignore the reasoning fields.

Give reasoning models enough tokens

Reasoning and the visible answer share the same generation budget. If you set max_tokens too low, a reasoning model can spend its whole budget thinking and return empty content with finish_reason: "length". That is a normal 200, not an error.
To avoid it, give reasoning models a generous max_tokens so there’s room for both the thinking and the answer.

Streaming

Reasoning works with streaming too. Set "stream": true and read choices[].delta. See Streaming.

Best practices

  • Allow ample max_tokens on reasoning models (room for thinking and the answer).
  • Use a reasoning model for math, code, and multi-step problems; a non-reasoning model is faster and cheaper for simple tasks.
  • Both reasoning and answer tokens count toward usage.completion_tokens and your cost.

Next steps

Tool calling

Let the model call your functions.

Structured outputs

Force responses that match a JSON schema.

Chat models

See which models support reasoning.