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
Setreasoning_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 tocontent:
message.reasoning: the reasoning text.message.reasoning_details: a structured array of reasoning segments.
Give reasoning models enough tokens
Reasoning and the visible answer share the same generation budget. If you setmax_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.
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_tokenson 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_tokensand 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.