Welcome to your first step in the OpenAI Agents SDK journey! This tutorial introduces you to the fundamental concept of creating a simple AI agent using OpenAI's Agents SDK.
Sign in to save downloads to your library and vote.
Preview
๐ฏ Tutorial 1: Your First OpenAI Agent
Welcome to your first step in the OpenAI Agents SDK journey! This tutorial introduces you to the fundamental concept of creating a simple AI agent using OpenAI's Agents SDK.
๐ฏ What You'll Learn
- Basic Agent Creation: How to create your first OpenAI agent
- OpenAI SDK Workflow: Understanding the agent lifecycle
- Simple Text Processing: Basic input/output handling
- Agent Configuration: Essential parameters and settings
๐ง Core Concept: What is an OpenAI Agent?
An OpenAI agent is a programmable AI assistant that can:
- Process user inputs (text, voice, etc.)
- Use AI models (like GPT-4o) to understand and respond
- Perform specific tasks based on your instructions
- Return structured or unstructured responses
Think of it as creating a smart function that uses AI to handle complex tasks.
๐ง Key Components
1. Agent Class
The main building block for creating AI agents in OpenAI SDK:
from agents import Agent
2. Essential Parameters
name: Unique identifier for your agentinstructions: How your agent should behavemodel: The AI model to use (defaults to "gpt-4o")
3. Basic Workflow
- Input: User sends a message
- Processing: Agent uses AI model to understand and respond
- Output: Agent returns a response
๐ Tutorial Overview
This tutorial includes two focused agent examples:
1. Personal Assistant Agent (personal_assistant_agent/)
- Basic agent creation and configuration
- Simple instructions and role definition
- Core Agent class usage
2. Execution Demo Agent (execution_demo_agent/)
- Demonstrates different execution methods
- Sync, async, and streaming patterns
- Runner class usage examples
๐ Project Structure
1_starter_agent/
โโโ README.md # This file - concept explanation
โโโ requirements.txt # Dependencies
โโโ personal_assistant_agent/ # Basic agent creation
โ โโโ __init__.py
โ โโโ agent.py # Simple agent definition (20 lines)
โโโ execution_demo_agent/ # Execution methods demonstration
โ โโโ __init__.py
โ โโโ agent.py # Sync, async, streaming examples
โโโ app.py # Streamlit web interface (optional)
โโโ env.example # Environment variables template
๐ฏ Learning Objectives
By the end of this tutorial, you'll understand:
- โ How to create a basic OpenAI agent
- โ Essential agent parameters and their purpose
- โ How to run agents synchronously and asynchronously
- โ Basic OpenAI SDK workflow and lifecycle
- โ How to use streaming responses
๐ Getting Started
-
Set up your environment:
# Make sure you have your OpenAI API key # Get your API key from: https://platform.openai.com/api-keys -
Install OpenAI Agents SDK:
pip install openai-agents -
Install dependencies:
# Install required packages pip install -r requirements.txt -
Set up environment variables:
# Copy the example environment file cp .env.example .env # Edit .env and add your OpenAI API key # OPENAI_API_KEY=sk-your_openai_key_here -
Test the agent:
# Run the agent directly python agent.py # Or run the Streamlit web interface streamlit run app.py -
Try different execution methods:
- Test synchronous execution: "What's the weather like today?"
- Test asynchronous execution: "Tell me a story about AI"
- Test streaming responses: "Explain machine learning in detail"
๐งช Sample Prompts to Try
- General Questions: "What's the capital of France?"
- Creative Tasks: "Write a short poem about technology"
- Problem Solving: "How can I improve my productivity?"
- Explanations: "Explain quantum computing in simple terms"
๐ Next Steps
After completing this tutorial, you'll be ready for:
- Tutorial 2: Structured Output Agent - Learn to create type-safe, structured responses
- Tutorial 3: Tool Using Agent - Add custom tools and functions to your agent
- Tutorial 4: Runner Execution Methods - Master different execution patterns
๐ก Pro Tips
- Start Simple: Begin with basic functionality and add complexity gradually
- Test Often: Try different prompts to understand agent behavior
- Read Instructions: Clear instructions lead to better agent behavior
- Experiment: Try different execution methods to see the differences
๐จ Troubleshooting
- API Key Issues: Make sure your
.envfile contains a validOPENAI_API_KEY - Import Errors: Ensure all dependencies are installed with
pip install -r requirements.txt - Rate Limits: If you hit rate limits, wait a moment before trying again
Ingestion metadata
- Source catalog
- awesome-llm-apps
- Repository
- Shubhamsaboo/awesome-llm-apps ยท main
- File path
- ai_agent_framework_crash_course/openai_sdk_crash_course/1_starter_agent/README.md
- Last refreshed
- 7/24/2026, 3:00:13 AM (51m ago)
- Refresh schedule
- Daily ยท 03:00 UTC
- Dedupe status
- Unique ยท deduped by (source, url)