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

# Anthropic Extended Thinking

> Configure reasoning token budgets and capture thinking blocks on Claude models.

Extended Thinking on the `/anthropic/v1/messages` endpoint allows [Claude](https://www.anthropic.com/claude?utm_source=neosantara-docs\&utm_medium=referral) models to deeply reason through complex tasks before producing answers. You control reasoning token expenditure via the `thinking` parameter object.

```python Python (Anthropic SDK) icon="python" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
from anthropic import Anthropic
import os

client = Anthropic(
    base_url="https://api.neosantara.xyz/anthropic",
    api_key=os.environ["NEOSANTARA_API_KEY"]
)

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=4096,
    thinking={
        "type": "enabled",
        "budget_tokens": 2048
    },
    messages=[
        {"role": "user", "content": "How many 'r' letters are in the word 'strawberry'?"}
    ]
)

for block in response.content:
    if block.type == "thinking":
        print(f"[Thinking Process]:\n{block.thinking}\n")
    elif block.type == "text":
        print(f"[Final Answer]:\n{block.text}")
```

```bash cURL icon="terminal" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
curl -X POST https://api.neosantara.xyz/anthropic/v1/messages \
  -H "x-api-key: $NEOSANTARA_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 4096,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 2048
    },
    "messages": [
      {"role": "user", "content": "How many r in strawberry?"}
    ]
  }'
```

## The `thinking` Parameter Rules

* **`max_tokens` Must Exceed Budget:** `max_tokens` must always be strictly greater than `budget_tokens` to ensure sufficient room for text completion.
* **Minimum Budget Limit:** The minimum value for `budget_tokens` is 1024 tokens.
* **Response Block Structure:** Responses emit an ordered block list where `type: "thinking"` precedes `type: "text"`.

## Next Steps

| Task | Guide |
| :- | :- |
| Anthropic Tool Use | [Anthropic Tool Use](https://docs.neosantara.xyz/en/gateway/anthropic-messages/tool-use.md) |
| Anthropic Streaming | [Anthropic Streaming](https://docs.neosantara.xyz/en/gateway/anthropic-messages/streaming.md) |
| OpenAI Chat Reasoning | [Model Reasoning](https://docs.neosantara.xyz/en/gateway/chat-completions/reasoning.md) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.