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

# Claude Sonnet 5

> Anthropic's Claude Sonnet 5 via Anyfast. The latest Sonnet model with a 1M context window, adaptive thinking, and strong coding and agent capabilities.

Claude Sonnet 5 is Anthropic's latest Sonnet model, available through Anyfast via the native Anthropic Messages API. It combines Sonnet-class speed with stronger coding, agentic execution, long-context reasoning, and analysis capabilities, making it well suited for production assistants, developer tools, and complex multi-step workflows.

## Key capabilities

* **1M context window** — 1M tokens by default, with 128K max output tokens
* **Adaptive thinking** — On by default; control depth with `output_config.effort`, or use `thinking: {"type": "disabled"}` to turn it off
* **Same API shape** — Requests, responses, and streaming keep the same shape as Claude Sonnet 4.6
* **New tokenizer** — The same text produces about 30% more tokens than Claude Sonnet 4.6
* **Model ID** — Use `claude-sonnet-5`

## Quick example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-5",
      "max_tokens": 1024,
      "messages": [
        { "role": "user", "content": "Write a Python function to merge two sorted arrays." }
      ]
    }'
  ```

  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai"
  )

  message = client.messages.create(
      model="claude-sonnet-5",
      max_tokens=1024,
      messages=[
          {"role": "user", "content": "Write a Python function to merge two sorted arrays."}
      ]
  )

  print(message.content[0].text)
  ```

  ```python Streaming theme={null}
  import anthropic

  client = anthropic.Anthropic(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai"
  )

  with client.messages.stream(
      model="claude-sonnet-5",
      max_tokens=1024,
      messages=[
          {"role": "user", "content": "Explain the difference between async and sync programming."}
      ],
  ) as stream:
      for text in stream.text_stream:
          print(text, end="")
  ```
</CodeGroup>

## Parameters

| Parameter        | Type    | Required | Description                                                                                                          |
| ---------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `model`          | string  | Yes      | Must be `claude-sonnet-5`                                                                                            |
| `messages`       | array   | Yes      | List of `{ role, content }` objects                                                                                  |
| `max_tokens`     | integer | Yes      | Maximum tokens to generate. Claude Sonnet 5 supports up to 128K output tokens.                                       |
| `output_config`  | object  | No       | Use `{"effort":"low" \| "medium" \| "high" \| "xhigh" \| "max"}` to control adaptive thinking depth. Default: `high` |
| `thinking`       | object  | No       | Omit it to use default adaptive thinking, or use `{"type":"disabled"}` to turn thinking off.                         |
| `stream`         | boolean | No       | Enable SSE streaming. Default: `false`                                                                               |
| `stop_sequences` | array   | No       | Sequences that stop generation                                                                                       |

<Note>
  Claude Sonnet 5 uses adaptive thinking by default. Use `output_config.effort` to tune reasoning depth (`low`, `medium`, `high`, `xhigh`, or `max`). Manual extended thinking (`thinking: {type: "enabled", budget_tokens: N}`) returns a 400 error, and non-default `temperature`, `top_p`, or `top_k` values also return a 400 error. Use `thinking: {type: "disabled"}` to turn thinking off.
</Note>

<Note>
  Claude Sonnet 5 uses a new tokenizer. The same text produces approximately 30% more tokens than on Claude Sonnet 4.6, so prompt counts and `max_tokens` budgets should be recalculated before migrating.
</Note>

<Note>
  Requests involving prohibited or high-risk cybersecurity topics may be refused. Refusals return `stop_reason: "refusal"`.
</Note>

<Card title="API Reference" icon="code" href="/api-reference/model-api/anthropic/claude-sonnet-5">
  View the interactive API playground for Claude Sonnet 5.
</Card>

<script src="/feedback.js" />
