Sozdai LogoDocs
Getting Started/Advanced

Reasoning & Thinking Models

Reasoning models like DeepSeek-R1 and OpenAI o1/o3 generate internal 'thinking' logic before outputting final answers. This guide explains how to control reasoning effort and render thinking content.

#1. Reasoning Content Field

For models like DeepSeek-R1 that output raw reasoning lines, Sozdai includes the `reasoning_content` field alongside `content` in the response choices. This allows you to render the reasoning steps separately in an expandable UI accordion on the front-end.

json
{
  "id": "chatcmpl-456",
  "object": "chat.completion",
  "model": "deepseek-reasoner",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The final answer is: 42.",
        "reasoning_content": "We need to calculate the meaning of life, which is a known constant..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 120,
    "total_tokens": 135
  }
}

#2. Streaming Reasoning

In streaming mode (`stream: true`), the API first emits `reasoning_content` chunks. Once thinking concludes, the stream transitions to normal `content` delta chunks. Your code should separate and append both:

text
data: {"id":"chatcmpl-456","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_content":"Thinking step..."}}],"model":"deepseek-reasoner"}

data: {"id":"chatcmpl-456","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Final answer..."}}],"model":"deepseek-reasoner"}

#3. Reasoning Effort Control

Certain models (such as OpenAI o3-mini) support adjusting the reasoning duration. You can specify `reasoning_effort` in the request body:

  • low: Shorter thinking path, faster responses, lower costs.
  • medium: Default balanced effort.
  • high: Extensive reasoning steps for complex math, coding, or logic queries.

Billing Note

All tokens consumed during internal thinking are billed at the model's standard output token rate. High reasoning effort yields more tokens and increases costs accordingly.