The OpenAI Agents SDK is a versatile and lightweight framework designed for building multi-agent workflows with ease. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as over 100 other Large Language Models (LLMs). This makes it highly adaptable for various use cases.
Key Features:
- Agents: Configure LLMs with instructions, tools, guardrails, and handoffs.
- Handoffs: Transfer control between agents seamlessly using specialized tool calls.
- Guardrails: Implement configurable safety checks for input and output validation.
- Tracing: Built-in tracking of agent runs for debugging and optimization.
Getting Started:
- Set up your Python environment:
bash python -m venv env source env/bin/activate
- Install the Agents SDK:
bash pip install openai-agents
For voice support, install with the optional voice group:bash pip install 'openai-agents[voice]'
Example Usage:
python
from agents import Agent, Runner
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
print(result.final_output)
Advanced Features:
- Structured Outputs: Define
output_type
to ensure the agent produces specific types of responses. - Asynchronous Support: Use
asyncio
for non-blocking agent interactions. - Extensible Tracing: Supports custom spans and integrations with external tools like Logfire, AgentOps, and more.
The Agents SDK is designed for flexibility, allowing you to model a wide range of LLM workflows, from deterministic flows to iterative loops. It also includes comprehensive tracing capabilities, making it easy to debug and optimize your workflows. For more examples and detailed documentation, explore the examples
directory in the repository.