> ## 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 OpenAI 兼容格式

> 基于 2026-03-23 Crazyrouter 生产环境验证的 Claude Chat Completions 兼容路径

> 更新日期：2026-06-23

# Claude OpenAI 兼容格式

```
POST /v1/chat/completions
```

截至 2026 年 3 月 23 日，Crazyrouter 生产环境已验证：

* `claude-opus-4-8` 非流式请求返回 `object: "chat.completion"`
* `message` 当前稳定包含 `role`、`content`
* 流式请求返回 `chat.completion.chunk`
* SSE 仍以 `data: [DONE]` 结束

<Warning>
  本页是 Claude 走 OpenAI Chat Completions 兼容格式的普通对话路径。Claude 原生 `tool_use`、Claude Code、以及依赖工具调用的 Agent 编程场景，请优先使用 [Claude 原生格式](/chat/anthropic/messages) 的 `POST /v1/messages`。OpenAI 兼容格式不保证等价支持 Claude 原生工具块。
</Warning>

***

## 非流式请求

```bash theme={null}
curl https://api.crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Compare PostgreSQL and MySQL in one paragraph."}
    ],
    "max_tokens": 256,
    "temperature": 0.2
  }'
```

关键响应形态：

```json theme={null}
{
  "object": "chat.completion",
  "model": "claude-opus-4-8",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "PostgreSQL and MySQL are both popular..."
      }
    }
  ]
}
```

***

## 流式请求

```bash theme={null}
curl https://api.crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [
      {"role": "user", "content": "Say hello in one sentence."}
    ],
    "max_tokens": 128,
    "stream": true
  }'
```

2026-03-23 的生产环境流式探针里，开头片段如下：

```text theme={null}
data: {"object":"chat.completion.chunk","model":"claude-opus-4-8","choices":[{"delta":{"role":"assistant"}}]}
data: {"object":"chat.completion.chunk","model":"claude-opus-4-8","choices":[{"delta":{"content":"Hello! ..."}}]}
data: [DONE]
```

<Note>
  如果你需要 Claude 原生的 `thinking`、原生工具块或文档输入，优先使用 [Claude Messages](/chat/anthropic/messages)。
</Note>
