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

# Claude Sonnet 5.5

> Claude Sonnet 5.5 程式設計、知識工作和工具工作流，包含新版思考設定及遷移注意事項。

Claude Sonnet 5.5 兼顧響應速度與推理能力，面向程式設計、知識工作和多步驟工具工作流。使用完整 MixRoute ID `claude-sonnet-5-5`。

## 模型資訊

| 欄位 | 說明 |
| - | - |
| `model` | claude-sonnet-5-5 |
| `context` | 1M tokens |
| `max output` | 128K tokens |
| `input / output` | 輸入文本和影像，輸出文本及工具呼叫內容塊。 |

以上為模型規格；實際限制、價格和託管工具可用性取決於賬號及路由。Claude 專有配置優先使用原生 Messages API。

## Messages API

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/messages" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "anthropic-version: 2023-06-01" \
  --data '{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "output_config": {
    "effort": "low"
  },
  "messages": [
    {
      "role": "user",
      "content": "Explain the tradeoffs of database indexes."
    }
  ]
}'
```

| 欄位 | 說明 |
| - | - |
| `model` | 必填：claude-sonnet-5-5。 |
| `max_tokens` | 必填，輸出預算包含思考和可見文本。 |
| `messages` | 必填，會話訊息；系統指令使用頂層 system 欄位。 |
| `output_config.effort` | low、medium、high、xhigh、max，預設 high。 |
| `thinking.type` | adaptive（預設）或 between\_tools，不支援舊版 enabled/disabled。 |
| `thinking.display` | adaptive 下預設為 omitted，summarized 返回可讀摘要；between\_tools 不傳此欄位。 |
| `tools` | Claude 工具包含 name、description、input\_schema；strict 工具支援取決於上游平臺。 |
| `tool_choice` | 使用 `{"type":"auto"}`，不支援強制選擇 any 或 tool。 |
| `stream` | true 啟用原生 Messages SSE 事件流。 |

## 思考設定

省略 `thinking` 會啟用自適應思考。若要關閉首次回答前的思考，使用 `thinking: {"type":"between_tools"}`，並將 effort 設為 `low`、`medium` 或 `high`。工具呼叫之間的進度更新仍可能以 thinking 內容塊返回，並不表示整個工具流程完全沒有思考內容。

```json theme={null}
{
  "thinking": {
    "type": "between_tools"
  },
  "output_config": {
    "effort": "low"
  }
}
```

不要將 `between_tools` 與 `xhigh`/`max`、`display`、`budget_tokens` 或 `block_binding` 組合；最高兩檔 effort 使用 adaptive。移除非預設取樣設定（`temperature`、`top_p`、`top_k`）和舊版手動思考預算。

## 工具呼叫與響應

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/messages" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "anthropic-version: 2023-06-01" \
  --data '{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "output_config": {
    "effort": "low"
  },
  "messages": [
    {
      "role": "user",
      "content": "Call lookup_status for service demo, then report the returned status."
    }
  ],
  "tools": [
    {
      "name": "lookup_status",
      "description": "Return the status of a named service.",
      "input_schema": {
        "type": "object",
        "properties": {
          "service": {
            "type": "string"
          }
        },
        "required": [
          "service"
        ],
        "additionalProperties": false
      },
      "strict": true
    }
  ],
  "tool_choice": {
    "type": "auto"
  }
}'
```

auto 模式下，模型可以呼叫工具，也可以直接回答；在提示詞中說明何時需要工具。若所選路由不支援 strict，省略 strict，並在應用中校驗返回參數。

當 `stop_reason` 為 `tool_use` 時，處理所有 `tool_use` 塊，再通過 user 訊息中的 `tool_result` 和對應 `tool_use_id` 回傳結果。將完整 assistant content 陣列原樣追加到會話，包括空 thinking 塊及簽名；不要將思考塊移到其他模型或無關會話。

預設不返回思考正文，因此 content 陣列可能在文本之前包含空 thinking 塊。應按型別讀取，而不是假設 content\[0] 一定是文本：

```python theme={null}
for block in response.json().get("content", []):
    if block.get("type") == "text":
        print(block["text"])
```

## OpenAI 相容對話

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/chat/completions" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Explain the tradeoffs of database indexes."
    }
  ]
}'
```

文本結果從 `choices[0].message.content` 讀取；不要假設 Claude 專有思考設定與 Chat Completions 欄位同名對映，需要這些控制時使用 Messages。

## 從 Sonnet 5 遷移

1. 使用不帶日期字尾的 `claude-sonnet-5-5`。
2. 將 disabled 改為 between\_tools，並使用 high 或更低的 effort。
3. 將強制工具選擇改為 auto，完整保留思考塊與簽名。
4. 移除 assistant 預填充、手動思考預算和非預設取樣設定。
5. 重新評估輸出預算與 effort；託管電腦操作、advisor 等工具還受各平臺相容性限制。

[Messages API](/zh-hant/api-reference/endpoint/messages) | [Chat Completions API](/zh-hant/api-reference/endpoint/chat-openai)


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