OpenAI Agents SDKopenai-agents 0.22 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson

Installation and setup

Every lesson runs in the browser panel with nothing installed. On your own machine, the SDK can run agents on OpenAI or, through LiteLLM, on a free Groq or Gemini key.

The browser panel

Press Run in the panel beside a lesson. The first run takes a few seconds while Python starts in your browser and the SDK downloads; after that it is instant. Nothing leaves the page, and no key is needed because the course uses a stand-in model you write in lesson 4.

pip install openai-agents 0.22

This course was checked with version 0.22.2.

pip install "openai-agents==0.22.2"

Running agents on a free modelOptional

Agents use OpenAI models by default, which read OPENAI_API_KEY from a paid account. For a provider with an OpenAI-compatible API, the SDK docs pass an AsyncOpenAI client with that provider's URL to OpenAIChatCompletionsModel. Traces upload to OpenAI, so without an OpenAI key turn tracing off with set_tracing_disabled, which lesson 23 explains; lesson 24 swaps in a real model.

python
import os

from agents import Agent, AsyncOpenAI, OpenAIChatCompletionsModel, set_tracing_disabled

set_tracing_disabled(True)
client = AsyncOpenAI(api_key=os.environ["GROQ_API_KEY"], base_url="https://api.groq.com/openai/v1")
agent = Agent(
    name="Support",
    instructions="Answer questions about orders.",
    model=OpenAIChatCompletionsModel(model="openai/gpt-oss-120b", openai_client=client),
)
ProviderKeyVariablebase_url and model
GroqFree, console.groq.com/keysGROQ_API_KEYhttps://api.groq.com/openai/v1, openai/gpt-oss-120b
GeminiFree, aistudio.google.com/apikeyGEMINI_API_KEYhttps://generativelanguage.googleapis.com/v1beta/openai/, gemini-2.5-flash
OpenRouterFree models end in :free, openrouter.ai/keysOPENROUTER_API_KEYhttps://openrouter.ai/api/v1, google/gemma-4-31b-it:free
OpenAIPaid, platform.openai.com/api-keysOPENAI_API_KEYNo client of your own; the default model
export GROQ_API_KEY=gsk_...
Try it yourself
  • Run the panel in lesson 2 before installing anything locally.

Little by little, you're building something great.