Demonstrates the three execution methods available in the OpenAI Agents SDK: sync, async, and streaming.
Sign in to save downloads to your library and vote.
Preview
Execution Methods
Demonstrates the three execution methods available in the OpenAI Agents SDK: sync, async, and streaming.
๐ฏ What This Demonstrates
- Runner.run(): Asynchronous execution for non-blocking operations
- Runner.run_sync(): Synchronous execution for simple blocking calls
- Runner.run_streamed(): Streaming execution for real-time responses
- Performance Comparison: When to use each method
๐ Quick Start
-
Install OpenAI Agents SDK:
pip install openai-agents -
Set up environment:
cp ../env.example .env # Edit .env and add your OpenAI API key -
Run the agent:
from agents import Runner from agent import root_agent # Test sync execution result = root_agent.sync_execution_example() print(result)
๐ก Key Concepts
- Sync Execution: Blocks until completion, simple to use
- Async Execution: Non-blocking, enables concurrency
- Streaming Execution: Real-time response processing
- Use Case Selection: Choose based on application needs
๐ Next Steps
- Conversation Management - Threading and sessions
- Run Configuration - Advanced settings
Ingestion metadata
- Source catalog
- awesome-llm-apps
- Repository
- Shubhamsaboo/awesome-llm-apps ยท main
- File path
- ai_agent_framework_crash_course/openai_sdk_crash_course/4_running_agents/4_1_execution_methods/README.md
- Last refreshed
- 10/24/2026, 3:00:14 AM (5h ago)
- Refresh schedule
- Daily ยท 03:00 UTC
- Dedupe status
- Unique ยท deduped by (source, url)