Skip to content
API referenceDashboard

Tool calling

Let the model call your functions.

All three endpoints support function tools in their native format. Other tool types (built-in tools, code interpreter, file search) return 400 unsupported_tool.

The loop is the same everywhere: send tools, the model returns a call, you run it and send the result back.

{
"model": "flash",
"messages": [{ "role": "user", "content": "Weather in Lisbon?" }],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] }
}
}]
}

The reply has choices[0].message.tool_calls. Append that assistant message, then a { "role": "tool", "tool_call_id": "...", "content": "..." } message per call, and send again.

tool_choice accepts "auto", "none", "required" or { "type": "function", "function": { "name": "get_weather" } }. parallel_tool_calls is supported.