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
- Define tools as JSON schemas — the model uses the
descriptionto decide which tool to call. - First request → model sees the tools and the user query. It may emit
tool_callsinstead of text. - Execute tools → your code runs the matching function with the parsed arguments.
- Return results → append a
toolmessage with the output for each call. - 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 overmessage.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