Function calling across AI providers
One tool-calling shape across OpenAI, Anthropic and Google, the loop, and the differences that matter.
The loop
You describe your functions in tools. The model either answers in text or returns tool_calls with a function name and JSON arguments. Your code runs the function, appends the result as a role: "tool" message carrying the tool_call_id, and calls the model again. Repeat until it answers in text.
One shape for every provider
Send tools in the OpenAI function shape on /chat/completions. For Anthropic models the gateway turns the tools into Anthropic's format and turns the tool_use blocks that come back into tool_calls with finish_reason: "tool_calls". Your loop does not change when you switch the model string from GPT to Claude to Gemini.
tool_choice takes "auto" (the default), "none", "required", or an object naming one function. With streaming, calls arrive as deltas in the standard chunk shape.
The differences that still matter
Not every model takes tools. Check capabilities.tools in GET /models. Where a model has several providers, "provider": { "require_parameters": true } keeps the request on routes known to honour tools.
Send tool calls back unchanged. Gemini attaches a thought signature to a tool call and checks it on the next turn. If an older SDK drops it, the gateway fills in Google's documented placeholder so the call still succeeds, at the cost of that step's earlier reasoning.
JSON output is emulated on Anthropic. Anthropic's API has no response_format, so the gateway turns the schema into a tool the model must call. The result looks the same; with streaming it arrives in one chunk.
Further reading
The tool calling docs have runnable examples, the structured output docs cover JSON schemas, and the Anthropic-format endpoint takes tools in Anthropic's own shape if you prefer it.
Common questions
Do Claude and Gemini support OpenAI-style function calling?
Through Rapid Router, yes: you send tools in the OpenAI function shape to any model that supports tools, and the gateway converts them for Anthropic and Google and converts the calls back into tool_calls.
How do I know which models support tools?
GET /models marks each model with capabilities.tools. Filter on it before you send tools.
Can I force a specific function?
Yes. tool_choice takes "auto", "none", "required", or an object naming one function.
Does streaming work with tool calls?
Yes. With stream: true the calls arrive as tool_calls deltas in the standard chunk shape, Anthropic models included.