# Reasoning Models (/docs/reasoning)


Overview [#overview]

Yunxin provides first-class support for reasoning/thinking models. Unlike bolt-on solutions, reasoning is a core primitive in Yunxin's architecture.

<Callout>
  Reasoning support is not a plugin — it's built into the core API adapter layer for each provider.
</Callout>

How Reasoning Works [#how-reasoning-works]

Reasoning models produce an internal "thinking" process before generating the final answer. This thinking process may be:

* **Visible** — Returned as `reasoning_content` in the response
* **Hidden** — Used internally but not exposed
* **Configurable** — Extended thinking can be toggled via parameters

Using Reasoning Models [#using-reasoning-models]

```
POST /v1/chat/completions
```

Basic Usage [#basic-usage]

```python
response = client.chat.completions.create(
    model="model-id",
    messages=[
        {"role": "user", "content": "Prove that the square root of 2 is irrational."}
    ]
)

# Access reasoning content (if available)
if hasattr(response.choices[0].message, 'reasoning_content'):
    thinking = response.choices[0].message.reasoning_content
    print(f"Thinking process:\n{thinking}")

answer = response.choices[0].message.content
print(f"Answer:\n{answer}")
```

Extended Thinking [#extended-thinking]

Some models support extended thinking with configurable token budgets:

```python
response = client.chat.completions.create(
    model="model-id",
    messages=[
        {"role": "user", "content": "Analyze the complexity of the traveling salesman problem."}
    ],
    extra_body={
        "thinking": {
            "type": "enabled",
            "budget_tokens": 10000
        }
    }
)
```

<Callout type="info">
  Some reasoning models have specific constraints and may not support certain parameters like `temperature`, `top_p`, or `system` messages. Yunxin automatically adapts these parameters per model.
</Callout>

Streaming with Reasoning [#streaming-with-reasoning]

When streaming reasoning models, thinking tokens are delivered before the final answer:

```python
stream = client.chat.completions.create(
    model="model-id",
    messages=[{"role": "user", "content": "What is 99 * 97?"}],
    stream=True
)

for chunk in stream:
    delta = chunk.choices[0].delta

    # Reasoning tokens
    if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
        print(f"💭 {delta.reasoning_content}", end="")

    # Final answer tokens
    if delta.content:
        print(f"💬 {delta.content}", end="")
```

Available Reasoning Models [#available-reasoning-models]

<Callout>
  Use the `GET /v1/models` endpoint with `capability=thinking` to list all available reasoning models.
</Callout>
