API errors & retries
Production LLM calls hit **429 rate limits**, timeouts, and bad JSON — handle them on purpose.
Reviewed July 2026 · interactive lab
1Try it yourself
Playground
API errors & retries
429 rate limits are normal — back off, retry, and cap attempts in production.
Attempt 1
429 Rate limit — retry after 2s2Read & reflect
Recap
#What you just did
You walked through 429 → wait → retry → success — the shape every SDK wrapper needs.
Teach
#How it works
| Code | Meaning | Typical action | |------|---------|----------------| | 429 | Rate limit | Exponential backoff + cap retries | | 401 | Bad key | Alert ops — don't retry blindly | | 500 | Server error | Retry with jitter, then fallback | | 400 | Bad request | Fix payload — don't retry same body |
Read
#Try it
Add a retry loop around your chat call — max 3 attempts, double wait each 429. Log each failure with request id.
3Spark check