OpenAI Agents SDK Quickstart

OpenAIQuickstart

Get started with the official OpenAI Agents SDK in under 10 minutes.

OpenAI Agents SDK Quickstart

Introduction

The OpenAI Agents SDK is the official SDK for building AI agents with OpenAI's latest models and tools.

Installation

pip install openai-agents

Your First Agent

from openai_agents import Agent, Runner

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
)

runner = Runner(agent)
result = runner.run("Explain quantum computing in simple terms.")
print(result.final_output)

Using Tools

from openai_agents import tool

@tool
def get_weather(location: str) -> str:
    """Get the current weather for a location."""
    return f"The weather in {location} is 72°F and sunny."

agent = Agent(tools=[get_weather])

Multi-Agent Systems

from openai_agents import Agent, Group

researcher = Agent(name="Researcher", instructions="You are a researcher.")
writer = Agent(name="Writer", instructions="You are a writer.")

group = Group(agents=[researcher, writer])
result = group.run("Write a research summary.")

Conclusion

The OpenAI Agents SDK provides a clean, official way to build agents with OpenAI's latest capabilities.

Resources