# Error 429: Rate limit exceeded — Retry-After header missing or malformed

- **ID:** `llm/rate-limit-with-retry-after-header-misread`
- **Domain:** llm
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

The API returns a 429 error with a missing or non-standard Retry-After header, causing automatic retry logic to fail or use incorrect wait times.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| openai==1.16.0 | active | — | — |
| anthropic==0.30.0 | active | — | — |
| requests==2.31.0 | active | — | — |
| httpx==0.27.0 | active | — | — |
| gpt-4-turbo-2024-04-09 | active | — | — |
| claude-3-opus-20240229 | active | — | — |

## Workarounds

1. **Implement a custom retry handler that first checks for Retry-After header; if missing, use a default exponential backoff (e.g., 1s, 2s, 4s) up to a max of 60 seconds.** (90% success)
   ```
   Implement a custom retry handler that first checks for Retry-After header; if missing, use a default exponential backoff (e.g., 1s, 2s, 4s) up to a max of 60 seconds.
   ```
2. **Use a third-party retry library like `tenacity` with a custom retry condition that handles missing Retry-After headers gracefully.** (85% success)
   ```
   Use a third-party retry library like `tenacity` with a custom retry condition that handles missing Retry-After headers gracefully.
   ```

## Dead Ends

- **** — Hardcoding a fixed retry delay (e.g., 10 seconds) may be too short or too long, leading to repeated 429s or unnecessary waiting. (75% fail)
- **** — Ignoring the Retry-After header and using exponential backoff from scratch can cause multiple rapid retries that all fail. (80% fail)
- **** — Switching to a different HTTP library (e.g., from requests to httpx) doesn't fix missing headers from the server. (90% fail)
