tools array, so anything you’ve written against OpenAI, Anthropic, or other compat SDKs works unchanged. It’s available across all 300+ models.
The round trip
A tool call always follows the same shape:- You send a chat completion request with a
toolslist. - The model responds with a
tool_use(it wants to call one). - You run the tool in your code.
- You send the result back to the model as a
tool_resultmessage. - The model uses the result to write its final response.
A working example
A weather assistant.Control when tools fire
Thetool_choice parameter tells the model how aggressively to use tools.
Parallel calls
The model can ask for several tool calls in one turn. Thetool_calls array on the response can have more than one entry. Run them all (in parallel if they’re independent), then send back one tool message per call, each with its tool_call_id.
Streaming tool arguments
When you stream a tool call withstream: true, the arguments arrive as JSON fragments in delta.tool_calls[].function.arguments. Concatenate them as they come in, then parse once the call is complete. Useful for showing “I’m calling search…” UI as the call assembles. See Streaming.
Tools vs structured output
Tools and structured output look similar but do different things.
If you have a clear input → output and don’t need the model to drive control flow, reach for structured output, not tools.
What’s next
Server-side tools
Provider-run tools — Anthropic web_search, OpenAI code_interpreter, Google grounding — no round-trip needed.
Conversations
Multi-turn chat with message history.
Streaming
Stream tokens and tool arguments as they arrive.
Structured output
Get JSON back without the tool round-trip.