Tool calling — also called function calling — lets the model invoke defined external tools instead of just producing text. It is the API that makes agents possible. Every major provider supports it with similar shape and different quirks.
- 01Structure a tool definition.
- 02Explain the tool-call loop.
- 03State cross-provider compatibility differences.
The definition
A tool is a name, description, and JSON Schema for parameters. The model decides when to call it and with what arguments. Your code executes the tool, returns the result, and the model continues.
The loop
1. User message. 2. Model output: text or tool call. 3. If tool call, execute and append result to context. 4. Model output on next turn. 5. Repeat until the model outputs a final answer without a tool call.
Compatibility
OpenAI, Anthropic, Google, xAI, and most open models support tool calling. Naming differs (tools vs. functions). Parallel tool calls: OpenAI yes, Claude yes, Gemini yes, many open models no. Design for the least common denominator.
- Tool calling is text-in, structured-out with a callable interface.
- The loop is: call tool → append result → continue.