Tool calling
Tool calling is normalized to the OpenAI tools / tool_calls shape across every provider that supports it — Anthropic, Google, Kimi, DeepSeek, Mistral, Meta. You write one schema; the gateway translates into each provider's native format and translates the response back.
Declare tools
Tools are JSON-schema-validated function signatures. The model sees the function name, description, and argument schema; it decides when to call one.
{ "model": "moonshot/kimi-k2.6",
"messages": [
{ "role": "user", "content": "what's the weather in SF?" }
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Fetch current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" },
"units": { "type": "string", "enum": ["c", "f"] }
},
"required": ["city"]
}
}
}],
"tool_choice": "auto" }The model calls a tool
When the model decides to use a tool, the response carries a tool_calls array instead of (or alongside) regular content. Parse the arguments, execute your function, and return the result in a role: "tool" message with the matching tool_call_id.
// assistant turn { "role": "assistant", "content": null, "tool_calls": [{ "id": "call_abc", "type": "function", "function": { "name": "get_weather", "arguments": "{\"city\":\"SF\",\"units\":\"f\"}" } }] } // your turn — return the result { "role": "tool", "tool_call_id": "call_abc", "content": "{\"tempF\":68,\"cond\":\"sunny\"}" }
Parallel tool calls
Kimi, GPT-5.4, Claude Opus 4.7, and Gemini 3.1 Pro can emit multiple tool_calls in one turn when the tasks are independent. Execute them in parallel and return all results before the next assistant turn. The model stitches the results together.
Streaming tool calls
When streaming, tool arguments arrive chunk-by-chunk as delta.tool_calls[].function.arguments. Only parse the full JSON after finish_reason === "tool_calls". See Streaming → Tool deltas.
Forcing or disabling
tool_choice: "auto"— model decides (default).tool_choice: "none"— ignore all tools for this turn.tool_choice: { "type": "function", "function": { "name": "…" } }— force a specific tool.
Which models are best at tools?
For agent loops, we recommend moonshot/kimi-k2.6 (cheap, high-throughput, reliable multi-tool), anthropic/claude-sonnet-4.5 (best tool accuracy at moderate cost), or openai/gpt-5.4 (highest quality for complex tool chains).