AI API rate limits and reliability: keeping your app working when the model fails
Why AI APIs slow down and refuse requests
Every AI provider limits how much work each account can send. Limits are usually counted in requests per minute and in tokens, which are the pieces of text the model reads and writes. When you go over a limit, the provider refuses the call with a standard status code for too many requests. Limits differ by account tier and by model, and they change, so read your provider's current rate limit page rather than relying on a figure from a blog.
Load can also slow a response down or make it fail. A long answer takes longer than a short one, and a busy model can queue requests. A connection can drop halfway through a stream. Your app has to expect these events as normal, not as rare bugs.
Retries with backoff, and when not to retry
A retry is useful only when the failure is temporary. For a request that was refused for too many requests, or for a server error, wait and try again. Wait longer after each failed attempt, which is called exponential backoff, and add a small random delay so many users do not retry at the same moment. Stop after a few attempts and tell the user.
Do not retry a request that failed for a permanent reason. A malformed request, an oversized prompt or a refused key will fail every time. Retrying the same failing request does not fix it, it only uses time and quota. Read the status and error type first, then decide whether to wait, change the request or stop.
- Retry temporary failures, such as too many requests, server errors and timeouts.
- Do not retry invalid input, a missing permission or a key that the provider has rejected.
- If the prompt was too long, shorten it before the next attempt rather than sending the same text again.
- Cap the total time a user waits, not only the number of attempts.
Timeouts, queues and rate control in your own code
Set a timeout on every call to a model. Without one, a stuck request holds a connection open and blocks other work. Choose a timeout that fits the task: a short reply can time out quickly, while a long report needs more time and should run in the background.
Heavy or non-urgent work belongs in a queue. Summaries, bulk classification and overnight reports can wait in line and be processed at a steady rate that stays under your limit. Interactive requests, such as a chat answer, should go to the front of the queue and never wait behind a batch job.
Idempotency: avoid doing the same job twice
When a call times out, you often do not know whether the provider finished the work. If you retry blindly, you may create two records, send two emails or charge a customer twice. Give each job a unique identifier, store it with the result, and check for it before you run the job again.
This matters most for AI agents that write to other systems. The model's step may succeed while the write to the CRM fails. Design the write so that running it twice has the same effect as running it once.
Fallback providers and graceful messages for users
A fallback provider can keep a feature running when your main provider is down or over its limit. It works only if you have tested the fallback on your own prompts, because a different model can answer in a different style or miss a rule. Keep the fallback in your configuration, not hard-coded, so you can switch in minutes.
When no answer is possible, say so in plain words. Tell the user the feature is busy, keep what they typed, and offer a retry or a saved draft. Do not show a raw error code or a blank screen. A clear message builds more trust than a silent failure.
Monitor failures before users complain
Count the failures, the retries and the timeouts for each feature, and alert your team when they rise. A rise in retries often shows a provider problem before anyone writes in. Check each provider's status page as well, and keep a record of incidents so you can explain them later.
Test the failure paths on purpose. Use a test key with a low limit, or simulate a timeout, and confirm that the app waits, retries and shows the right message. A failure path that has never run is not a control.
How Hundred Seas helps
Hundred Seas is a product studio in Taipei that builds AI agents, AI CRM systems and mobile apps. We build on Claude and OpenAI models, and we design the retry, queue and fallback layers around them so a slow or failing provider does not take the product down. We choose the model for each task on cost, speed, quality and where the client's data has to stay.
We begin with a scope step, about one week at a fixed price, that ends in a written plan and a firm quote. Software is then delivered in weekly releases, and a monthly run plan covers monitoring, provider changes and the failure paths we test after each release.
Questions
- Why does my AI feature suddenly stop working?
- The most common cause is your account going over a rate limit, or the provider having a server problem. Check the error type in your logs, then your provider's status page and your usage dashboard. If you find a limit, ask for a higher tier or queue the requests.
- Is retrying a failed AI request a good fix?
- Only for temporary failures. Retrying a request that was refused for a permanent reason repeats the same failure. Read the error first, shorten the input if it was too long, and use backoff with a limit on attempts. Stop and show a clear message once the limit is reached.
- What is a fallback provider?
- A fallback provider is a second model service your app can switch to when the main one fails or is over its limit. It keeps the feature available, but only after you have tested it on your own prompts. Answers can differ in style and accuracy, so review them before relying on the switch.
- How do I avoid charging or emailing a customer twice?
- Give each job a unique identifier, store it with the outcome, and check it before running the job again. Make writes to other systems safe to repeat, so a retry after a timeout produces the same result as the first attempt.
- What should users see when the AI is unavailable?
- They should see a short, plain message that the feature is busy, along with what they typed and an option to try again later. Avoid raw error codes or a spinner that never stops. Where possible, offer a simpler route that still helps them finish the task.