curl --request POST \
--url https://api.aihubmax.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "比较 PostgreSQL 和 MySQL 的主要区别"
}
]
}
'{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 150
}
}{
"error": {
"message": "请求参数无效",
"type": "invalid_request_error"
}
}{
"error": {
"message": "API密钥无效",
"type": "authentication_error"
}
}{
"error": {
"message": "请求参数无效",
"type": "invalid_request_error"
}
}{
"error": {
"message": "访问被拒绝",
"type": "permission_error"
}
}{
"error": {
"message": "请求频率超限",
"type": "rate_limit_error"
}
}{
"error": {
"message": "服务器内部错误",
"type": "server_error"
}
}Claude 格式
Claude 格式 - 消息
- 适用于所有兼容 Claude 格式模型的通用 Anthropic Messages API 参考
- 最简化参数,快速上手
- 发送包含文本内容的结构化输入消息列表
- 系统提示词:自定义 AI 的角色和行为
- 支持流式和非流式响应
POST
/
v1
/
messages
curl --request POST \
--url https://api.aihubmax.com/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "比较 PostgreSQL 和 MySQL 的主要区别"
}
]
}
'{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 150
}
}{
"error": {
"message": "请求参数无效",
"type": "invalid_request_error"
}
}{
"error": {
"message": "API密钥无效",
"type": "authentication_error"
}
}{
"error": {
"message": "请求参数无效",
"type": "invalid_request_error"
}
}{
"error": {
"message": "访问被拒绝",
"type": "permission_error"
}
}{
"error": {
"message": "请求频率超限",
"type": "rate_limit_error"
}
}{
"error": {
"message": "服务器内部错误",
"type": "server_error"
}
}授权
所有接口均需要使用Bearer Token进行认证
使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求体
application/json
模型名称,如 claude-sonnet-4-6
示例:
"claude-sonnet-4-6"
对话消息列表
Show child attributes
Show child attributes
最大生成token数(必填)
系统提示词
采样温度 (0-1)
必填范围:
0 <= x <= 1核采样参数 (0-1)
必填范围:
0 <= x <= 1Top-K 采样参数
是否流式返回响应
停止序列
可用工具列表
Show child attributes
Show child attributes
工具选择策略
Show child attributes
Show child attributes
请求元数据
Show child attributes
Show child attributes
响应
Claude Messages API 响应