OpenAI Agents SDK

Build agents using the official OpenAI Agents SDK with built-in tool calling and handoffs.

Language:PythonProvider:OpenAIKey required:OPENAI_API_KEY

Quick start

1

Create the project

npx agentvoy create my-project --framework openai --provider openai --model gpt-4o --yes
2

Install dependencies

cd my-project-agent
pip install -r requirements.txt
3

Add your API key

cp .env.example .env
# Edit .env and add: OPENAI_API_KEY=sk-proj-...

Need a key? See how to get an OpenAI API key.

4

Run

python run.py

App mode

npx agentvoy create my-project --framework openai --build-mode app --deploy-target docker --yes

Creates a full app with FastAPI server, Streamlit chat UI, DevTools dashboard, and Dockerfile.

What gets generated

# agent.py — core agent logic
from agents import Agent, Runner

agent = Agent(
    name="my-project",
    model=os.environ.get("DEFAULT_MODEL", "gpt-4o"),
    instructions="You are a helpful AI assistant...",
    tools=[search_web, read_file],
)

def run_agent(prompt: str, model: str | None = None) -> str:
    """Run agent with guardrails enforcement."""
    from agentvoy_guard import Guard
    guard = Guard.from_config()
    with guard.session() as session:
        session.check_input(prompt)
        result = Runner.run_sync(agent, prompt)
        final = result.final_output
        session.check_output(final)
    return final

Switching models at runtime

Change the model without editing code by setting DEFAULT_MODEL in your .env:

DEFAULT_MODEL=gpt-4.1

In app mode, the Streamlit chat UI also lets you switch models on the fly via a dropdown.

Compatible providers

The OpenAI Agents SDK only works with OpenAI as the provider. If you need to use Anthropic or Google models, choose a multi-provider framework like CrewAI or LangGraph.