Tool Calling
Let models request function execution and return structured tool results.
POST/v1/responses
| Name | Type | Required | Description |
|---|---|---|---|
tools | array | Required | Tool definitions available to the model |
type | string | Required | function |
name | string | Required | Stable tool identifier |
parameters | json-schema | Required | Input schema for tool arguments |
tool_choice | string | object | auto | none | specific function |
Tool Definition and Loop
Request
{
"model": "anthropic/claude-sonnet-4.5",
"input": "What is weather in Tokyo?",
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Fetch weather by city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
]
}tool-call-output.json
{
"output": [
{
"type": "tool_call",
"name": "get_weather",
"call_id": "call_abc123",
"arguments": "{"city":"Tokyo"}"
}
]
}Validate Arguments
Validate and sanitize model-provided tool arguments before execution. Treat tool calls as untrusted input.