What to Do When an AI API Stops Working

A triage order for failing AI API calls: read the status code and message, fix what’s yours, retry only temporary errors, and keep users informed.

Your app’s requests to an AI model used to get answers; now they return errors, hang, or bring back something unusable. Work out which kind of failure you have before changing anything, because the fix for one kind makes another worse.

Start with the status code, a three-digit number saying whether the request worked, and the error message, the provider’s explanation. If the problem is yours (a malformed request, a bad API key, the secret string that identifies your account, missing permission, an empty balance, a retired model name), fix it first; the same request will fail the same way. If it’s temporary (too many requests, a timeout, an overloaded server), retry, meaning send it again, with backoff, a delay that grows after each failed try, and stop after a set number of attempts. Meanwhile, check the provider’s status page and keep users informed. New to AI APIs? Start with how apps connect to AI models.

TL;DR

  • Read the status code and error message together; providers use one number for different problems [1, 2, 3].
  • Fix request, key, permission, billing and model-name errors before sending again; Google says not to retry 400, 402 or 403 errors [4].
  • Retry only temporary failures, with growing, slightly randomized delays and a cap, remembering that providers’ code libraries may already retry [5, 2, 4].
  • A retired model can fail outright, but on Google’s Gemini API some deprecated names, such as gemini-2.5-pro and gemini-2.5-flash from Dec 1, 2026, are instead routed to a different model billed at that model’s rates [6, 7].
  • Before retrying anything that saves, sends or charges, make sure a repeat can’t do it twice [8, 9].
  • Log request IDs, codes and times; keep keys out of logs, and remove or mask sensitive personal data [10, 11].

Start With What the Response Says

The web’s HTTP standard sorts status codes by first digit: 4xx means the request seems to be at fault, 5xx means the server failed on a request that looked valid, and an unfamiliar code should be treated like the first code of its class [8]. What happens during a single request walks through the request itself, sent to an endpoint (the web address of one API function) with headers (labeled lines of information such as your key); this guide covers acting on the codes.

Providers map their problems onto codes differently, as these examples from their pages on Nov 22, 2026 show [1, 2, 3, 12]:

  • OpenAI returns 429, the “too many requests” code, for requests sent too quickly but also for an exhausted prepaid balance, a spend limit you set and a usage limit OpenAI assigned; its error.code field tells them apart [1].
  • Anthropic returns 400, normally a malformed request, when usage reaches a spend limit the customer set, and 402 for billing problems [2].
  • Google’s Gemini API returns 402 when its prepay balance runs out [3], although the HTTP standard still lists 402 as reserved for future use [8].
  • Anthropic and Amazon Bedrock use 529 for overload [2, 12], a number IANA’s status-code registry leaves unassigned [13].

So read the code, the provider’s own error code and the message together. Errors come back as JSON, a plain-text format of named fields and values; Google’s error object, for example, carries a machine-readable code and a message [3]. Also note the request ID, a unique label for each request: OpenAI sends it in an x-request-id header and Anthropic in a request-id header; Anthropic asks for it when you contact support, and OpenAI recommends logging it for troubleshooting with its support team [10, 2].

Work Through the Likely Causes in Order

BuildAIQ drew this order from the documentation cited in each row; your provider’s error page has the final word.

What you seeWhat it usually meansFirst moveRetry?
400Malformed body, unknown or unsupported parameter; at Anthropic, also a spend limit you set [2, 3]Read the message, compare with the current API referenceNo, fix first [4]
401Missing, mistyped, revoked or expired key; on Amazon Bedrock, credential problems can arrive as 403 or 400 [1, 2, 3, 12]Check which key the app is usingNo
402, or a billing code on 429 or 400Credit used up or a spend limit reached [1, 2, 3]Add credit or raise the limitNo; OpenAI says retrying won’t restore access [1]
403Missing permission, unsupported region, restricted project or blocked key [1, 3, 4]Check permissions and account statusNo [4]
404Wrong endpoint, resource ID or model name [2, 3, 12]Copy the name from the current models and deprecation pagesNo
429 (rate or quota message)Too many requests or tokens (the pieces of text providers count for limits and billing) in a period, or a daily quota [1, 3]Slow down; wait for the stated timeYes, with backoff, unless the message names billing or a daily quota
Timeout, dropped connection or 504The answer took too long or the network failed; Anthropic and Google use 504 for timeouts [1, 2, 3]Check the network and request size; for Google’s 504, raise or remove your own deadline setting [3]Yes, carefully
500, 503, 529Server error or temporary overload [1, 2, 3, 12]Check the provider’s status pageYes, with backoff

Fix These Before You Send Again

A 400 means the provider couldn’t accept the request as written, such as a malformed body or an unknown parameter [3, 2]. A model switch is an easy cause to miss: Anthropic documents 400 errors when newer models receive settings they no longer support, and Google warns that some sampling settings its newest models ignore will return 400 in a future release [2, 4].

A 401 points to the key. OpenAI’s causes include a revoked key, a key from another organization or project, a typo or extra space, and a key lacking permission for that endpoint [1]. If a key may have leaked, follow protecting and replacing an API key.

A 403 means the provider refuses the request, usually for permission, region or account reasons. OpenAI uses it for an unsupported country, region or territory [1], and on Amazon Bedrock it can also mean an access key the service doesn’t recognize [12]. Google uses it for missing permissions, restricted projects and keys it has blocked as leaked [3, 4].

Billing errors differ by provider but share a rule: retrying won’t fix them. OpenAI says retrying billing, spend or quota errors won’t restore access until credits or limits change, though a monthly spend limit also lifts when it resets, and Google’s 402 entry says not to retry until credits are added [1, 3]. Avoiding unexpected charges explains which limits stop traffic.

A Model Name That Stopped Working

Providers retire models differently. OpenAI says a shut-down model no longer accepts requests through its standard API, and affected customers are notified by email and in its documentation; its table, for example, listed gpt-5 and gpt-5-mini for shutdown on Dec 11, 2026 [14]. Anthropic says requests to retired models fail, promises at least 60 days’ notice for publicly released models, and offers a usage export by key and model; those dates apply to Anthropic-operated platforms, while Amazon Bedrock and Google-managed deployments set their own [6].

Google sometimes reroutes instead. Its Gemini deprecations page said on Nov 22, 2026 that from Dec 1, 2026, requests to gemini-2.5-pro will go to gemini-3.8-flash and requests to gemini-2.5-flash to gemini-3.5-flash-lite, billed at the new models’ rates, and that gemini-3.5-flash already routes to gemini-3.6-flash [7]. Such requests keep “working” while model, behavior and cost change. Retirement planning belongs to choosing a model; a rerouted model’s cost, to how API pricing works.

Too Many Requests

A 429 is the standard code for too many requests in a given time, and it may carry a Retry-After header saying how long to wait [15]. Anthropic says a 429 from its usage tier’s monthly spend cap has no retry-after header and keeps failing until access resumes [2]. The units and tiers behind these limits are in the previous guide, what rate limits are and how they're counted.

Timeouts and Dropped Connections

A timeout is a time limit after which a program stops waiting. OpenAI’s Python library distinguishes connection errors (network, proxy, certificate or firewall problems) from timeouts, where the request took too long and the server closed the connection [1]. Anthropic returns 504 when processing times out and recommends streaming, which sends the answer in pieces, for long requests [2]. Streaming has its own catch: Anthropic says an error can arrive after a response has started with a 200 success code, and Google sends streaming errors as events inside the stream [2, 3].

Server Errors, Overload and Outages

The HTTP standard describes 503 as a temporary overload or maintenance likely to clear after a delay [8], and Anthropic says its 529 overload error can occur when traffic is high across all users [2].

Check the status page before touching your code. OpenAI’s lists its APIs separately from ChatGPT, and Anthropic’s lists the Claude API as its own component with email, text and other alerts [16, 17]. Bedrock users are pointed to the AWS Service Health Dashboard [12]; elsewhere, use the status page your provider’s docs link.

When the Call Works but the Result Doesn’t

Some failures arrive with a success code. If you ask for structured output, data such as JSON matching a schema (a description of required fields and types), it can still be unusable. OpenAI says its schema-enforced mode constrains only completed answers that aren’t refusals, so apps must still handle refusals, answers cut off by an output limit, and API errors [18]. Google says the output will be syntactically correct JSON, but some schema constraints, such as minimum and maximum string lengths, aren’t enforced, and apps should still check values and handle answers that fit the schema yet are wrong [19]. Structured output covers validation. Google also returns “generation blocked” codes when safety or policy filters stop an output, and advises changing the input before retrying [3].

A fluent but wrong answer isn’t an API failure, and no status code flags it. See checking whether an AI answer is correct, and BuildAIQ’s Building AI Applications guide on handling incorrect or unreliable AI outputs in an app.

Worked Example (Hypothetical): The Quiz Generator Goes Quiet

Imagine a study app that turns pasted notes into a five-question quiz through Google’s Gemini API, chosen only as an example. The scenario is invented and nothing was run; the codes are from Google’s API errors page as of Nov 22, 2026 [3].

Every request fails with a 404. The body looks like this illustrative example in Google’s documented shape, with invented message text [3]:

{"error": {"code": "model_not_found", "message": "Model MODEL_NAME was not found."}}

The deprecation page shows the model retired, so the developer tests a current one before switching.

Some requests then fail with a 400 parameter_unknown, caused by a setting left over from the old setup; Google advises removing the unrecognized parameter [3].

429s appear when classes end, coded rate_limit_exceeded, a per-minute or per-second limit, so the app waits and retries with backoff [3]. An empty prepay balance would instead bring a 402 payment_required, which no retry fixes until someone adds credit [3].

One evening everything returns 503 service_unavailable, which Google describes as temporarily overloaded or down [3]. After capped retries, the app says: “Quiz generation is paused. Your notes are saved; try again later.”

Retry Safely, or Not at All

Google’s Gemini guide says to retry only transient errors such as 429, 408 or 5xx, never client errors such as 400, 402 or 403 [4]. When you do retry, the vendor guidance cited here points to four habits:

  • Honor Retry-After. OpenAI says to wait at least as long as the header specifies [5].
  • Back off exponentially, with jitter. Wait briefly, then longer after each failure, adding a small random delay so many clients don’t retry at once [9, 4].
  • Cap it. Limit the delay, the attempts and the total time; OpenAI notes failed requests still count toward per-minute limits [5, 9].
  • Retry in one place. In Amazon’s example, five layers each retrying three times multiply load on the bottom service 243x [9].

Count retries carefully, because SDKs, the code libraries providers publish, already retry. As of Nov 22, 2026, OpenAI’s official SDKs retry eligible 429 and 503 responses, Anthropic’s SDK retries transient failures twice by default, and Google’s Python SDK retries up to four times [5, 2, 4]. OpenAI advises disabling SDK retries or counting them if you add your own [5].

No-code tools need care too. n8n’s rate-limit page says Retry On Fail allows at most five tries up to 5 seconds apart and that its HTTP Request node doesn’t automatically honor Retry-After, while its node-settings page says the setting reruns until it succeeds [20, 21]. Check the Max Tries value in your own node rather than relying on either description. See connecting an AI API to a no-code tool for workflow error handling, and BuildAIQ’s AI Automation guide on what happens when an automation fails for partial runs and replays.

Don’t Do It Twice: Idempotency

A request is idempotent when sending it twice has the same effect as sending it once. The HTTP standard says clients shouldn’t automatically retry one that isn’t unless they know it’s safe or was never applied [8]. In Microsoft’s Retry pattern, a service processes a request but fails to send the response, so the retry repeats the work [22]. A timeout doesn’t prove the side effects didn’t happen, Amazon adds [9].

A repeated model call mostly means paying for the answer twice; the bigger risk is what your app does with it: saving a record, emailing a customer, charging a card. Give each such action a unique ID your app generates and check it before acting again; Amazon describes caller-provided request identifiers as its preferred way to make retries safe [23].

Keep the App Usable While the API Is Down

The goal is what AWS’s Well-Architected guidance calls graceful degradation: a component keeps delivering its core function when a dependency is unhealthy, returning stale data, alternate data or a reduced response rather than failing outright [24]. For the quiz app: save notes, show earlier quizzes, queue new requests. When failures persist, stop calling: Microsoft’s circuit breaker pattern blocks calls once failures pass a threshold, then lets a few trial requests through to test recovery [25]. Amazon’s Builders’ Library notes that circuit breakers add behavior that’s hard to test, so rehearse the open state too [9].

A fallback, another model or provider used when the first fails, is only worth having if it works when needed. For a model the provider can’t find, Bedrock’s and Google’s error pages suggest switching to an alternative [12, 3]. For outages, AWS warns that fallback logic that is never exercised tends to be broken when you need it, and advises keeping degraded paths simpler than the main one and testing them as often as production code [24]. An Amazon Builders’ Library article about Amazon’s own systems, not AI APIs, says Amazon almost never uses fallbacks and exercises any essential one regularly [26]. Test any backup model on your own examples and use it regularly.

What to Tell Your Users

This is BuildAIQ editorial guidance. Say plainly what isn’t working, whether the user’s input was saved, and what to do next. Don’t show raw error bodies or anything resembling a key, don’t present a cached or fallback answer as fresh, and say when a feature is paused instead of leaving a spinner running.

Log What Support Needs, Not Your Secrets

OpenAI recommends logging request IDs in production and lets apps send their own X-Client-Request-Id, so support can trace a request even when a timeout hid the response [10]. Microsoft suggests logging early retry failures as informational and only the final one as an error [22].

OWASP’s Logging Cheat Sheet, a community security guide, says access tokens, passwords, encryption keys and sensitive personal data should usually be removed, masked or encrypted rather than logged directly [11]. Support requests need the same care: OpenAI’s support asks for the request data and headers you sent [1], and the authentication header carries your key, so remove it first. For ongoing alerts, see BuildAIQ’s AI Automation guide on monitoring an automation after launch.

Practical Takeaways

A checklist for the next failure (BuildAIQ editorial guidance):

  1. Copy the status code, error code, message and request ID; look them up on your provider’s error page.
  2. Fix 400, 401, 402, 403 and 404 problems first: request, key, permission, billing, model name.
  3. Check the status page for 500s, 503s and overload codes before debugging.
  4. Retry only temporary failures: honor Retry-After, back off with jitter, cap attempts and time, and count your SDK’s or tool’s own retries.
  5. Give side-effect actions your own unique IDs so a retry can’t save, send or charge twice.
  6. Check deprecation pages on a schedule, since some models reroute rather than fail.
  7. Show users an honest message, keep their input, keep keys out of logs and support requests, and mask sensitive personal data.

You now have a triage order, a retry policy and an outage plan, which completes this path. Return to what an AI API is for the big picture, or continue with BuildAIQ’s Building AI Applications guides. The evidence here is provider documentation and vendor guidance; we found no independent data on how often each failure occurs or which retry settings suit AI APIs.

Sources

  1. Error codes. OpenAI, accessed 2026-11-22.
  2. Claude API errors. Anthropic, accessed 2026-11-22.
  3. API errors (Gemini Interactions API). Google, accessed 2026-11-22.
  4. Troubleshooting guide (Gemini API). Google, accessed 2026-11-22.
  5. Rate limits. OpenAI, accessed 2026-11-22.
  6. Model deprecations. Anthropic, accessed 2026-11-22.
  7. Gemini deprecations. Google, accessed 2026-11-22.
  8. RFC 9110: HTTP Semantics. IETF (RFC Editor), 2022-06, accessed 2026-11-22.
  9. Timeouts, retries, and backoff with jitter. Amazon Web Services (Amazon Builders' Library, AWS Builder Center), 2019-12-05, accessed 2026-11-22.
  10. API Reference overview. OpenAI, accessed 2026-11-22.
  11. Logging Cheat Sheet. OWASP Cheat Sheet Series, accessed 2026-11-22.
  12. Troubleshooting Amazon Bedrock API Error Codes. Amazon Web Services, accessed 2026-11-22.
  13. Hypertext Transfer Protocol (HTTP) Status Code Registry. IANA, 2025-09-15, accessed 2026-11-22.
  14. Deprecations. OpenAI, accessed 2026-11-22.
  15. RFC 6585: Additional HTTP Status Codes. IETF (RFC Editor), 2012-04, accessed 2026-11-22.
  16. OpenAI Status. OpenAI, accessed 2026-11-22.
  17. Claude Status. Anthropic, accessed 2026-11-22.
  18. Structured model outputs. OpenAI, accessed 2026-11-22.
  19. Structured output (Gemini API). Google, accessed 2026-11-22.
  20. Handle rate limits. n8n, accessed 2026-11-22.
  21. Work with nodes (node settings). n8n, accessed 2026-11-22.
  22. Retry pattern. Microsoft (Azure Architecture Center), 2024-07-18, accessed 2026-11-22.
  23. Making retries safe with idempotent APIs. Amazon Web Services (Amazon Builders' Library), accessed 2026-11-22.
  24. REL05-BP01 Implement graceful degradation to transform applicable hard dependencies into soft dependencies. Amazon Web Services (AWS Well-Architected Framework), accessed 2026-11-22.
  25. Circuit Breaker pattern. Microsoft (Azure Architecture Center), 2025-02-05, accessed 2026-11-22.
  26. Avoiding fallback in distributed systems. Amazon Web Services (Amazon Builders' Library, AWS Builder Center), 2019-12-05, accessed 2026-11-22.