# Claude Sonnet 5.5 API (https://wanapi.app/docs/claude-sonnet-5-5)





This reference covers **Claude Sonnet 5.5** and its own Messages parameters. Use `claude-sonnet-5-5` with `POST https://api.wanapi.app/v1/messages`. [Compare Claude models](/docs/claude-api).

## Model settings [#model-settings]

| Setting                            | Claude Sonnet 5.5                 |
| ---------------------------------- | --------------------------------- |
| Model ID                           | `claude-sonnet-5-5`               |
| Context window                     | 1M tokens                         |
| Maximum synchronous output         | 128000 tokens, including thinking |
| Thinking modes                     | Adaptive or between\_tools        |
| Default effort                     | `high`                            |
| Forced tool calls (`any` / `tool`) | Not supported                     |

## Connect and send a request [#connect-and-send-a-request]

Create a key in [API key settings](/settings/apikeys). One API key works across all models and groups. Keep it in your server environment as `WAN_API_KEY`. Send `anthropic-version: 2023-06-01`; add `anthropic-beta` only for features that require it.

```bash
curl https://api.wanapi.app/v1/messages \
  -H "x-api-key: $WAN_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Explain the purpose of a database index in three sentences."}]
  }'
```

```python
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["WAN_API_KEY"],
    base_url="https://api.wanapi.app",
)
message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain the purpose of a database index in three sentences."}],
)
print("".join(block.text for block in message.content if block.type == "text"))
```

## Current API coverage [#current-api-coverage]

The table below describes this model's native contract. Wan API currently forwards requests through a compatibility layer. **Use a positive `max_tokens` value**: the gateway currently replaces `0` with a generation budget, so it cannot be used for cache-only prewarming here.

The current gateway does not forward `diagnostics`, `compaction`, `fallbacks`, `fallback_credit_token` or `thread`. It also filters `speed`, `service_tier` and `inference_geo` in the current channel configuration. These fields are documented below to explain the model's contract, but they are not available through this connection yet. A successful response does not mean an ignored field took effect. Beta features that need these fields share the same limitation.

## Parameters [#parameters]

| Parameter                         | Type / required                    | Official constraints and defaults                                                                                                                                                                                                                                    |
| --------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`                           | string, required                   | `claude-sonnet-5-5`.                                                                                                                                                                                                                                                 |
| `max_tokens`                      | integer, required                  | 0–128000, including thinking tokens. Officially, 0 populates the prompt cache without generating output; see Current API coverage below.                                                                                                                             |
| `messages`                        | object array, required             | At least one conversation message, at most 100000. Each has `role` and `content`; content is a string or content-block array. Ordinary turns use `user`/`assistant`. Mid-conversation `system` messages follow the official placement rules.                         |
| `system`                          | string or text-block array         | Top-level instructions. Text blocks can include cache breakpoints.                                                                                                                                                                                                   |
| `thinking`                        | object                             | Default: `{"type":"adaptive"}`. The other supported mode is `{"type":"between_tools"}`. Manual budgets and `disabled` are rejected.                                                                                                                                  |
| `thinking.display`                | enum                               | Adaptive mode only: `omitted` (default) or `summarized`. An omitted summary does not mean thinking is disabled.                                                                                                                                                      |
| `thinking.block_binding`          | object, beta                       | Adaptive mode only. Requires `thinking-binding-controls-2026-08-01`; follow the official preserved-thinking contract.                                                                                                                                                |
| `output_config.effort`            | enum or null                       | `low`, `medium`, `high`, `xhigh`, `max`; default `high`. Null leaves the default in effect.                                                                                                                                                                          |
| `output_config.format`            | object or null                     | Structured JSON output: `{"type":"json_schema","schema":{...}}`. Use the supported JSON Schema subset.                                                                                                                                                               |
| `stream`                          | boolean                            | Default `false`; `true` returns SSE events.                                                                                                                                                                                                                          |
| `stop_sequences`                  | string array                       | Officially stops generation at a matching string. The upstream compatibility check did not enforce this behavior.                                                                                                                                                    |
| `temperature`                     | number or null                     | Only 1 is accepted for compatibility; omit it. Other non-null values are rejected.                                                                                                                                                                                   |
| `top_p`                           | number or null                     | Only 0.99–1 is accepted for compatibility; omit it.                                                                                                                                                                                                                  |
| `top_k`                           | no non-null value                  | Sampling is unsupported; omit this property.                                                                                                                                                                                                                         |
| `tools`                           | object array                       | Client tools have `name`, `input_schema`, and optional description / strictness settings. Server tools use their versioned official definitions.                                                                                                                     |
| `tool_choice`                     | object                             | `auto` (default) or `none`. `any` and named forced `tool` are rejected. `auto` may include `disable_parallel_tool_use`.                                                                                                                                              |
| `metadata.user_id`                | string or null                     | At most 512 characters; use an opaque identifier.                                                                                                                                                                                                                    |
| `cache_control`                   | object or null                     | `type: "ephemeral"`; `ttl: "5m"` (default) or `"1h"`. Sonnet 5.5 requires at least 512 cacheable tokens. Block-level cache breakpoints are also supported by the official API.                                                                                       |
| `diagnostics`                     | object or null                     | `previous_message_id`: string of at most 256 characters or null. Requests cache-divergence diagnostics.                                                                                                                                                              |
| `service_tier`                    | enum                               | `auto` (default) or `standard_only`.                                                                                                                                                                                                                                 |
| `speed`                           | enum or null                       | Omit or use `standard` / null. Sonnet 5.5 does not support `fast`.                                                                                                                                                                                                   |
| `inference_geo`                   | string or null                     | The official default comes from the account settings. An accepted request alone does not verify geographic processing.                                                                                                                                               |
| `fallbacks`                       | string, object array or null, beta | `"default"` or up to three fallback entries. Each requires `model`; optional overrides are `max_tokens`, `thinking`, `output_config` and `speed`. See the fallback rules below.                                                                                      |
| `fallback_credit_token`           | string, object or null             | A token from a prior refusal, or `{"token":"...","mode":"strict"}`. Object form requires `fallback-credit-2026-07-01`; mode is `strict` (default) or `best_effort`. Cannot accompany a non-null `fallbacks` value.                                                   |
| `container`                       | string, object or null             | Container ID, or container configuration with optional `id` and `skills` (at most 20). Skills use the official type, identifier and version fields.                                                                                                                  |
| `context_management`              | object or null                     | Official context-edit configuration, including `edits`; null omits the setting. Model-specific edit compatibility still applies.                                                                                                                                     |
| `mcp_servers`                     | object array                       | Official MCP server definitions, subject to the required beta version and server authentication. An empty-array probe does not verify remote MCP execution.                                                                                                          |
| `compaction`                      | object or null, beta               | `{"type":"summarize"}`, with `compact-2026-09-04`; null omits compaction. Enabled compaction cannot be combined with non-null `context_management`, stop sequences or structured-output format. The signed compaction behavior did not pass the current test.        |
| `messages[].output_config.effort` | enum, beta                         | Per-message effort on a system message; requires `mid-conversation-output-config-2026-07-01`. Effort-only system messages may appear anywhere; content-bearing system groups follow the official placement rules. It must not change effort in `between_tools` mode. |

## Thinking and tools [#thinking-and-tools]

`between_tools` accepts only its `type` property and effort `low`, `medium` or `high`. Do not send `display`, `budget_tokens` or `block_binding` with it. Example:

```json
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "thinking": {"type": "between_tools"},
  "output_config": {"effort": "medium"},
  "messages": [{"role": "user", "content": "Explain this concept briefly."}]
}
```

Assistant prefilling is unsupported. To continue a `pause_turn`, replay the returned server-tool assistant content unchanged. Compaction summarizes existing history and is not an assistant prefill. Preserve thinking blocks and signatures exactly; do not move them between models or edit earlier history without following the official binding rules.

On the native Claude API, computer use requires `computer_toolset_20260801`; `computer_20251124` is rejected. Advisor configurations using `claude-opus-4-8`, `claude-opus-4-7` or `claude-sonnet-5` are also rejected for this executor.

## Media input [#media-input]

For images and PDFs, use publicly accessible HTTP(S) URLs in a user message's `content` blocks. Host your files yourself; this integration does not provide a Files API or uploads. Example image input:

```json
{"role":"user","content":[
  {"type":"image","source":{"type":"url","url":"https://example.com/chart.png"}},
  {"type":"text","text":"What does this chart show?"}
]}
```

Use a `document` block for a PDF. Keep tool-use IDs, complete thinking blocks and signatures unchanged when continuing a conversation. Your application executes client tools and returns their results; declaring a tool does not execute it.

## Pricing [#pricing]

USD per 1 million tokens

Current rates include each group’s multiplier. Prices are cached for up to 2 minutes.

One API key works across all models and groups. Default marks the first eligible group in the automatic routing order; the request is billed at the rates of the group actually selected.

### Claude Sonnet 5.5

`claude-sonnet-5-5`

| Billable tokens | claude · Default · All input lengths |
| --- | ---: |
| Input (uncached) | $1 |
| Output | $5 |
| Cache read | $0.05 |
| Cache write · 5 minutes | $1.25 |
| Cache write · 1 hour | $2 |

— means no verified quote is available; it does not mean free.

Cache rates apply only when the response reports the corresponding cache usage. Do not count cached tokens again as uncached input.

Multiply each billable token count by its matching rate and divide the total by 1,000,000. Thinking tokens are included in output tokens, not charged a second time. Cache reads, 5-minute writes and 1-hour writes have separate rates. For length-based pricing, choose the applicable band before calculating the request cost.

## Response and streaming [#response-and-streaming]

A completed message includes `id`, `type`, `role`, `model`, `content`, `stop_reason` and `usage`. Read text blocks from `content`; the first block may instead be thinking or a tool call. This example is illustrative:

```json
{
  "id": "msg_example",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [{"type": "text", "text": "A database index helps locate rows without scanning the whole table."}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 24, "output_tokens": 18}
}
```

Set `stream: true` for SSE and use `curl -N`. Handle `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta` and `message_stop`, plus `ping` and stream errors. Read final usage rather than treating every chunk as a complete response.

## OpenAI-compatible formats [#openai-compatible-formats]

The same model ID works with `POST /v1/chat/completions` and `POST /v1/responses`. Use `Authorization: Bearer YOUR_API_KEY` and the OpenAI SDK base URL `https://api.wanapi.app/v1`. Chat Completions uses `messages`; Responses uses `input`. Their fields are converted to Messages, so use `/v1/messages` for the native parameters documented above.

```bash
curl https://api.wanapi.app/v1/chat/completions \
  -H "Authorization: Bearer $WAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5-5","max_tokens":256,"messages":[{"role":"user","content":"Reply with OK."}]}'
```

## Usage logs and errors [#usage-logs-and-errors]

[LLM logs](/usage) show completed calls from the last 7 days, with the model, input tokens, output tokens and cost. Refresh after a call and filter by `claude-sonnet-5-5`. Use [Task logs](/tasks) for images and videos.

Inspect the HTTP status and `error` object when a request fails. Check the key, [balance](/docs/balance), model ID and supported parameter combinations. A refusal or output-limit stop is different from an HTTP error. If a request or stream is interrupted, check the logs before retrying: a new request can incur another charge.

## Model references [#model-references]

* [Official Sonnet 5.5 overview](https://platform.claude.com/docs/en/models/sonnet-5-5/overview)
* [Sonnet 5.5 changes and restrictions](https://platform.claude.com/docs/en/models/sonnet-5-5/whats-new-sonnet-5-5)
* [Messages parameter reference](https://platform.claude.com/docs/en/api/messages/create)
* [Per-message effort](https://platform.claude.com/docs/en/build-with-claude/effort)
* [On-demand compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand)
* [Refusals and fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback)
* [Fallback credit](https://platform.claude.com/docs/en/build-with-claude/fallback-credit)
