Course 4 · Unit 1
APIs and services for AI
Part of Applications with LLMs
- 5 lessons
- ≈ 13 h of study
- Level: intermediate
Turning a model into a reliable service. HTTP and REST, APIs with FastAPI and Pydantic, LLM streaming, usage limits and keys, and deployment with Docker, environment configuration and health checks.
Topics covered
- HTTP
- REST
- Status codes
- JSON
- Idempotency
- Retries
- Exponential backoff
- Authentication
- FastAPI
- Pydantic
- Dependency injection
- Async
- TestClient
- OpenAPI
- Streaming
- Server-Sent Events
- Timeouts
- Rate limiting
- Token bucket
- API keys
- Docker
- Environment configuration
- Secrets
- Health checks
- Graceful shutdown
Lessons in this unit
- HTTP and REST — the language of services 40 min
What travels in an HTTP request and response, what methods and status codes mean, why idempotency matters and how an API is authenticated. - Building an API with FastAPI 65 min
Routes, validation with Pydantic, dependency injection, errors, async and tests with TestClient; and what FastAPI does under the hood, implemented by hand. - Serving a model or an LLM behind an API 70 min
Streaming with Server-Sent Events, timeouts and cancellation, usage limits with a token bucket, API keys stored as hashes and a contract documented with OpenAPI. - Deploying — Docker, configuration and health checks 70 min
Packaging an AI service into a reproducible Docker image, configuring it with environment variables validated at startup, and exposing health checks so the platform knows when to restart it and when to send it traffic. - Your first real call to an LLM 70 min
A model on your own computer with Ollama (free and private) or a paid API with its key in an environment variable; messages, tokens and cost, structured output, timeouts, retries and a swappable client to test without a network.
Prerequisites
Before this unit it helps to have done:
- Engineering with Python (Course 1 · Unit 2)
- Data for AI (Course 1 · Unit 4)
The full explanations, auto-graded exercises, exams and projects are inside the academy.
Every lesson you complete gives you 10 yang, the academy's currency, and every unit exam you pass, 50.
Shall we start?
Create your account and activate your subscription: you get the whole syllabus from day one.