Anthropic Messages
Anthropic Messages 接口适合 Claude Code、Anthropic SDK 和兼容 Messages 协议的客户端。
Base URL
text
https://quotarouter.ai常用请求路径:
text
/v1/messages
/v1/models认证头:
http
x-api-key: YOUR_QUOTAAPI_KEY
anthropic-version: 2023-06-01Messages 请求
bash
curl https://quotarouter.ai/v1/messages \
-H "x-api-key: YOUR_QUOTAAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4.8",
"max_tokens": 120,
"system": "You answer with concise technical guidance.",
"messages": [
{
"role": "user",
"content": "Show a one-sentence QuotaAPI connection check."
}
]
}'流式响应
bash
curl https://quotarouter.ai/v1/messages \
-H "x-api-key: YOUR_QUOTAAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4.8",
"max_tokens": 120,
"stream": true,
"messages": [
{ "role": "user", "content": "Stream a short response." }
]
}'Models
bash
curl https://quotarouter.ai/v1/models \
-H "x-api-key: YOUR_QUOTAAPI_KEY" \
-H "anthropic-version: 2023-06-01"客户端映射
| 客户端字段 | 推荐值 |
|---|---|
| Base URL | https://quotarouter.ai |
| API Key | YOUR_QUOTAAPI_KEY |
| Header | x-api-key |
| Version | 2023-06-01 |
Claude Code 通常只需要设置 ANTHROPIC_BASE_URL 和认证变量。具体变量名可能随客户端版本变化,配置后请用短请求验证。
排查
- 缺少
anthropic-version:部分客户端或手写请求会被拒绝。 - Base URL 写成
/v1:Claude Code 可能再次拼接路径,导致请求地址错误。 - 模型不可用:检查 API Key 的 Claude 分组权限和模型名称。
- 余额不足:控制台会显示扣费失败或余额不足记录。
