curl --location --request POST 'https://newapi.mexxxxai.win/v1/messages' \
--header 'x-api-key: {{ANTHROPIC_API_KEY}}' \
--header 'anthropic-version: 2023-06-01' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "获取指定城市的当前天气信息",
"input_schema": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "城市名称,例如:北京、上海"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "温度单位"}
},
"required": ["city"]
}
}
],
"messages": [{"role": "user", "content": "北京现在的天气怎么样?"}]
}'{
"id": "msg_07TOOLUSEabcde",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "我来帮你查询北京的当前天气。"
},
{
"type": "tool_use",
"id": "toolu_01AbCdEfGhIjKlMn",
"name": "get_weather",
"input": {
"city": "北京",
"unit": "celsius"
}
}
],
"model": "claude-sonnet-4-6",
"stop_reason": "tool_use",
"stop_sequence": null,
"usage": { "input_tokens": 68, "output_tokens": 62 }
}