Vibe Coder · Unit 10: APIs · Lesson 13 of 13
Errors and retries
Engineers: API calls fail. Handle rate limits, timeouts and overloads so your users see a working product.
Read the short notes and pictures.Do everything inside a blue frame.
Designing for failure
Model APIs are busy services. Requests are sometimes rejected or slow. Whether the user notices depends on how you handle it: retry what is temporary, report what is permanent, and keep their input safe.

Which errors to retry
Retry
Rate limited, overloaded, timed out. Use exponential backoff with jitter.
Do not retry
Invalid request, authentication failure. These need a code or config fix.
Cap it
A maximum number of attempts and a total time limit.

What the user sees
Keep their input
Never clear the form on failure.
Say what happened
In plain words, with a retry button.
Degrade gracefully
The rest of the app keeps working.
Alert yourself
Log and monitor error rates.
Harden your AI feature
Add timeouts, backoff retries for temporary errors, a clear error state that keeps the user’s input, and logging. Test by simulating a rate limit and a timeout.
Done when
Your AI feature is implemented, structured, tooled, cached and resilient.
Keep these
- Expect API failures.
- Retry temporary errors with backoff.
- Keep user input and fail clearly.