1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
24 small wins to finish your pathNext lesson →
Installation and setup
Pydantic AI installs as a slim core plus one extra per model provider. Groq and Gemini each have an extra and a free key.
pydantic-ai-slim[openai], pydantic-evals and pytest
pydantic-ai-slim is the framework without provider libraries; [openai] adds OpenAI's. The full pydantic-ai package installs every provider at once. pydantic-evals is for lesson 22 and pytest for lesson 21.
pip install "pydantic-ai-slim[openai]==2.43.0" "pydantic-evals==2.43.0" pytestfrom importlib.metadata import version
print(version("pydantic-ai-slim"))Provider extras and model stringsOptional
The course runs on the built-in test model and a function model you write in lesson 4, so it needs no key. Lesson 6 moves to real providers: add the provider's extra, set its key and name the model.
from pydantic_ai import Agent
agent = Agent("groq:openai/gpt-oss-120b", instructions="You answer support tickets.")| Provider | Key | Variable | Extra and model string |
|---|---|---|---|
| Groq | Free, console.groq.com/keys | GROQ_API_KEY | [groq], "groq:openai/gpt-oss-120b" |
| Gemini | Free, aistudio.google.com/apikey | GOOGLE_API_KEY | [google], "google:gemini-2.5-flash" |
| OpenRouter | Free models end in :free, openrouter.ai/keys | OPENROUTER_API_KEY | [openrouter], "openrouter:google/gemma-4-31b-it:free" |
| OpenAI | Paid, platform.openai.com/api-keys | OPENAI_API_KEY | [openai], "openai:gpt-5.2" |
pip install "pydantic-ai-slim[groq]==2.43.0"export GROQ_API_KEY=gsk_...Try it yourself
- Create the agent above with no key set and read the error message.
Little by little, you're building something great.