Skip to main content
In this guide, you will build an agent that:
  • Connects to an LLM (OpenAI GPT-4o)
  • Uses a custom tool to take actions
  • Returns structured results
All in about 15 lines of code.

1. Define the Agent

Save the following code as my_agent.py:
my_agent.py
You now have:
  • An agent that reasons about which tools to call
  • Automatic parallel tool execution
  • A typed RunOutput with content, messages, and metadata

2. Run Your Agent

1

Set up your environment

2

Install Definable

3

Export your OpenAI API key

4

Run your agent

You should see the agent call get_weather for both cities and return a combined response.

3. Add Memory

Make your agent remember past conversations:
my_agent.py

4. Add Knowledge

Ground your agent in documents:
my_agent.py

5. Stream Responses

Stream tokens as they are generated:

What You Just Built

In a few lines of code, you built:
  • An agent with tool calling and parallel execution
  • Persistent memory across conversations
  • Knowledge-grounded responses via RAG
  • Real-time streaming output
This same architecture scales to multi-agent teams, structured workflows, and production deployments.

Next Steps