0

๐ŸŽฏ Tutorial 1: Your First OpenAI Agent

awesome-llm-apps1_starter_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.

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 agent
  • instructions: How your agent should behave
  • model: The AI model to use (defaults to "gpt-4o")

3. Basic Workflow

  1. Input: User sends a message
  2. Processing: Agent uses AI model to understand and respond
  3. 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

  1. Set up your environment:

    # Make sure you have your OpenAI API key
    # Get your API key from: https://platform.openai.com/api-keys
    
  2. Install OpenAI Agents SDK:

    pip install openai-agents
    
  3. Install dependencies:

    # Install required packages
    pip install -r requirements.txt
    
  4. 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
    
  5. Test the agent:

    # Run the agent directly
    python agent.py
    
    # Or run the Streamlit web interface
    streamlit run app.py
    
  6. 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:

๐Ÿ’ก 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 .env file contains a valid OPENAI_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)