Reference · API
Anthropic tool use
Let Claude request **tools** with structured inputs — your code executes and returns results.
Let Claude request **tools** with structured inputs — your code executes and returns results.
Tool definition
{
"name": "get_weather",
"description": "Get weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}Flow
1. Send `tools` array with messages
2. Model may respond with `tool_use` content blocks
3. Run your function with validated inputs
4. Send `tool_result` user message with output
5. Model produces final natural-language answer
Safety
- Allowlist tool names
- Validate JSON schema before execution
- Confirm destructive actions with users
Related
- Lesson: Function calling in code
- Lesson: What are tools?
- OpenAI parallel: Chat completions tools