开始使用
Anthropic Messages
Anthropic Messages 适合 Claude Code、Anthropic SDK 等使用消息协议的客户端。
最小请求
curl https://panel.weekendapi.site/v1/messages \
-H "x-api-key: $WEEKENDAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "your-claude-model",
"max_tokens": 512,
"messages": [{"role":"user","content":"你好"}]
}'请求要点
- 使用
x-api-key传递本站 API 密钥,并保留anthropic-version版本头。 messages至少包含 user 消息;system、tools 和多模态内容请按目标模型支持范围使用。max_tokens是消息请求的重要限制,过小会导致输出提前结束。- 流式请求需要客户端支持 Anthropic SSE 事件;不要用 Chat Completions 的解析器直接处理。
如果客户端只支持 Authorization Bearer,请按该客户端的 Anthropic 适配说明配置;不要同时发送多个互相冲突的认证值。