本站点为 Anthropic Claude 兼容中转,透传至上游网关。保持 Anthropic 原生报文格式,支持流式输出。
https://api2.bayai.top/anthropic/v1/messages/v1/messagesx-api-key: sk-你的key + anthropic-version: 2023-06-01provider: anthropic
base_url: https://api2.bayai.top
api_key: sk-你的key
model: claude-sonnet-4-5
base_url 不用带 /anthropic,Hermes 会自动补上前缀。
curl -s https://api2.bayai.top/anthropic/v1/messages -X POST \
-H "x-api-key: sk-你的key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
--data '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "你好"}]
}'
返回 {"id":"msg_...","type":"message","content":[{"type":"text","text":"..."}]}
curl -s -N https://api2.bayai.top/anthropic/v1/messages -X POST \
-H "x-api-key: sk-你的key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
--data '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "你好"}]
}'
逐条返回 event: message_start / content_block_delta 等 SSE 事件。
from anthropic import Anthropic
client = Anthropic(
api_key="sk-你的key",
base_url="https://api2.bayai.top/anthropic",
)
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "你好"}],
)
print(msg.content[0].text)
| 现象 | 原因 / 处理 |
|---|---|
| 401 | x-api-key 没带或不对 |
| 返回 HTML | 路径写错,确认是 /anthropic/v1/messages |
| 502 | 中转到上游网络异常,稍后重试 |
| 流式一次性吐完 | 客户端需按 SSE 逐行读取 |