curl https://api.anthropic.com/v1/messages -H "content-type: application/json" -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "anthropic-beta: tools-2024-04-04" -d '{
"model": "claude-3-opus-20240229",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in London?"
}
]
}'
{"id":"msg_01DvvYuXbiFcdHauAHfS1jzo","type":"message","role":"assistant","model":"claude-3-opus-20240229","stop_sequence":null,"usage":{"input_tokens":487,"output_tokens":135},"content":[{"type":"text","text":"<thinking>\nThe user is asking about the current weather, so the relevant tool to use is get_weather. This function requires a \"location\" parameter.\nThe user has provided the city \"London\" but not the state or country. However, since London is a well-known city, we can reasonably infer they are referring to London, United Kingdom. \n</thinking>"},{"type":"tool_use","id":"toolu_01Nu82nfXTcUufvPqZ4VHJmv","name":"get_weather","input":{"location":"London, United Kingdom"}}],"stop_reason":"tool_use"}