Skip to main content

Overview

Reasoning lets the model spend more compute on internal chain-of-thought or extended thinking before producing the final answer. Maitai exposes one reasoning object on chat requests. The platform maps it to each provider’s native interface (for example reasoning controls on OpenAI reasoning models, thinking blocks on Anthropic, or extracted reasoning content where the model exposes it). You do not need to branch your integration by vendor.

Request parameters

Pass reasoning inside the same argument list as your chat completion (SDK) or inside the request body’s params object (REST). It has two fields:
reasoning.effort
string
How much the model should think before answering. Typical values: "low", "medium", "high". Exact behavior depends on the model; Maitai forwards this through the unified config.
reasoning.summary
boolean
default:"false"
When true, the response can include the model’s reasoning text in the top-level reasoning field (see Response fields).

SDK examples

Basic usage (effort only)

import maitai

client = maitai.MaitaiAsync()

messages = [
    {"role": "user", "content": "Explain briefly how you would solve 17 * 24."},
]

response = await client.chat.completions.create(
    messages=messages,
    application="demo_app",
    intent="REASONING_DEMO",
    session_id="YOUR_SESSION_ID",
    model="gpt-5",
    reasoning={"effort": "high"},
)
print(response.choices[0].message.content)

Returning reasoning in the response

Set summary: true (Python: True) so the completion may include the model’s reasoning text on the response object.
response = await client.chat.completions.create(
    messages=messages,
    application="demo_app",
    intent="REASONING_DEMO",
    session_id="YOUR_SESSION_ID",
    model="gpt-5",
    reasoning={"effort": "high", "summary": True},
)
print(response.reasoning)
print(response.choices[0].message.content)

API example

Server-side chat completions are sent to Maitai with application_ref_name, session_id, action_type (intent), and a params object that mirrors SDK parameters. Include reasoning inside params:
curl -sS -X POST "https://api.trymaitai.ai/api/v1/chat/completions/serialized" \
  -H "Content-Type: application/json" \
  -H "X-Maitai-Api-Key: $MAITAI_API_KEY" \
  -d '{
    "application_ref_name": "demo_app",
    "session_id": "YOUR_SESSION_ID",
    "action_type": "REASONING_DEMO",
    "evaluation_enabled": true,
    "params": {
      "messages": [
        { "role": "user", "content": "Short plan to boil an egg." }
      ],
      "model": "gpt-5",
      "stream": false,
      "reasoning": { "effort": "high", "summary": true }
    },
    "auth_keys": {}
  }'
Adjust model and message content to match your environment.

Response fields

When reasoning.summary is enabled and the model returns thinking content, the completion may include:
reasoning
string | null
The model’s chain-of-thought or thinking text. Omitted or null when summaries are off or the model does not expose reasoning in the response.
Usage may break out reasoning token counts:
usage.completion_tokens_details.reasoning_tokens
number | null
Number of completion tokens attributed to reasoning, when the provider supplies this breakdown.
Standard choices[0].message.content still holds the final assistant message.

Portal configuration

In the Maitai Portal, you can set a default reasoning effort at the intent or intent group level as part of model / request configuration (the UI uses the legacy reasoning_effort field for that default). Per-request reasoning from the SDK or API overrides those defaults when both are present.
  • Model Request — full chat parameters and Maitai-specific fields