Skip to content

Examples

Check out a variety of sample implementations of the SDK in the examples section of the repo. The examples are organized into several categories that demonstrate different patterns and capabilities.

Categories

  • agent_patterns: Examples in this category illustrate common agent design patterns, such as

    • Deterministic workflows
    • Agents as tools
    • Parallel agent execution
    • Conditional tool usage
    • Input/output guardrails
    • LLM as a judge
    • Routing
    • Streaming guardrails
  • basic: These examples showcase foundational capabilities of the SDK, such as

    • Hello world examples (Default model, GPT-5, open-weight model)
    • Agent lifecycle management
    • Dynamic system prompts
    • Streaming outputs (text, items, function call args)
    • Prompt templates
    • File handling (local and remote, images and PDFs)
    • Usage tracking
    • Non-strict output types
    • Previous response ID usage
  • customer_service: Example customer service system for an airline.

  • financial_research_agent: A financial research agent that demonstrates structured research workflows with agents and tools for financial data analysis.

  • handoffs: See practical examples of agent handoffs with message filtering.

  • hosted_mcp: Examples demonstrating how to use hosted MCP (Model Context Protocol) connectors and approvals.

  • mcp: Learn how to build agents with MCP (Model Context Protocol), including:

    • Filesystem examples
    • Git examples
    • MCP prompt server examples
    • SSE (Server-Sent Events) examples
    • Streamable HTTP examples
  • memory: Examples of different memory implementations for agents, including:

    • SQLite session storage
    • Advanced SQLite session storage
    • Redis session storage
    • SQLAlchemy session storage
    • Encrypted session storage
    • OpenAI session storage
  • model_providers: Explore how to use non-OpenAI models with the SDK, including custom providers and LiteLLM integration.

  • realtime: Examples showing how to build real-time experiences using the SDK, including:

    • Web applications
    • Command-line interfaces
    • Twilio integration
  • reasoning_content: Examples demonstrating how to work with reasoning content and structured outputs.

  • research_bot: Simple deep research clone that demonstrates complex multi-agent research workflows.

  • tools: Learn how to implement OAI hosted tools such as:

    • Web search and web search with filters
    • File search
    • Code interpreter
    • Computer use
    • Image generation
  • voice: See examples of voice agents, using our TTS and STT models, including streamed voice examples.