> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Reasoning & thinking

> Using the o3 / GPT-5 / Claude thinking / Gemini thinking model families

Reasoning models perform **internal thinking** before producing an answer. They are significantly stronger at math, code, planning and logic problems than ordinary models, but with higher latency and cost.

## Supported models

| Vendor    | Model / suffix                                             | How to enable                                |
| --------- | ---------------------------------------------------------- | -------------------------------------------- |
| OpenAI    | `o3-mini-low/medium/high`, `o3`, `gpt-5.5-low/medium/high` | Built into the model ID / `reasoning_effort` |
| Anthropic | `claude-*-thinking`, base model + `thinking` param         | Built into the model ID / `thinking` param   |
| Google    | `gemini-2.5-pro-thinking`, `-low/medium/high`              | Built into the model ID / `thinking_budget`  |
| DeepSeek  | `deepseek-r1`                                              | Use the model ID directly                    |

## OpenAI

### Via model ID

```python theme={null}
resp = client.chat.completions.create(
    model="o3-mini-high",
    messages=[{"role": "user", "content": "Prove that √2 is irrational"}],
    max_completion_tokens=4096,
)
print(resp.usage.completion_tokens_details.reasoning_tokens)
```

### Via parameter (Responses API)

```python theme={null}
resp = client.responses.create(
    model="o3-mini",
    input="Prove that √2 is irrational",
    reasoning={"effort": "high"},
    max_output_tokens=4096,
)
```

Notes:

* Reasoning models **do not support** some parameters like `temperature`, `top_p`, `presence_penalty`.
* Use `max_completion_tokens` (new) rather than `max_tokens`.
* `reasoning_tokens` are invisible but billed — be sure to leave enough budget.

## Claude

```python theme={null}
resp = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=4096,
    thinking={"type": "enabled", "budget_tokens": 8000},
    messages=[{"role": "user", "content": "Prove Fermat's little theorem"}],
)

for block in resp.content:
    if block.type == "thinking":
        print("[thinking]", block.thinking)
    elif block.type == "text":
        print("[answer]", block.text)
```

* `budget_tokens`: the thinking budget ceiling, typically 1024-32000.
* Thinking blocks are **visible** by default — unlike OpenAI, you can read the reasoning process.
* Billing: thinking\_tokens are billed **additionally** at the output price.

## Gemini

```python theme={null}
resp = client.models.generate_content(
    model="gemini-3.1-pro-preview",
    contents="Prove Goldbach's conjecture",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_budget=8000),
    ),
)
print(resp.usage_metadata.thoughts_token_count)
```

Or use a preset ID:

| ID                            | Behavior                          |
| ----------------------------- | --------------------------------- |
| `gemini-2.5-pro-thinking`     | Default medium thinking budget    |
| `gemini-2.5-pro-thinking-128` | Force a 128-token thinking budget |
| `gemini-2.5-flash-nothinking` | Thinking off (cheaper)            |
| `gemini-2.5-pro-high`         | High reasoning effort             |

## When to use a reasoning model

<CardGroup cols={2}>
  <Card title="✅ Good for" icon="check">
    * Math proofs, complex logic problems
    * Code refactoring, bug localization
    * Multi-step planning, agent decisions
    * Long-document analysis, research reviews
  </Card>

  <Card title="❌ Not needed for" icon="xmark">
    * Ordinary Q\&A, casual chat
    * Translation, summarization, rewriting
    * Simple classification, info extraction
  </Card>
</CardGroup>

## Billing reminders

* Reasoning tokens are **not shown in `content`** but are still billed at the output price.
* The console log breaks out thinking / answer into two parts.
* When setting `max_completion_tokens` / `max_output_tokens`, **leave plenty of headroom** (≥ 4096 recommended), or the answer may come back empty due to token exhaustion.

## Streaming

Reasoning models can stream, but during the **thinking phase there are no delta contents** — the client sees a blank period first (possibly several seconds) before the answer starts arriving.
Add a loading state in your UI. Claude / Gemini streaming can receive thinking-block deltas, enabling a "visible thinking process."
