LLM API Alert Thresholds: 429, 5xx, Timeout and P95 Latency Rules
Don't set a single "error rate above X%" alert for your LLM API. The three kinds of errors (429, 5xx and timeouts) have different owners and different fixes. A 429 is usually your own quota or concurrency problem, 5xx and overload errors usually come from the upstream provider, and timeouts may be your network. Don't use a fixed millisecond value for latency either; a multiple of each endpoint's own baseline is more stable. Below is a starter rule table split by error type, then why each rule is set the way it is and what to check first when one fires.
Why isn't one error-rate threshold enough?
Say your service calls a model API, the overall error rate climbs to 8% over 5 minutes, and an alert fires. The first thing the on-call engineer does is dig through logs to see what that 8% actually is. If it is all 429s, the job is to reduce concurrency, check the quota, and see whether retries are amplifying traffic. If it is 502, 503 and 529, the job is to check for an upstream announcement and decide whether to switch to a backup provider. If it is connection timeouts, suspect your own egress network or proxy first.
The three cases share no response actions. Mixing them into one metric causes two problems:
- The threshold is hard to pick. Some 429s at peak traffic are normal, and a client that backs off recovers on its own. 5xx is worth a look even at 2%. One number can't serve both: either 429s wake people up every day, or nobody knows when 5xx starts to climb.
- The alert points nowhere. Whoever gets "error rate high" has to classify the errors themselves, adding minutes to response time.
For what each status code means and whether to retry, see the LLM API error code cheat sheet. For alert design, split errors into at least these four buckets:
| Bucket | Statuses included | Main owner | Typical action |
|---|---|---|---|
| Rate limiting | 429 (separate rate limit from exhausted quota) | Your quota, concurrency, retry logic | Slow down, check quota, read Retry-After |
| Upstream failure | 500, 502, 503, 504, 529, etc. | The model provider or an intermediate gateway or CDN | Check the status page, switch to backup, wait for recovery |
| Network | Connection timeout, TLS failure, read timeout, stream interruption | Your egress, proxy, cross-border route | Test egress, change route, check proxy config |
| Request error | 400, 401, 403, 404, 413 | Your code or API key | Check the latest release, fix code or replace the key |
The request-error bucket usually follows deployments. For example, you can alert on it only when it appears within 10 minutes after a new release. I won't go into it here.
How should I set 429 alerts?
A 429 is not necessarily bad. A client with proper backoff waits and resends when it gets a 429, and users feel at most a slight slowdown. Two situations genuinely need an alert:
- 429s make up a large share of requests for a sustained period. That means you are constantly over the limit, queues keep growing, and eventually requests turn into timeouts or users give up.
- The 429 is caused by exhausted quota rather than exceeding a rate limit. Some providers distinguish the two in the 429 response body. Exhausted quota does not recover by waiting, so the person who manages billing should be notified immediately. OpenAI's 429 comes in two kinds, insufficient_quota and rate_limit_exceeded, and your alert rules should split on that field. For the difference, see OpenAI API 429: insufficient_quota vs rate_limit_exceeded and how to handle each.
So split 429 into at least two rules. Rate-type 429s get a longer window and a higher threshold and go to working-hours notification. Quota-type 429s notify as soon as they appear, with no ratio needed. It also helps to record Retry-After and the remaining-quota headers from 429 responses and include them in the alert message, saving the on-call one lookup. For concrete ways to handle 429s, see What to do when the API returns 429 Too Many Requests.
One easy-to-miss point: with badly written retry logic, 429s can multiply your own traffic several times over. Add a separate observation metric for "retry requests / first-attempt requests". When the ratio rises noticeably, the problem may be in the client rather than the limit. For how to write a retry budget, see How to write retries for LLM APIs.
How should I set 5xx and overload alerts?
5xx is the most direct signal that something is wrong upstream, so its threshold should be lower and its window shorter than for 429. Two things to handle when writing the rules.
First, count overload errors separately. 529 (Anthropic's overloaded_error) and 503s carrying a "service busy" message are mostly upstream capacity pressure and may ease on their own after a while. 500 and 502 are more likely real failures. Counting overload on its own lets you give it a somewhat looser duration requirement. For how 529 differs from 429 and 500, see What Claude's 529 overloaded_error means.
Second, you must add a minimum sample count. Ratio-based alerts are badly distorted during low-traffic periods. Here is real data: AGI Plan's public hourly request statistics (AGI Plan is a commercial partner of cdnping; only 5xx counts as a platform failure, and the data comes from https://agiplan.dev/api/status/requests). The window runs from 2026-10-15 19:05 to 10-17 18:05 (Beijing time, UTC+8), 48 hourly buckets in all, and the table shows 6 of them:
| Hourly bucket timestamp (Beijing time) | Success | Failed | Failure share |
|---|---|---|---|
| 10-16 13:05 | 832 | 5 | 0.6% |
| 10-16 14:05 | 664 | 722 | 52.1% |
| 10-16 15:05 | 455 | 877 | 65.8% |
| 10-16 16:05 | 921 | 107 | 10.4% |
| 10-16 17:05 | 968 | 15 | 1.5% |
| 10-17 18:05 | 15 | 1 | 6.3% |
Two things stand out in this data. First, real outages arrive fast: between two adjacent hourly buckets the failure share jumped from 0.6% to 52.1%, so an hourly aggregated alert would fire much later. That is why 5xx alerts should use a 5-minute window. Second, low traffic inflates ratios: the last row has only 16 requests, so a single failure is 6.3%, more than four times the 1.5% of the 17:05 bucket (983 requests, 15 failures), and that bucket is the period just after an outage ended that still deserves attention. Without a minimum sample count in the rule, late night and early morning will produce constant false alarms. The same data also has hourly buckets with only 2 successes, where a ratio means nothing.
Why look at timeouts separately?
Timeouts and connection errors are invisible on the server side. Only the caller knows about them. If the provider's status page is all green but you see lots of timeouts, the cause may be your proxy, DNS, cross-border route or MTU.
Counting them separately also lets you compare against 5xx. If 5xx and timeouts rise together, it is most likely upstream. If only timeouts rise and 5xx stays flat, check your own network first.
Distinguish two kinds of timeout:
- Connect timeout / TLS failure: the request never left, which is almost always a network problem.
- Read timeout / stream interruption: the request reached upstream. Upstream may be slow to generate, or an intermediate Nginx or CDN may have cut the long-lived connection. If read timeouts cluster on long responses, check the idle-timeout settings of your proxy and gateway first. For troubleshooting, see LLM streaming output cut off midway.
Why can't P95 latency alerts use a fixed number of milliseconds?
"Normal latency" differs widely between endpoints. The table below shows cdnping probes from the Cloudflare edge to each official API entry point. First, the window: cdnping started collecting on 2026-10-17, and the probe window in this snapshot is 2026-10-17 16:40 to 18:05 (Beijing time), with 242 probes across all endpoints in total, from the Denver (DEN) probe location. The p50, p95 and availability in the table cover only this hour or so, so treat them as an example, not long-term statistics. What is measured is the round trip from the edge to the API entry point, excluding model generation time. For the method, see Methodology.
| Endpoint | p50 (ms) | p95 (ms) | p95 / p50 | Availability in window |
|---|---|---|---|---|
| Claude API | 73 | 84 | 1.2 | 100% |
| OpenAI API | 96 | 194 | 2.0 | 100% |
| Mistral API | 153 | 536 | 3.5 | 100% |
| Kimi Open Platform (Moonshot AI) | 375 | 1125 | 3.0 | 94.4% |
| Alibaba Cloud Model Studio | 615 | 1152 | 1.9 | 100% |
| Volcengine Ark | 485 | 1149 | 2.4 | 100% |
Suppose you set one "P95 over 500 ms" alert for every endpoint. Model Studio, Volcengine Ark and Kimi are already above 500 ms in this window, so they would fire constantly. Meanwhile the Claude API's P95 could rise from 84 ms to 400 ms, nearly a fivefold increase, and never trigger. A fixed threshold creates noise at one end and misses real degradation at the other.
The Mistral row shows something else: the most recent probe was 538 ms, right around its p95 (536 ms), while its p50 is only 153 ms. One slow request does not mean the endpoint got slower. Latency alerts should look at percentiles and require persistence across several windows.
A workable approach is to set a multiple of each endpoint's own baseline. For example, take the P95 from the same time of day over the past 7 days as the baseline, and alert only if the current 15-minute P95 exceeds 2x the baseline for 3 consecutive windows. For a newly integrated endpoint without 7 days of data, use the first few days of observations, then switch once enough data has accumulated.
If calls are streamed, it is best to monitor latency as two numbers, time to first token (TTFT) and total duration, because they slow down for different reasons. A slower TTFT is mostly queuing or network, while slower total duration can also mean longer output. For how to break latency into stages, see AI API latency breakdown: connection setup, gateway round trip and time to first token.
Starter alert rule table
The table below is a starting point, not an industry standard. Adjust every number to your own traffic and your business's tolerance for latency. After going live, observe for two weeks, loosen rules with many false alarms and tighten the ones that miss.
| Rule | Calculation | Window | Starting threshold | Min samples | Duration | Cooldown | Notify |
|---|---|---|---|---|---|---|---|
| Quota exhausted | Count of quota-type 429s | 5 min | ≥ 1 | None | None | 1 hour | Immediately, account owner |
| Rate limiting | Rate-type 429 / all requests | 10 min | > 10% | 50 | 10 min | 30 min | Working hours |
| Upstream failure | 500/502/503/504 / all requests | 5 min | > 2% | 30 | 5 min | 15 min | On-call |
| Upstream overload | 529 and overload-type 503 / all requests | 5 min | > 5% | 30 | 10 min | 15 min | On-call |
| Severe outage | Total 5xx / all requests | 5 min | > 20% | 30 | 5 min | 15 min | Phone call |
| Network | Connect timeout + TLS failure / all requests | 5 min | > 2% | 30 | 5 min | 15 min | On-call |
| Latency | Current P95 / same-time P95 over 7 days | 15 min | > 2x | 100 | 3 consecutive windows | 1 hour | Working hours |
| Retry amplification | Retry requests / first-attempt requests | 10 min | > 0.5 | 50 | 10 min | 30 min | Working hours |
A few noise-reduction details:
- When the severe-outage rule fires, suppress the upstream-failure rule for the same endpoint so one incident doesn't send two messages.
- Group by endpoint (provider + model). Don't combine all upstreams in one calculation, or a small provider going down gets diluted by large traffic elsewhere.
- During the cooldown, only update the original alert instead of sending a new one. On recovery, send a "resolved" message with the duration.
If you already have SLOs for your service, you can add an error-budget burn-rate alert on top of this table. For the algorithm, see SLI, SLO and SLA: what is the difference.
Prometheus example
Suppose you instrument the caller with a counter llm_requests_total that has provider, model and error_type labels (values ok, rate_limit, quota, upstream_5xx, overloaded, network). The upstream-failure rule can be written like this:
groups:
- name: llm-api
rules:
- alert: LLMUpstream5xx
expr: |
(
sum by (provider, model) (rate(llm_requests_total{error_type="upstream_5xx"}[5m]))
/
sum by (provider, model) (rate(llm_requests_total[5m]))
) > 0.02
and
sum by (provider, model) (increase(llm_requests_total[5m])) >= 30
for: 5m
labels:
severity: page
annotations:
summary: "{{ $labels.provider }}/{{ $labels.model }} 5xx above 2%"
runbook: "Check https://cdnping.org/status and /down first, then your own logs"
The and ... >= 30 clause is the minimum sample count. For the latency-multiple rule, use histogram_quantile to compute the current P95, then divide by the same expression with offset 7d.
What should I check first when an alert fires?
Follow this order. Each step rules out a large class of causes:
- First confirm whether it is an upstream problem. Open cdnping's API status and see whether the edge probes for that endpoint turned red at the same time. Then check Is it down? for other users reporting an outage at the same time. For Kimi, for example, go straight to /en/status/moonshot. Announcements on an official status page can appear later than the actual outage, so don't just wait for them.
- See which bucket the errors fall into. Mostly 5xx follows the upstream procedure. Mostly 429, look at quota and retries. Mostly timeouts, jump to step 4.
- If an upstream failure is confirmed, switch to a backup provider or degrade features according to your plan, and note the start time in the alert message to help with the postmortem.
- If only your side is timing out, test egress from the affected machine. Use the online speed test to see first-connection and round-trip times for each API, and IP and environment check to confirm that your egress IP and routing look the same as usual. When the proxy or route changes, latency and timeouts often change together.
- Record the outcome and tune the rules afterward. Label every alert as "valid / false alarm / duplicate", and after two weeks adjust thresholds and minimum sample counts based on the labels.
What if you haven't set up upstream probing yet?
The rules in this article all rely on instrumentation in the caller. If you also need a layer of upstream probing independent of your business traffic, so you can detect outages even during low-traffic periods, see How to monitor the availability of an AI application.