Module 5: Using AI APIs (OpenAI, Gemini, Anthropic)
Use the OpenAI, Google Gemini, and Anthropic Claude APIs from Python. Learn auth, streaming, structured outputs, cost control, and rate-limit handling. With a 30-minute Python primer.
Module 5: Using AI APIs (OpenAI, Gemini, Anthropic)
What this module gives you
Move from "talking to ChatGPT in a browser" to "calling LLMs from your own code". By the end you will have written real Python scripts against three frontier APIs, with streaming, JSON, and cost control.
Skills you will pick up
- Python basics for AI (just enough, in 30 minutes)
- Installing SDKs and managing API keys safely
- Making chat completions across OpenAI, Gemini, and Anthropic
- Streaming responses to a user
- Structured outputs and tool calls
- Handling rate limits and retries
Why it matters in production
Every AI product on the market is built on API calls. Owning this layer means you can build, debug, and switch providers without depending on a framework's leaky abstractions. The examples use OpenAI because the SDK is the most widely documented, but every pattern works on the free-tier providers too: Google AI Studio (Gemini Flash, no card required), Groq (open Llama and Gemma models, no card required), Hugging Face Inference Providers, and Ollama running locally. The full free-stack matrix lives in tech stack and tools.
Lessons in this module
- 1
Lesson 5.1
Python for AI in 30 minutes
2 min - 2
Lesson 5.2
Setup: keys, env vars, .gitignore, virtual envs
2 min - 3
Lesson 5.3
Your first OpenAI call
2 min - 4
Lesson 5.4
The same call in Gemini and Claude
2 min - 5
Lesson 5.5
Streaming responses
2 min - 6
Lesson 5.6
Structured outputs across providers
2 min - 7
Lesson 5.7
Rate limits, retries, and resilient code
2 min - 8
Lesson 5.8
Cost control patterns
2 min
Ready to start?
Open Lesson 5.1: Python for AI in 30 minutes