Loading page
3 questions on what this guide covers, aimed at your weakest concept. Answers count toward your mastery.
Learn to build autonomous coding agents with the OpenAI Agents SDK
Master building autonomous AI agents that can scaffold projects, search the web, edit code, and connect to external services.
AI agents are autonomous systems that can perform complex tasks by combining large language models with tools that interact with the real world. Unlike simple chatbots, agents can:
The snippets on this page use gpt-5-mini, the model this platform uses for code. Check which models your OpenAI account can use before running them.
# Install the OpenAI Agents SDK
pip install openai-agents openai asyncio
# Set your API key
export OPENAI_API_KEY="sk-..."
# Create a simple agent
from agents import Agent, Runner, WebSearchTool
agent = Agent(
name="My Agent",
model="gpt-5-mini",
instructions="You are a helpful assistant.",
tools=[WebSearchTool()]
)
# Run the agent
result = await Runner.run(agent, "What's new in Python 3.12?")