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

# Claude 原生格式

> 基于生产环境复核，使用 Anthropic Messages API 调用 Claude

> 更新日期：2026-06-06

# Claude 原生格式

```
POST /v1/messages
```

本文页只写入 `2026-03-22` 已在 Crazyrouter 生产环境复核过的 Claude Messages 用法。

当前主示例模型：

* `claude-opus-4-8`
* `claude-opus-4-8`

## 认证

本轮已复核以下两种写法都可用：

```text theme={null}
x-api-key: YOUR_API_KEY
```

```text theme={null}
Authorization: Bearer YOUR_API_KEY
```

同时保留：

```text theme={null}
anthropic-version: 2023-06-01
```

***

## 基本对话

```bash cURL theme={null}
curl https://api.crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 128,
    "messages": [
      {
        "role": "user",
        "content": "Explain quantum computing in one sentence."
      }
    ]
  }'
```

当前生产返回的关键结构：

```json theme={null}
{
  "type": "message",
  "content": [
    {
      "type": "text",
      "text": "..."
    }
  ]
}
```

***

## Function Calling

当前生产环境中，Claude 的工具调用可稳定通过 `/v1/messages` 返回 `tool_use`。

首轮联调建议：

* 显式传 `tool_choice`
* 提示词里写清楚“必须调用工具，不要直接回答”

```bash cURL theme={null}
curl https://api.crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 256,
    "tools": [
      {
        "name": "get_time",
        "description": "Get the current time for a timezone",
        "input_schema": {
          "type": "object",
          "properties": {
            "timezone": {
              "type": "string"
            }
          },
          "required": ["timezone"]
        }
      }
    ],
    "tool_choice": {
      "type": "any"
    },
    "messages": [
      {
        "role": "user",
        "content": "Use the get_time tool for Asia/Shanghai. Do not answer directly."
      }
    ]
  }'
```

当前生产验证返回的关键字段：

```json theme={null}
{
  "stop_reason": "tool_use",
  "content": [
    {
      "type": "tool_use",
      "name": "get_time",
      "input": {
        "timezone": "Asia/Shanghai"
      }
    }
  ]
}
```

***

## Extended Thinking

本轮生产复核中，明确返回 `thinking` block 的组合是：

* `claude-opus-4-8`

基础版 `claude-opus-4-8` 本轮没有拿到同等明确的 thinking block，因此这里优先写 thinking 能力。

```bash cURL theme={null}
curl https://api.crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 320,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 128
    },
    "messages": [
      {
        "role": "user",
        "content": "Which is larger, 9.11 or 9.9? Explain briefly."
      }
    ]
  }'
```

当前生产验证返回的关键字段：

```json theme={null}
{
  "content": [
    {
      "type": "thinking",
      "thinking": "..."
    },
    {
      "type": "text",
      "text": "..."
    }
  ]
}
```

<Warning>
  使用 `thinking` 时，`max_tokens` 必须大于 `budget_tokens`。思考 Token 也计入成本。
</Warning>

***

## 当前建议

* 普通文本对话：优先用 `claude-opus-4-8`
* 工具调用：优先用 `claude-opus-4-8`，并在首轮验证里加 `tool_choice`
* 明确需要 thinking block：优先用 `claude-opus-4-8`

相关页面：

* [核心能力：Tool Calling](/features/tool-calling)
* [核心能力：Reasoning](/features/reasoning)
* [模型官方定价方式](/reference/official-pricing-methods)
