On-call runbook: AI API latency spike
When a user's chat request hangs for 5 seconds instead of the usual 800 milliseconds, your on-call phone buzzes. The incident is real: an AI API latency spike is degrading production. This runbook walks you through diagnosis, mitigation, and recovery in the first 30 minutes, and how to prevent the next one.

Photo by Kampus Production from Pexels
When a user's chat request hangs for 5 seconds instead of the usual 800 milliseconds, your on-call phone buzzes. The incident is real: an AI API latency spike is degrading production. This runbook walks you through diagnosis, mitigation, and recovery in the first 30 minutes, and how to prevent the next one.
Key takeaway: Regional monitoring, clear latency thresholds, and a pre-tested failover strategy reduce incident response time from 30–60 minutes to 10–15 minutes. Most latency spikes are provider-side degradation, regional routing issues, or retry storms amplifying the problem. Stop retrying before you understand the root cause, and always compare latency across regions to distinguish between global outages and localized problems.
TL;DR
- Latency spikes are regional and variable. A single aggregate metric hides whether slowness is global, provider-wide, or isolated to your routing path. Compare TTFB (time to first byte) and TTFT (time to first token) across regions via monitoring tools like Observinio's daily probes.
- Retry storms make spikes worse. If an API tool starts timing out at 20% of calls, the agent retries and burns token budget. Stop retrying before you understand the root cause.
- Provider status pages lag reality by 5–15 minutes. Check your own regional probes first; then verify with the provider's dashboard.
- Failover to a backup provider or region takes 2–5 minutes. Have a pre-tested runbook and alert thresholds set before the spike happens.
- Post-incident: analyze trends, not just the spike. Weekly summaries reveal whether latency is creeping upward or if this was an outlier.
Minute 0–2: Confirm the spike is real
Before escalating or panicking, verify that the latency spike is not a local issue.
Step 1: Check your own application metrics.
- Open your APM tool (DataDog, New Relic, etc.) and look at API response times for the last 10 minutes.
- Isolate the latency to the external AI API call, not your entire request pipeline. Filter by service and endpoint.
- Note the percentile affected: Is 100% of requests slow, or just the p99?
- If you call the AI API from multiple regions (US East, EU, Asia-Pacific), compare latency across each origin point.
- A global provider outage affects all regions evenly; a regional incident affects one or two.
- Use Observinio's dashboard to see TTFB and TTFT from 21 global probe regions. This gives you a data-driven view in seconds, without waiting for internal logs to backfill.
- Check your provider's rate-limit headers in the API responses:
x-ratelimit-remaining,x-ratelimit-reset. - If remaining quota is near zero, you are rate-limited. This is not a provider outage; you need to increase quota or shed load.
Minute 2–5: Identify the root cause
Latency spikes have three common causes: provider degradation, regional routing trouble, or your own retry storm. Narrow it down quickly.
Root Cause #1: Provider-side degradation
Symptoms:- Latency spike is global (all regions affected equally, or only regions that route to that provider).
- Error rate is stable or low; requests are succeeding, just slowly.
- Your application code and configuration have not changed.
- Check the provider's status page. OpenAI's status page at
status.openai.com, OpenRouter's atstatus.openrouter.io, and similar services. Look for "Investigating" or "Degraded Performance" posts in the last 15 minutes. - Compare latency to Observinio baseline. If your baseline TTFB was 300 ms and you are now seeing 1.2 seconds from multiple regions, the provider is slow. Check the baseline graph on
/statusor your own dashboard. - Check provider's own dashboards. If you have direct OpenAI or provider account access, log in and verify response times from their first-party metrics.
- Query recent batch jobs or traffic spikes. Use the provider's API logs or account page to see whether a large batch job or viral use case is consuming the provider's capacity.
- Post an incident in your Slack #incidents channel with: "OpenAI latency degraded globally. TTFB baseline 300 ms → 1.2 s. Failover to OpenRouter in progress."
- Move to the "Failover" section (Minute 5–10).
- Do not keep retrying the slow provider; every retry burns tokens and delays recovery.
Root Cause #2: Regional routing issue
Symptoms:- Only one or two regions are slow; others are normal.
- Error rate is stable.
- Your provider's own status page shows no issues.
- Compare latency per region in Observinio's 21-region probes. If US East is 300 ms and US West is 2.5 seconds, the issue is routing between your data center and the provider's West Coast endpoint, not the provider itself.
- Check your regional failover configuration. Is a DNS entry pointing to the wrong endpoint? Is a regional load balancer broken?
- Contact your provider's support and mention the specific region. They can see whether their endpoint in that region is healthy or degraded.
- Route traffic away from the slow region to an alternate endpoint or fallback provider.
- Update DNS or load-balancer rules to test the alternate path.
- Expect 2–5 minutes for DNS or LB rule changes to propagate.
Root Cause #3: Retry storm (your code is amplifying the spike)
Symptoms:- Error rate is up (e.g., 5–10% of requests are timing out).
- Total request volume to the provider doubled or tripled in the last 5 minutes.
- Your retry logic is aggressive (e.g., retry every 100 ms, 10 times).
- Check your API logs for patterns. Are the same user session retrying the same request three times? Are you retrying on all error types?
- Compare incoming request volume to outgoing API calls. If you have 100 user requests but 400 API calls, you are retrying 3x per user request on average.
- Stop retrying immediately. Set a feature flag to disable retries and flip it in production.
- Update your retry logic to: retry only on transient errors (5xx, timeout), not on client errors (4xx). Use exponential backoff (wait 500 ms, then 1 s, then 2 s) to avoid slamming the provider.
- Burn down the queue of queued retries before resuming normal traffic.
Minute 5–10: Failover or mitigate
Once you have identified the root cause, execute the appropriate mitigation. This is where pre-planning saves minutes.
If provider is degraded: Failover to backup provider
Pre-incident setup (do this before you are on-call):
- Configure a secondary provider in your AI API routing layer. For example: primary = OpenAI, secondary = OpenRouter or Anthropic Claude.
- Set a latency threshold for failover (e.g., if p99 latency exceeds 2 seconds for 2 consecutive minutes, failover).
- Test failover in staging. Verify that swapping providers does not break your prompt formatting or token limits.
- Document the failover in your runbook (this file).
- Open your feature-flag or config-management tool (LaunchDarkly, Unleash, etc.).
- Create or enable a flag called
use_backup_provider: trueand roll it out to 100% of traffic. - Monitor the p99 latency for 30 seconds. If it drops back to normal (< 500 ms), the failover worked.
- If the backup provider is also slow, roll the flag back and escalate to your CTO or incident commander.
"If an API tool starts timing out at 20% of calls, the agent retries and burns token budget.">, The On
If regional issue: Reroute or shed load
For regional degradation:
- Update your DNS or load-balancer to route affected regions to an alternate endpoint or provider.
- If you use OpenRouter, try a different model or provider tier (e.g., switch from
openai/gpt-4-turbotoopenrouter/anthropic-claude-opus). Latency may differ. - Shed non-critical load: if you offer background jobs or batch processing, pause them for 10 minutes to reduce pressure on the provider.
If retry storm: Kill and drain
- Disable retry logic via feature flag immediately. Set
max_retries: 0. - Monitor the queue of pending retries. As they fail and are drained from memory, outgoing API request volume will fall.
- Once volume stabilizes (5–10 minutes), gradually re-enable retries with exponential backoff (start at 500 ms, max 5 seconds, max 3 attempts).
Minute 10–20: Communicate and monitor
Communication checklist:
Monitoring checklist:
Minute 20–30: Stabilize and document
Once latency has been normal for 10 minutes and error rate is stable, the incident is effectively over. But do not skip stabilization.
Stabilization steps:
- Gradually roll back failover. If you failed over to a backup provider, slowly shift 10% of traffic back to the primary provider every 2 minutes. Watch for latency spikes. If the primary is still degraded, keep the failover in place and move to post-incident review.
- Verify no cascading issues. Check downstream services that depend on your AI API responses. Did any timeouts or queue backlogs accumulate?
- Update your dashboards and alerts. If you discovered a blind spot (e.g., regional latency was not monitored), set up a new alert or dashboard panel now.
- Duration: start time, end time, total minutes of impact.
- Root cause: one sentence.
- Mitigation: what action fixed it and how long it took.
- Why we did not catch this earlier: did your alerts fail? Was the threshold too high?
- Prevention: what will you do differently next time?
Preventing the next spike: Setup and thresholds
Latency spikes are not random. They cluster around certain events: provider maintenance windows, traffic spikes from viral content, or gradual capacity exhaustion. Use data to predict and prevent.
Daily probes and baseline comparison
Use Observinio or a similar synthetic monitoring tool to:
- Run daily probes from 21 regions. Each probe measures TTFB, TTFT, and error rate. This gives you a global latency map, not a single aggregate number.
- Compare against rolling 7-day baseline. If today's TTFB is 50% higher than the 7-day average, an anomaly detector should fire an alert.
- Set region-specific thresholds. US East latency might be 300 ms on average, but EU latency might be 450 ms due to routing. Set alerts relative to each region's baseline, not a global threshold.
Alert configuration
Recommended alert thresholds for P1 (critical) incidents:
- P99 latency > 1.5 seconds for > 2 minutes, on any region: page on-call immediately.
- Error rate > 5% for > 2 minutes: page on-call immediately.
- Latency degradation > 50% from 7-day baseline for > 5 minutes, on any region: send email alert (not page) to track trends.
- P99 latency > 800 ms for > 5 minutes, on any region: send email to #incidents channel.
- Error rate > 2% for > 5 minutes: send email alert.
Weekly trend review
Every Monday morning, review the previous week's latency from Observinio's weekly summary email or your APM tool:
- Max latency per region. Did any region hit new highs?
- Baseline drift. Is latency creeping upward week-over-week, or stable?
- Error spike incidents. Were there any brief spikes that your alerts did not catch?
- Provider comparison. If you use multiple providers, which one is fastest and most stable?
Checklist: Before you are on-call
Print or bookmark this checklist. Complete every item before your on-call shift.
Your progress is saved automatically in your browser.
FAQ
Frequently Asked Questions
TTFT (time to first token) is how long until the first complete token is available. For streaming APIs, TTFT is often the same as TTFB. For batch APIs, TTFT is TTFB plus the time to generate the first token, which can be 500 ms–2 seconds depending on the model.
Both matter. High TTFB means the user waits a long time before any response appears. High TTFT but low TTFB means the server is fast but the model is slow.
Instead: failover to a backup provider, shed non-critical load, or return a cached response to the user. Retry only after latency has normalized and your retry logic uses exponential backoff (minimum 500 ms between attempts, maximum 3 attempts).
For critical services, set alerts for even smaller degradations (e.g., 20% above baseline for 5 minutes).
- Chat applications (real-time): P50 < 300 ms, P99 < 1000 ms. Users notice delays beyond 1 second.
- Batch or background processing: P95 < 5 seconds. Less time-sensitive; users do not see the request in real-time.
- Code generation or analysis: P50 < 500 ms, P99 < 2000 ms. Users can tolerate 2 seconds if the output is useful.
Check your APM tool, too. If you have servers in multiple regions, compare latency per origin. A global provider outage affects all origins equally. A regional routing issue affects only one origin.
- Check whether the backup provider's own status page reports issues.
- Shed load aggressively: pause background jobs, batch processing, and non-critical features.
- Return a cached response or a simplified fallback response to the user instead of calling the provider.
- Escalate to your CTO or engineering lead. You may need to communicate a broader incident.
- Document the incident and review your failover strategy afterward. Consider a third backup provider or a different routing strategy.
Next steps
Latency spikes will happen. But with regional monitoring, clear thresholds, and a tested failover strategy, you can go from alert to resolution in 10–15 minutes instead of 30–60.
Start today:
- Set up Observinio daily probes from 21 regions to compare your OpenRouter and OpenAI latency against a rolling baseline. Alerts will fire when latency drifts, before users complain.
- Configure your backup provider and test failover in staging this week.
- Share this runbook with your team. Run a brief training session or post-mortem walkthrough so everyone knows what to do when their phone buzzes.
- Review your weekly latency trends every Monday. Spot trends early and avoid the emergency on Friday at 5 PM.
Quick Response Matrix
| Symptom | Likely Cause | Action |
| All regions slow equally | Provider degradation | Failover to backup provider |
| One region slow | Regional routing issue | Reroute or DNS update |
| High error rate + volume spike | Retry storm | Disable retries, drain queue |
Additional Resources
- The On-Call Runbook for AI Systems That Nobody Writes - A latency spike could be caused by: a model generating longer outputs (upstream content change), KV cache pressure from concurrent long-context ...
- On-Call Runbook Template: A Framework That Works at 3AM - Here's the framework we've tested across hundreds of incidents — it works whether you're responding to a latency spike, a spike in 500s, or a ...
- The State of On-Call Runbook Automation in 2026 - In 2026, AI agents can execute these runbooks for you — querying your observability stack, analyzing the data, and surfacing a root cause in ...
Monitor AI API latency from 22 regions
Observinio runs daily probes against OpenRouter and OpenAI endpoints and emails you when latency degrades.
Set up alerts