OpenAI Agents SDK: Building Your First AI Agent
Literally copy paste this page into ChatGPT and it'll teach you what to do.
What is OpenAI Agents SDK?
The OpenAI Agents SDK is a lightweight and flexible framework designed to build AI agents that can perform tasks, utilize tools, and interact seamlessly within workflows. Whether you're building customer support assistants, content generators, or even complex multi-agent systems, the OpenAI Agents SDK streamlines the creation and orchestration of intelligent agents.
Why Use the Agents SDK?
The SDK provides:
Easy setup for simple agents
Powerful tools integration
Structured outputs for reliable results
Built-in orchestration for multi-agent workflows
Here's how you can quickly create your first agent:
Quickstart: Haiku Assistant
Follow these steps to create an agent that responds in haikus:
Set up your Python environment:
python -m venv env
source env/bin/activatepip install openai-agents
pip install python-dotenv
pip install termcolorYou will need an OpenAI API key which you can get here.
Writing Your First Agent
Let's create a simple agent that only responds in haikus:
from agents import Agent, Runner
import asyncio
from dotenv import load_dotenv
from termcolor import colored
import os
from agents import set_tracing_disabled
# Load environment variables from .env file
load_dotenv()
set_tracing_disabled(True)
agent = Agent(
name="Haiku Assistant",
instructions="You only respond in haikus."
)
async def main():
print(colored("=== Running Haiku Assistant ===", "cyan"))
print(colored("You: Tell me about recursion in programming.", "magenta"))
result = await Runner.run(agent, "Tell me about recursion in programming.")
print(colored(result.final_output, "cyan"))
if __name__ == "__main__":
asyncio.run(main()) Running Your Agent
Save the script as hello_haiku.py and run it:
python hello_haiku.pyCongratulations! You've built your first agent with OpenAI's Agents SDK.
What's Next?
From here, you can expand your agents with:
Tools: Allow agents to access databases, APIs, and other external resources.
Guardrails: Ensure your agents produce valid, safe, and relevant responses.
Multi-agent orchestration: Connect agents to handle complex workflows or tasks that require specialized knowledge or skills.
Ready to explore more? Check out the following articles in this series:
OpenAI Agents SDK: Give Your Agent Tools
OpenAI Agents SDK: Guardrails
OpenAI Agents SDK: Multi-agent Orchestration
We’re excited to see what you build!






