Anthropic · Messages
POST /v1/messages
Xác thực: trang xác thực. Claude Code: chương. Base là gốc site — xem giao thức.
http
x-api-key: sk-xxxx
anthropic-version: 2023-06-01
Content-Type: application/jsonbash
curl https://api.daoxe.com/v1/messages \
-H "x-api-key: sk-xxxx" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "sao chép từ /v1/models",
"max_tokens": 64,
"messages": [{"role":"user","content":"ping"}]
}'max_tokens
Yêu cầu Messages thường bắt buộc có
max_tokens.Phản hồi thành công (cấu trúc)
json
{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"content": [{ "type": "text", "text": "..." }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 10, "output_tokens": 20 }
}Ví dụ lỗi
json
{"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: required"}}
{"error":{"message":"Invalid token","code":401}}