Skip to content

This is a basic guide to create an AI Agent using python and OpenAI Agents SDK.

Notifications You must be signed in to change notification settings

diegocp01/openai_agents

Repository files navigation

Intro

This repository is a basic guide on how to build AI Agents using pyhton and OpenAI Agents SDK

Optional: Talk to an AI that knows this repository: https://huggingface.co/spaces/diegocp01/GPT-4.1

Requirements

Beginner friendly step by step

-Download Cursor, VS Code or Windsurf to your computer (Google it) -Open your IDE (Cursor, Windsurf, VSCode) and then click on Open Folder (create a folder for this project) -Go to the top left and chose Terminal -> New Terminal

  • In the Terminal: copy and paste this + enter:
git clone https://github.com/diegocp01/openai_agents.git

Make sure your folder name on the left is the same as the terminal. (if not, take a screenshoot and ask chatgpt. Is a quick cd command)

-Create a new file inside of the openai-sdk-agent folder, called '.env' -Inside of the .env file copy this:

# Copy and paste your openai api key below instead of the 'sk-12....'
OPENAI_API_KEY=sk-12232432

# The LLM to use find more llm names here
#https://platform.openai.com/docs/models
MODEL_CHOICE=gpt-4.1-nano

-In the Terminal: Install the required dependencies: Create a virtual enviroment like this ->

python -m venv .venv

If your IDE asks you to create a python ENV click YES

-Then in the terminal paste this (This activates the enviroment):

source .venv/bin/activate

-Now you will install the openai agents sdk and other frameworks needed -(The frameworks are listed in the requirements file)

pip install -r requirements.txt

Then paste this in the terminal (with your openai key from .env file)

export OPENAI_API_KEY=sk-122

Files

  • v1_basic_agent.py - Basic Agent
  • v2_structured_output.py - Agent with organized outputs
  • v3_tool_calls.py - Agent with access to tools
  • v4_handoffs.py - Orchestrator Agents with Specialized agents

Running the Agents

Basic Agent (v1)

Run the basic agent example:

python v1_basic_agent.py

Structured Output Agent (v2)

Run the Agent with organized outputs:

python v2_structured_output.py

Tool Calls Agent (v3)

Run the tool calls travel agent example:

python v3_tool_calls.py

Now we will give our agent some TOOLS! (This is when it gets fun!) Recipe Agent

Handoffs Agent (v4)

Run the Orchestrator Agents with Specialized agents

python v4_handoffs.py

Run the interactive user interface app

streamlit run app.py

Youtube Video: https://youtu.be/w0D1R69LOjk

About

This is a basic guide to create an AI Agent using python and OpenAI Agents SDK.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages