Skip to main content

Tool calling agent

This example shows a complete agent that can use external tools. The model decides when to call a tool, your code executes it, and the result goes back into the conversation.

Define your tools

agent.py

Expected output

How it works

  1. Define tools as JSON schemas — the model uses the description to decide which tool to call.
  2. First request → model sees the tools and the user query. It may emit tool_calls instead of text.
  3. Execute tools → your code runs the matching function with the parsed arguments.
  4. Return results → append a tool message with the output for each call.
  5. Second request → model sees the tool results and generates the final answer.

Parallel tool calls

Radium models support parallel tool calls — the model can request multiple tools at once. The example above handles this by iterating over message.tool_calls and executing each one before sending results back.

Next steps

Structured extraction

Extract typed data from text

RAG chatbot

Give your agent access to documents