Docs / Features

Tool calling

Let models request function calls — the gateway passes tool definitions and results through unchanged.

Defining tools

Send tools as an array of function definitions, and tool_choice to control when the model may call them. Tool calls arrive in the assistant message as tool_calls entries.

JSON
{
  "model": "anthropic/claude-sonnet-5",
  "messages": [{"role": "user", "content": "Weather in Tokyo?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get current weather for a city",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  }],
  "tool_choice": "auto"
}

Returning results

Append the assistant message containing tool_calls, then a role=tool message per call with the function output. The next completion consumes those results.