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": "深圳现在天气怎么样?适合去海边吗?"
}
],
"tools": [
{
"name": "get_weather",
"description": "获取指定城市的当前天气信息",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "温度单位"
}
},
"required": [
"city"
]
}
}
]
}
'{
"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 格式模型的通用 Anthropic Messages API(含工具调用)
- 工具调用:支持 Function Calling,定义模型可调用的工具
- 多模态输入:支持文本 + 图像混合输入
- 扩展思考:支持思维链推理模式
- 支持流式和非流式响应
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": "深圳现在天气怎么样?适合去海边吗?"
}
],
"tools": [
{
"name": "get_weather",
"description": "获取指定城市的当前天气信息",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "温度单位"
}
},
"required": [
"city"
]
}
}
]
}
'{
"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 响应