# Claude Haiku 5.5 API (https://wanapi.app/zh-tw/docs/claude-haiku-5-5)





本文件介紹 **Claude Haiku 5.5** 及其專屬的 Messages 參數。請在 `POST https://api.wanapi.app/v1/messages` 中使用 `claude-haiku-5-5`。[比較 Claude 模型](/zh-tw/docs/claude-api)。

## 模型設定 [#模型設定]

| 設定                     | Claude Haiku 5.5    |
| ---------------------- | ------------------- |
| 模型 ID                  | `claude-haiku-5-5`  |
| 同步輸出上限                 | 128000 Token，包含思考用量 |
| 思考模式                   | 自適應或停用              |
| 預設 effort              | `medium`            |
| 強制工具呼叫（`any` / `tool`） | 支援                  |

## 連線並傳送請求 [#連線並傳送請求]

在 [API 金鑰設定](/zh-tw/settings/apikeys)建立金鑰。一把 API 金鑰即可存取所有模型與分組。請將它保存在伺服器環境的 `WAN_API_KEY` 中。傳送 `anthropic-version: 2023-06-01`；只有功能需要時才加入 `anthropic-beta`。

```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-haiku-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-haiku-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"))
```

## 目前 API 支援範圍 [#目前-api-支援範圍]

下表說明此模型的原生介面規格。Wan API 目前透過相容層轉送請求。**請將 `max_tokens` 設為正整數**：網關目前會將 `0` 替換為生成額度，因此此處無法用它僅預熱快取而不生成內容。

目前網關不會轉送 `diagnostics`、`compaction`、`fallbacks`、`fallback_credit_token` 或 `thread`。目前的通道設定也會過濾 `speed`、`service_tier` 與 `inference_geo`。下方仍記載這些欄位，以說明模型的原生規格，但目前尚無法透過此連線使用。回應成功不代表被忽略的欄位已生效。需要這些欄位的 Beta 功能也有相同限制。

## 參數 [#參數]

| 欄位                      | 必填 | 規格                                                                                        |
| ----------------------- | -- | ----------------------------------------------------------------------------------------- |
| `model`                 | 是  | `claude-haiku-5-5`。                                                                       |
| `max_tokens`            | 是  | 0–128000 的整數，包含思考用量。API 沒有預設值。                                                            |
| `messages`              | 是  | 1–100000 則訊息，包含角色，以及字串或內容區塊陣列。請參閱下方對話規則。                                                  |
| `system`                | 否  | 字串或文字區塊陣列。不可為 null。                                                                       |
| `thinking`              | 否  | 預設為自適應，也可停用。不支援手動額度或 between-tools 模式。                                                    |
| `output_config`         | 否  | 物件，包含 `effort`、`format`，以及選填的 Beta 欄位 `task_budget`。                                      |
| `stop_sequences`        | 否  | 停止字串陣列。                                                                                   |
| `stream`                | 否  | 布林值，預設為 false。                                                                            |
| `temperature`           | 否  | 請省略。此處會捨棄；官方相容值為 1。                                                                       |
| `top_p`                 | 否  | 請省略。此處會捨棄；官方相容值為 0.99。                                                                    |
| `top_k`                 | 否  | 不支援，會捨棄。                                                                                  |
| `tools`                 | 否  | 用戶端工具或官方伺服器工具宣告的陣列。                                                                       |
| `tool_choice`           | 否  | `auto`、`none`、`any`，或指定名稱的 `tool`。支援強制工具呼叫。                                               |
| `metadata`              | 否  | 物件；選填的 `user_id` 可為最多 512 個字元的字串或 null。                                                   |
| `cache_control`         | 否  | Null 或 `{"type":"ephemeral","ttl":"5m"}`；TTL 也接受 `1h`。預設 TTL 為 5m。                        |
| `container`             | 否  | Null、容器 ID 字串，或含選填 ID 與最多 20 個 skills 的物件。                                                |
| `context_management`    | 否  | Null 或包含官方上下文編輯設定的物件；須使用對應的 Beta 標頭。                                                      |
| `mcp_servers`           | 否  | 最多 20 個 URL 伺服器的陣列；需要對應的 MCP Beta 標頭。                                                     |
| `service_tier`          | 否  | `auto` 或 `standard_only`。Haiku 沒有 Priority Tier 容量。                                       |
| `inference_geo`         | 否  | `global`、`us` 或 null。省略時使用帳號預設值；請先檢查回報的用量資訊，再確認處理區域。                                      |
| `diagnostics`           | 否  | Null 或物件；`previous_message_id` 可為 null 或最多 256 個字元的字串。                                    |
| `compaction`            | 否  | Null 或 `{"type":"summarize","instructions":"..."}`。instructions 為選填，可為 null，最多 16384 個字元。 |
| `fallbacks`             | 否  | 搭配對應 Beta 的 null 或 `default`。Haiku 沒有自動備援模型；明確指定清單無效。                                     |
| `fallback_credit_token` | 否  | Null、權杖字串，或 `{token,mode}`。API 必須驗證資格與有效性；不可假設任何模型都符合目標資格。                                |
| `speed`                 | 否  | `standard` 或 null。不支援快速模式。                                                                |

## 思考與工具 [#思考與工具]

預設採自適應思考，effort 為 **medium**，並省略思考文字。Effort 接受 `low`、`medium`、`high`、`xhigh`、`max`，或以 null 使用預設值。

```json
{
  "thinking": {"type": "adaptive", "display": "summarized"},
  "output_config": {"effort": "medium"}
}
```

若要停用思考，請使用 `{"type":"disabled"}`，搭配 low、medium 或 high effort。停用模式不可包含 `display` 或 `block_binding`。`enabled`、`budget_tokens`、`between_tools`，以及在 xhigh/max 下停用思考均無效。

自適應模式的 `display` 接受 `omitted`、`summarized` 或 null。通用 Beta 值 `updates` 需要 `thinking-display-updates-2026-08-18`；Anthropic 目前尚未確認 Haiku 可提供可讀的進度更新，因此請勿依賴這類輸出。

選填的 `thinking.block_binding` 需要 `thinking-binding-controls-2026-08-01`。它可為 null，或含 `prefix_mismatch_behavior` 的物件，其值為 `error`、`drop_block` 或 null。重播歷史訊息時，請保持先前對話輪次與完整思考區塊不變。思考簽章綁定於產生該簽章的帳號，或與其連結的帳號。

`output_config.task_budget` 可為 null，或 `{ "type": "tokens", "total": 20000 }`，並可選填整數或 null 的 `remaining`。它需要 `task-budgets-2026-03-13`；`total` 必須至少為 20000。此處未對 `remaining` 施加額外範圍限制。

### 工具與結構化輸出 [#工具與結構化輸出]

用戶端工具必須有 1–128 個英文字母、數字、底線或連字號組成的名稱，以及 `type: "object"` 的 `input_schema`。使用 `tool_choice: {"type":"any"}` 或 `{"type":"tool","name":"lookup"}` 可強制呼叫已宣告的工具。在自適應思考模式下，強制工具回應會直接從工具呼叫開始，不包含思考區塊。

`disable_parallel_tool_use` 是 auto、any 與 tool 選項可使用的選填布林值，不是 none 的欄位。回傳工具結果時，請使用原始 `tool_use_id`。用戶端工具由您的應用程式執行。

```json
{
  "tools": [{
    "name": "lookup",
    "description": "Look up a product by SKU.",
    "input_schema": {
      "type": "object",
      "properties": {"sku": {"type": "string"}},
      "required": ["sku"],
      "additionalProperties": false
    }
  }],
  "tool_choice": {"type": "tool", "name": "lookup"}
}
```

結構化回應使用 `output_config.format: {"type":"json_schema","schema":{...}}`。請遵循 Anthropic 支援的 JSON Schema 子集，包括在物件上設定 `additionalProperties: false`。結構正確不保證內容符合事實。嚴格工具與結構化輸出有整體結構描述的限制；請參閱[官方結構化輸出文件](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)。

電腦操作需要 `computer_toolset_20260801`；舊版電腦工具無效。瀏覽器操作有獨立的 `browser_toolset_20260801`。宣告工具並不代表已驗證完整的伺服器工具工作階段可以運作。使用前，請閱讀該工具的官方指南與 Beta 要求。

## 媒體輸入 [#媒體輸入]

圖片與 PDF 請使用可公開存取的 HTTP(S) URL，放在使用者訊息的 `content` 區塊中。檔案須由您自行託管；此整合不提供 Files API 或上傳功能。圖片輸入範例：

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

PDF 請使用 `document` 區塊。繼續對話時，請保持工具呼叫 ID、完整思考區塊與簽章不變。用戶端工具由您的應用程式執行並傳回結果；宣告工具不會執行工具。

## 價格 [#價格]

每 100 萬 Token 的美元價格

目前費率已包含各分組的倍率。價格快取最長保留 2 分鐘。

一把 API 金鑰即可存取所有模型與分組。「預設」標示自動路由順序中第一個符合條件的分組；請求依實際選用分組的費率計費。

### Claude Haiku 5.5

`claude-haiku-5-5`

| 計費 Token | claude · 預設 · 輸入 Token ≤ 100,000 | claude · 預設 · 輸入 Token > 100,000 |
| --- | ---: | ---: |
| 輸入（未快取） | US$0.05 | US$0.25 |
| 輸出 | US$0.25 | US$1.25 |
| 快取讀取 | US$0.005 | US$0.025 |
| 快取寫入 · 5 分鐘 | US$0.0625 | US$0.3125 |
| 快取寫入 · 1 小時 | US$0.1 | US$0.5 |

門檻計算依據：未快取的輸入 Token。選定的價格區間適用於整個請求，不僅限於超過門檻的 Token。

— 表示目前沒有經確認的報價，不代表免費。

只有回應中回報相應快取用量時，才適用快取費率。請勿將快取 Token 再次計入未快取輸入。

將各項計費 Token 數量乘以對應費率後加總，再除以 1,000,000。思考 Token 已包含在輸出 Token 中，不會重複計費。快取讀取、5 分鐘寫入與 1 小時寫入分別採用不同費率。按長度計價時，請先選擇適用區間，再計算請求費用。

## 回應與串流 [#回應與串流]

已完成的訊息包含 `id`、`type`、`role`、`model`、`content`、`stop_reason` 與 `usage`。請從 `content` 讀取文字區塊；第一個區塊也可能是思考內容或工具呼叫。以下僅為示例：

```json
{
  "id": "msg_example",
  "type": "message",
  "role": "assistant",
  "model": "claude-haiku-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}
}
```

設為 `stream: true` 可使用 SSE，並搭配 `curl -N`。請處理 `message_start`、`content_block_start`、`content_block_delta`、`content_block_stop`、`message_delta` 與 `message_stop`，以及 `ping` 和串流錯誤。請讀取最終用量，不要將每個區塊視為完整回應。

## OpenAI 相容格式 [#openai-相容格式]

同一模型 ID 也適用於 `POST /v1/chat/completions` 與 `POST /v1/responses`。請使用 `Authorization: Bearer YOUR_API_KEY`，並將 OpenAI SDK 基底 URL 設為 `https://api.wanapi.app/v1`。Chat Completions 使用 `messages`；Responses 使用 `input`。這些欄位會轉換為 Messages 格式，因此使用上述原生參數時，請選用 `/v1/messages`。

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

## 用量記錄與錯誤 [#用量記錄與錯誤]

[LLM 記錄](/zh-tw/usage)顯示最近 7 天已完成的呼叫，包含模型、輸入 Token、輸出 Token 與費用。呼叫完成後請重新整理，並依 `claude-haiku-5-5` 篩選。圖片與影片請查看[任務記錄](/zh-tw/tasks)。

請求失敗時，請檢查 HTTP 狀態與 `error` 物件。核對金鑰、[餘額](/zh-tw/docs/balance)、模型 ID 與支援的參數組合。拒絕回應或因達到輸出上限而停止，與 HTTP 錯誤不同。若請求或串流中斷，請先查看記錄再重試：新請求可能產生另一筆費用。

## 模型參考資料 [#模型參考資料]

* [Haiku 5.5 模型總覽](https://platform.claude.com/docs/en/models/haiku-5-5/overview)
* [Haiku 5.5 遷移指南](https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide)
* [Messages 參考文件](https://platform.claude.com/docs/en/api/messages/create)
* [Beta Messages 參考文件](https://platform.claude.com/docs/en/api/beta/messages/create)
* [思考](https://platform.claude.com/docs/en/build-with-claude/thinking)、[effort](https://platform.claude.com/docs/en/build-with-claude/effort)、[任務額度](https://platform.claude.com/docs/en/build-with-claude/task-budgets)
* [隨需壓縮](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand)、[上下文編輯](https://platform.claude.com/docs/en/build-with-claude/context-editing)
* [提示快取](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)、[視覺](https://platform.claude.com/docs/en/build-with-claude/vision)、[PDF 支援](https://platform.claude.com/docs/en/build-with-claude/pdf-support)
