{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{
"role": "user",
"content": "今天北京的天气怎么样?"
}
],
"tools": [
{
"name": "get_weather",
"description": "获取指定位置的当前天气",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市名称,如:北京"
}
},
"required": ["location"]
}
}
]
}
curl --location --request POST 'https://api.wenwen-ai.com/v1/messages' \
--header 'anthropic-version: 2023-06-01' \
--header 'x-api-key: $NEWAPI_API_KEY' \
--header 'content-type: application/json' \
--data-raw '{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{
"role": "user",
"content": "今天北京的天气怎么样?"
}
],
"tools": [
{
"name": "get_weather",
"description": "获取指定位置的当前天气",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市名称,如:北京"
}
},
"required": ["location"]
}
}
]
}'
{
"content": [
{
"text": "我来帮您查询北京的天气情况。",
"type": "text"
},
{
"id": "toolu_012f3meaYuYj9yPPuyuRVw9U",
"input": {
"location": "北京"
},
"name": "get_weather",
"type": "tool_use"
}
],
"id": "msg_0195XjbG2FGZfN7Dqkd9kyyW",
"model": "claude-sonnet-4-20250514",
"role": "assistant",
"stop_reason": "tool_use",
"stop_sequence": null,
"type": "message",
"usage": {
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"input_tokens": 478,
"output_tokens": 71,
"service_tier": "standard"
}
}