docs/examples.md
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.
agent_patterns: Examples in this category illustrate common agent design patterns, such as
examples/agent_patterns/agents_as_tools_streaming.py)examples/agent_patterns/agents_as_tools_structured.py)examples/agent_patterns/forcing_tool_use.py)examples/agent_patterns/human_in_the_loop.py)examples/agent_patterns/human_in_the_loop_stream.py)examples/agent_patterns/human_in_the_loop_custom_rejection.py)basic: These examples showcase foundational capabilities of the SDK, such as
examples/basic/lifecycle_example.py)examples/basic/tools.py)examples/basic/tool_guardrails.py)examples/basic/image_tool_output.py)examples/basic/stream_ws.py)examples/basic/retry.py)examples/basic/retry_litellm.py)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: Practical examples of agent handoffs with message filtering, including:
examples/handoffs/message_filter.py)examples/handoffs/message_filter_streaming.py)hosted_mcp: Examples demonstrating how to use hosted MCP (Model Context Protocol) with the OpenAI Responses API, including:
examples/hosted_mcp/simple.py)examples/hosted_mcp/connectors.py)examples/hosted_mcp/human_in_the_loop.py)examples/hosted_mcp/on_approval.py)mcp: Learn how to build agents with MCP (Model Context Protocol), including:
examples/mcp/sse_remote_example)examples/mcp/streamable_http_remote_example)examples/mcp/streamablehttp_custom_client_example)MCPUtil.get_all_function_tools (examples/mcp/get_all_mcp_tools_example)examples/mcp/manager_example)examples/mcp/tool_filter_example)memory: Examples of different memory implementations for agents, including:
ModelSettings(store=False) (examples/memory/compaction_session_stateless_example.py)examples/memory/file_session.py)examples/memory/file_hitl_example.py)examples/memory/memory_session_hitl_example.py)examples/memory/openai_session_hitl_example.py)examples/memory/hitl_session_scenario.py)model_providers: Explore how to use non-OpenAI models with the SDK, including custom providers and third-party adapters.
realtime: Examples showing how to build real-time experiences using the SDK, including:
reasoning_content: Examples demonstrating how to work with reasoning content, including:
examples/reasoning_content/runner_example.py)examples/reasoning_content/gpt_oss_stream.py)examples/reasoning_content/main.py)research_bot: Simple deep research clone that demonstrates complex multi-agent research workflows.
tools: Learn how to implement OAI hosted tools and experimental Codex tooling such as:
examples/tools/apply_patch.py)examples/tools/shell.py)examples/tools/shell_human_in_the_loop.py)examples/tools/container_shell_inline_skill.py)examples/tools/container_shell_skill_reference.py)examples/tools/local_shell_skill.py)examples/tools/tool_search.py)examples/tools/codex.py)examples/tools/codex_same_thread.py)voice: See examples of voice agents, using our TTS and STT models, including streamed voice examples.