---
title: "Stay under their rate limits · Agent Wranglers"
url: https://agentwranglers.se/playbook/api-design/using-other-companies-apis/respect-their-limits
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Stay under their rate limits

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: API-77
- Level: Recommended
- Chapter: [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis)
- Rule: Throttle your own calls below the provider's published limit. After a 429 or 503, send nothing more to that provider until its `Retry-After` time has passed.
- How: Write the provider's limits in the adapter's settings, with a link to where they are published. Count calls in one place that every worker shares, such as Redis, so ten workers do not each use the full limit. Read `Retry-After` in both forms, a number of seconds or an HTTP date. Read the provider's rate limit headers too, as [tell clients their rate limit](https://agentwranglers.se/playbook/api-design/reliability/rate-limit-headers) describes them. Slow down before the remaining count reaches zero. Bulk jobs, such as nightly syncs, use a smaller share of the limit than calls a person waits for.
- Check: Make the provider's fake answer 429 with `Retry-After: 120` once. No worker calls the fake again within 120 seconds. A load test at twice the normal job size gets no 429 from the fake.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
function retryAfterMs(header, now = Date.now()) {
  if (header == null) return 0;
  const seconds = Number(header);
  if (Number.isInteger(seconds) && seconds >= 0) return seconds * 1000;
  const date = Date.parse(header);
  return Number.isNaN(date) ? 0 : Math.max(0, date - now);
}
```

### Python example

```python
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

def retry_after_seconds(header: str | None, now: datetime | None = None) -> float:
    if header is None:
        return 0
    if header.isdigit():
        return int(header)
    try:
        moment = parsedate_to_datetime(header)
    except (TypeError, ValueError):
        return 0
    return max(0, (moment - (now or datetime.now(timezone.utc))).total_seconds())
```

## Sources

- [RFC 9110 section 10.2.3 Retry-After](https://www.rfc-editor.org/rfc/rfc9110#section-10.2.3)

## Related rules

- [Tell clients their rate limit](https://agentwranglers.se/playbook/api-design/reliability/rate-limit-headers) in API design

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/api-design/using-other-companies-apis/respect-their-limits">Agent Wranglers API design playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Send the same idempotency key when you retry a write](https://agentwranglers.se/playbook/api-design/using-other-companies-apis/outgoing-idempotency-keys)
- Next: [Decide what happens when a provider is down](https://agentwranglers.se/playbook/api-design/using-other-companies-apis/provider-outages)
- [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis)
