Skip to main content
Tools turn a chat from “the model writes you a sentence” into “the model can do things.” You hand it a list of functions it’s allowed to call. It decides if and when to call them, you run the actual code, and you feed the result back into the conversation. Opper’s tool calling uses the standard OpenAI-compatible 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:
  1. You send a chat completion request with a tools list.
  2. The model responds with a tool_use (it wants to call one).
  3. You run the tool in your code.
  4. You send the result back to the model as a tool_result message.
  5. The model uses the result to write its final response.

A working example

A weather assistant.

Control when tools fire

The tool_choice parameter tells the model how aggressively to use tools.

Parallel calls

The model can ask for several tool calls in one turn. The tool_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 with stream: 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.