Topic 4 of 4 · 4 min read
Running budgeted live smoke tests against providers
Goal: Set up a small scheduled live test that catches provider or model changes without spending more than a fixed budget.
Mocks and recordings cannot notice that the provider changed, so run a few real calls on a schedule, keep them tiny, and cap what they can spend. They answer one question: does the live API still accept what we send and return something we can parse?
Check yourself · 1 of 3
What can a scheduled live smoke test catch that mocks and recordings cannot?
Why it matters
Everything else in your suite runs against fakes or old recordings, so it passes even after the provider retires a model, renames a parameter or changes an error. Providers publish deprecation schedules, and a retired model name returns an error on the day it is gone. A smoke test finds that on your schedule, not from a customer.
How to set it up
- Keep it small. One to five tests, one per capability you depend on: a plain completion, a streamed reply, a tool call, a structured-output request. Use the model names your production config uses, read from the same config.
- Make each call cheap. Short prompt, low
max_tokens, the smallest model that covers the feature. Aim for a few cents per run. - Assert on shape, not wording. Check that the status is 200, the reply parses, the stop reason is valid and the tool call has the expected arguments. Never assert on exact text.
- Use a separate key. Create a dedicated key or project for tests with a hard monthly spend limit set in the provider's console, so a bug in the test cannot run up a bill. Store it as a CI secret, never in the repo.
- Run on a schedule, not on every commit. A nightly or weekly job is enough, plus a manual trigger. Keep it out of pull request checks, where a provider outage would block unrelated work.
- Alert a human. A failure should notify a channel, with the status and the error body. Treat a failing smoke test as a ticket, and distinguish "provider is down" from "our model name is retired".
Before and after
# Before: live tests run on every push with the production key
on: push
env:
API_KEY: ${{ secrets.PROD_KEY }}
# After: nightly, separate capped key, small suite
on:
schedule: [{ cron: "0 5 * * *" }]
workflow_dispatch: {}
env:
API_KEY: ${{ secrets.SMOKE_TEST_KEY }}
What goes wrong
- Using the production key. A loop in a test drains the budget that serves customers.
- Flaky wording checks. The model words a reply differently and the job fails for no reason, so people mute it.
- Blocking merges on it. A provider outage stops the whole team.
- No owner. The alert goes to a channel nobody reads and a deprecation is found in production.
Examples
A nightly smoke job
Three tests run at 05:00: one plain completion, one streamed reply and one tool call. Each uses max_tokens: 50. The job costs about a few cents a night and uses a key limited to a small monthly amount. When the provider retires a model, the job fails with a "model not found" error and posts to the team channel before any user is affected.
Reading a failure
The report shows status 404 with a message that the model does not exist. That is a retired name, so the fix is a config change and a re-record of fixtures. A status of 529 or 503 means the provider is busy, so the job retries once and does not page anyone.
Key points
- Smoke tests are the only layer that notices provider or model changes, because mocks and recordings never call the live API.
- Keep the suite to a handful of cheap calls with short prompts and low token limits.
- Assert on status, parseable shape and stop reason, never on exact model wording.
- Use a dedicated key with a spend limit set in the provider console, stored as a CI secret.
- Run nightly or weekly and alert a person; do not block pull requests on it.
Common mistakes
- Running live tests with the production key, so a bug can spend the customer budget.
- Asserting on exact model text, which makes the job flaky until the team ignores it.
- Running live calls in every pull request, so provider outages block unrelated merges.
- Setting up the job without an owner or alert, so failures sit unread.
Check yourself · 2 of 3
Which key should a scheduled live test use?
Check yourself · 3 of 3
A smoke test asserts the reply equals "Paris is the capital of France." and it fails after a model update. What is the best fix?
Practice items, not counted towards your mastery.
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.
More for this topic
- Model deprecations (Claude docs) (opens in a new tab)DocsFree
Shows how models are retired on a published schedule, which is what live smoke tests catch.
- Deprecations (OpenAI API) (opens in a new tab)DocsFree
A dated list of retired models and endpoints, showing why a scheduled real call is needed.