Skip to article
API429 / Field notes

AI API Rate-Limit SLOs, 429 Observability, and Incident Triage Runbook

Define job-level rate-limit SLOs, log redacted 429 telemetry across Gemini and OpenAI-compatible calls, and execute a 10-minute incident triage and postmortem workflow.

Hourglass and a queue of paper request cards
Editorial photo illustration: Hourglass and a queue of paper request cards. Topic: AI API Rate-Limit SLOs, 429 Observability, and Incident Triage Runbook.

Measuring raw HTTP 429 counts in isolation neither tells you whether users are failing nor tells an on-call responder what to turn off first. A burst of transient 429s absorbed within a 2-second Retry-After window may leave user-visible SLOs intact, whereas a silent retry loop can hide a 429 storm until queue latency and token spend explode. Reliable operations require three linked disciplines: job-level rate-limit SLOs, redacted per-attempt observability, and a deterministic 10-minute incident triage and postmortem runbook.

This consolidated guide unifies AI API rate-limit SLO design, 429 incident observability, and gateway triage/postmortem templates into one operational reference. Use it alongside application retry budgets, adaptive throttling, and dead letter queue recovery.

Define job-level SLIs and rate-limit error budgets

Following Google SRE service-level objective principles, an AI SLI should measure valid business outcomes delivered within the caller's deadline, separated by workload class (interactive, webhook, batch).

SLI metric Formula Recommended target example Automated policy trigger on error-budget burn
Interactive valid completion rate valid_completions_within_deadline / total_admitted_interactive_jobs >= 99.0% over rolling 28d (fast-burn alert over 5m/1h) Enter brownout mode; pause background and bulk queues immediately
Retry amplification ratio total_upstream_http_attempts / total_admitted_logical_jobs <= 1.15 for interactive, <= 1.25 for async webhooks Clamp worker retries to 1 attempt; enforce strict Retry-After floor
Queue admission wait p95 p95(dispatched_at - enqueued_at) per priority lane <= 1.5s interactive, <= 30s webhook Shed low-priority arrivals before they consume socket concurrency
Unreconciled timeout rate timed_out_attempts_without_ledger_resolution / total_admitted_jobs < 0.1% Route uncertain outcomes to dead letter queue reconciliation

Never target a 0% HTTP 429 rate as an SLO. Upstream rate limits are normal flow-control signals; your SLO should govern whether bounded queuing and pacing deliver a valid result within budget.

Multi-window burn alerts and postmortem template

To avoid alert fatigue on brief 30-second bursts while catching sustained capacity exhaustion within minutes, pair a fast-burn window (for example, consuming 2% of the 28-day error budget in 1 hour, tested over a 5-minute and 1-hour dual window) with a slow-burn ticket alert (consuming 5% over 6 hours). When a fast-burn alert pages on-call, capture structured postmortem evidence immediately after stabilization:

  • Incident window and affected lanes: Exact UTC start/end timestamps, impacted priority lanes (`interactive`, `webhook`, `batch`), and total job completion SLI deficit.
  • Primary trigger vs internal amplifiers: Separate the external or traffic trigger (such as an unscheduled bulk backfill or long-context prompt deployment) from internal amplifiers (such as worker retry loops or missing per-tenant semaphores).
  • Verified remediation commits: Link every postmortem action item to a concrete configuration or code test—such as lowering the retry amplification ceiling, tightening token-bucket burst caps, or routing timed-out jobs to the dead letter queue.

What to log on every 429, timeout, and recovery attempt

When debugging Google Gemini API rate limits or OpenAI-compatible gateway calls documented in the API429 documentation and public OpenAPI spec, status code and wall-clock latency are not enough. Emit a structured, redacted OpenTelemetry span or log event per attempt with these exact fields:

  • Identity & correlation: trace_id, operation_id, attempt_index, workload_lane (interactive, webhook, batch), and tenant_id.
  • Model & contract: exact model_id (verified against /en/models and catalog drift checks), endpoint_path, stream_mode, and schema_version.
  • Capacity & timing: queue_wait_ms, upstream_latency_ms, remaining_deadline_ms, estimated_input_tokens, observed_retry_after_s, and suspected_dimension (RPM, input_TPM, RPD, spend_window, or unknown when unattributed).
  • Redaction guard: Never log raw prompts, bearer tokens (Authorization), or unredacted customer payloads during an incident.

First 10 minutes: 429 incident triage runbook and postmortem structure

When a fast-burn alert fires on your rate-limit SLO, execute this sequence in order without guessing:

  1. Minute 0–2 (Stop retry amplification): Verify the retry amplification ratio. If workers are multiplying traffic (ratio > 1.20), immediately freeze inline retries for non-critical lanes and enforce the full Retry-After cooldown floor.
  2. Minute 2–5 (Separate 429 from auth, catalog, and balance failures): Inspect whether errors are pure HTTP 429 or mixed with 401/403/404. Run a point-in-time check of GET /v1/models, GET /api/client/balance, and a scoped workload health observation. Check the Google provider hub, pricing page, and FAQ if account credit or model availability changed.
  3. Minute 5–8 (Shed bulk and background load): Pause batch backfills, n8n bulk enrichment jobs, and non-blocking evaluations so interactive users on Claude Code or Cursor retain local RPM/TPM reserves.
  4. Minute 8–10 (Verify recovery and stage postmortem evidence): Confirm queue wait p95 and amplification ratio return below threshold before gradually ramping background lanes via shadow traffic or staged ramp-up. Record the incident window, root trigger, amplifiers, and action items in your postmortem ledger.

Runnable offline Python SLO burn and incident triage evaluator

The following self-contained Python 3.10+ script computes job-level SLIs, retry amplification ratios, and automated incident triage actions from synthetic attempt logs:

from __future__ import annotations
from dataclasses import dataclass
from typing import Sequence


@dataclass(frozen=True)
class AttemptLogRecord:
    operation_id: str
    workload_lane: str       # "interactive", "webhook", "batch"
    http_status: int
    completed_within_deadline: bool
    queue_wait_ms: int
    retry_after_s: float
    suspected_dimension: str # "RPM", "input_TPM", "RPD", "unknown"


@dataclass(frozen=True)
class IncidentTriageReport:
    interactive_sli: float
    retry_amplification_ratio: float
    status_429_share: float
    dominant_dimension: str
    severity: str
    immediate_actions: tuple[str, ...]


def evaluate_slo_window(records: Sequence[AttemptLogRecord], slo_target: float = 0.99) -> IncidentTriageReport:
    if not records:
        return IncidentTriageReport(1.0, 1.0, 0.0, "none", "healthy", ())

    logical_jobs: dict[str, list[AttemptLogRecord]] = {}
    for rec in records:
        logical_jobs.setdefault(rec.operation_id, []).append(rec)

    interactive_jobs = [
        attempts for attempts in logical_jobs.values()
        if attempts[0].workload_lane == "interactive"
    ]
    interactive_ok = sum(
        1 for attempts in interactive_jobs
        if any(a.http_status == 200 and a.completed_within_deadline for a in attempts)
    )
    interactive_sli = round(interactive_ok / len(interactive_jobs), 4) if interactive_jobs else 1.0
    amplification = round(len(records) / len(logical_jobs), 3)
    records_429 = [r for r in records if r.http_status == 429]
    share_429 = round(len(records_429) / len(records), 4)

    dim_counts: dict[str, int] = {}
    for r in records_429:
        dim_counts[r.suspected_dimension] = dim_counts.get(r.suspected_dimension, 0) + 1
    dominant_dim = max(dim_counts, key=dim_counts.get) if dim_counts else "none"

    actions: list[str] = []
    if amplification > 1.20:
        actions.append("clamp_non_critical_retries_and_enforce_retry_after")
    if interactive_sli < slo_target or share_429 >= 0.10:
        actions.append("pause_batch_and_background_queues_enter_brownout")
    if dominant_dim == "input_TPM":
        actions.append("cap_long_context_prompts_and_prune_tool_history")
    elif dominant_dim == "unknown" and share_429 > 0:
        actions.append("run_point_in_time_catalog_and_balance_preflight")

    severity = "critical" if interactive_sli < slo_target else ("warning" if actions else "healthy")
    return IncidentTriageReport(
        interactive_sli=interactive_sli,
        retry_amplification_ratio=amplification,
        status_429_share=share_429,
        dominant_dimension=dominant_dim,
        severity=severity,
        immediate_actions=tuple(actions),
    )


if __name__ == "__main__":
    sample_window = [
        AttemptLogRecord("op-1", "interactive", 429, False, 120, 3.0, "input_TPM"),
        AttemptLogRecord("op-1", "interactive", 200, True, 3150, 0.0, "unknown"),
        AttemptLogRecord("op-2", "interactive", 429, False, 200, 4.0, "input_TPM"),
        AttemptLogRecord("op-2", "interactive", 429, False, 4200, 4.0, "input_TPM"),
        AttemptLogRecord("op-3", "batch", 429, False, 800, 5.0, "unknown"),
    ]
    print("Synthetic incident triage report:", evaluate_slo_window(sample_window))

FAQ

Why shouldn't our rate-limit SLO target 0% HTTP 429 responses?

An HTTP 429 response is a flow-control signal, not necessarily a user-facing failure. If your queue paces requests using Retry-After and completes the user's job within the deadline, the user experience succeeded. Targeting 0% 429s encourages teams to hide throttling with unbounded queues or over-provisioned idle capacity.

How can we tell whether a 429 incident is caused by RPM, input TPM, or retry amplification?

Log estimated_input_tokens and attempt_index on every attempt. If retry_amplification_ratio spikes above 1.20, retries are multiplying load; if 429s occur at low request counts alongside large prompts, input_TPM is the likely bottleneck; if the gateway returns a generic 429 without counter attribution, record the dimension as unknown and reduce overall admission.

Should we log full prompt bodies during a 429 incident to reproduce token counts?

No. Logging raw prompts leaks sensitive customer content and credentials into observability storage. Log only the integer estimated_input_tokens, character length, model_id, and a SHA-256 content hash.

What belongs in an AI API 429 postmortem?

Include five concrete sections: (1) user-level SLI impact and duration, (2) initial capacity trigger (such as an unpaced batch job or long-context spike), (3) retry or queue amplifiers that prolonged recovery, (4) exact mitigation timeline, and (5) code-level follow-ups such as tighter token buckets or DLQ isolation.

Sources & further reading

  1. Google SRE Book: Service Level Objectives
  2. OpenTelemetry observability primer
  3. RFC 6585 section 4: 429 Too Many Requests
  4. RFC 9110 section 10.2.3: Retry-After
  5. Google Gemini API rate limits
  6. Google Gemini API troubleshooting guide
  7. API429 customer documentation
  8. Current API429 public OpenAPI
  9. API429 public catalog contract

Put the next step into practice.

Check model IDs, current pricing and request formats before integrating. Availability can depend on the model and provider route.

Telegram