Tools

Function calling in both formats.

Function calling works in both formats on models with tool_calling.

json
{
  "model": "<model-id>",
  "messages": [{"role": "user", "content": "What is the weather in Pune?"}],
  "tools": [{"type": "function", "function": {"name": "get_weather", "description": "Current weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}],
  "tool_choice": "auto"
}

The response carries tool_calls (OpenAI) or a tool_use block (Anthropic). Run the tool, then send the result back as a tool role message or a tool_result block and call again. Arguments are relayed exactly as the model produced them; Top Billing never repairs JSON.

Streaming tool calls arrive as argument fragments that concatenate to valid JSON.