Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Create an agent with multiple tools. The agent decides which tools to call based on the user’s message.
Create the agent
from definable.agent import Agent
from definable.tool.decorator import tool
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
return f"Top result for '{query}': Example search result."
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"The weather in {city} is sunny, 72F."
@tool
def calculate(expression: str) -> str:
"""Evaluate a math expression."""
return str(eval(expression))
agent = Agent(
model="gpt-4o",
tools=[search_web, get_weather, calculate],
instructions="You are a helpful assistant. Use tools when needed.",
)
output = agent.run("What's 42 * 17, and what's the weather in Paris?")
print(output.content)
Export your API key
export OPENAI_API_KEY=sk-***
Run
The agent will call calculate and get_weather in parallel, then combine the results into a single response.