Tool Calling

Let models request function execution and return structured tool results.

POST/v1/responses
NameTypeRequiredDescription
tools
arrayRequiredTool definitions available to the model
type
stringRequiredfunction
name
stringRequiredStable tool identifier
parameters
json-schemaRequiredInput schema for tool arguments
tool_choice
string | objectauto | 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.