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
- OpenAI API Key (This has a cost attached to it, you will need a credit card, the good news is that is very cheap, model: GPT 4.1 mini. Input price: $0.40 / 1M tokens (like 'words') and $1.60 for 1M output) Get your key here -> https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://platform.openai.com/api-keys&ved=2ahUKEwi3m7vSg--NAxUzTTABHY5LJRcQFnoECCkQAQ&usg=AOvVaw1YhcGDWJXhiKSfmL59Pnfn
-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.gitMake 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 .venvIf 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.txtThen paste this in the terminal (with your openai key from .env file)
export OPENAI_API_KEY=sk-122v1_basic_agent.py- Basic Agentv2_structured_output.py- Agent with organized outputsv3_tool_calls.py- Agent with access to toolsv4_handoffs.py- Orchestrator Agents with Specialized agents
Run the basic agent example:
python v1_basic_agent.pyRun the Agent with organized outputs:
python v2_structured_output.pyRun the tool calls travel agent example:
python v3_tool_calls.pyNow we will give our agent some TOOLS! (This is when it gets fun!) Recipe Agent
Run the Orchestrator Agents with Specialized agents
python v4_handoffs.pystreamlit run app.pyYoutube Video: https://youtu.be/w0D1R69LOjk