Testing LLM API integrations
For engineers
Mocking providers, replaying recorded responses, forcing failure paths and running small live checks so model calls do not break silently
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
Why should a unit test of your summarising function not call a real model?
Check yourself · 2 of 5
What does a recorded fixture give you that a hand-written mock does not?
Check yourself · 3 of 5
Your retry code handles 429 responses. How do you test it without waiting for real backoff delays?
Check yourself · 4 of 5
What can a scheduled live smoke test catch that mocks and recordings cannot?
Check yourself · 5 of 5
A mock model always returns clean text. Which code path is most likely to go untested?
Topics
- Mocking the model provider in unit tests4 min read · Replacing the SDK or HTTP layer with a mock that returns fixed text, streams, tool calls or errors
- Recording and replaying real API responses4 min read · Cassette-style recording, scrubbing keys and personal data, and refreshing fixtures when a model changes
- Testing rate limits, timeouts and malformed output5 min read · Simulating 429 and overloaded errors, stalled and truncated streams and invalid JSON to prove the app recovers
- Running budgeted live smoke tests against providers4 min read · A few scheduled real calls that catch model deprecations and API changes, with separate keys and a spend cap
Start here
- AI SDK Core: testing (opens in a new tab)DocsFree
Mock language models and test helpers that return fixed text, streams and errors without network calls.
- Mock Service Worker documentation (opens in a new tab)ToolFree
Intercepting HTTP requests at the network layer, so the real SDK runs against a fake server.
- VCR.py documentation (opens in a new tab)ToolFree
Record modes, header filtering and replay for HTTP cassettes in Python tests.
Helps to know first
110 questions · last verified 2026-12