Anthropic
Anthropic Messages
Send a structured list of input messages and receive a model-generated response.
POST
v1/messagesAuthorizations
X-Api-Keystringheaderrequired
Use the following format for authentication: sk-pat-您的AccessToken
anthropic-versionstringheaderrequired
API 版本号,当前使用 2023-06-01
密钥的值使用HAI Gateway的个人访问令牌(以 sk-pat- 开头),无需在Anthropic处单独申请 API Key。
Base URL
Body 参数
请求体格式与 Anthropic 官方 Messages API 完全一致,详细参数说明请参考 Anthropic 官方文档。
cURL
curl https://api.hai.network/anthropic/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "X-Api-Key: sk-pat-您的Access Token" \
-d '{
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, world"
}
]
}'200
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"model": "claude-opus-4-6",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 10
}
}