Skip to main content
All authenticated Swarms API responses include rate limit headers. These headers let you monitor your usage programmatically — build retry logic, display quota dashboards, or throttle requests before hitting limits.
Rate limit headers are included on every authenticated response, including error responses. You do not need to make a separate API call to check your quota.

Headers

Every response includes these headers:
HeaderTypeDescription
X-RateLimit-Limit-MinuteintegerMaximum requests allowed per minute for your tier
X-RateLimit-Remaining-MinuteintegerRequests remaining in the current minute window
X-RateLimit-Limit-DayintegerMaximum requests allowed per day for your tier
X-RateLimit-Remaining-DayintegerRequests remaining in the current day window
X-RateLimit-Resetunix timestampWhen the current minute window resets (seconds since epoch)
X-RateLimit-TierstringYour current tier: free or premium
Retry-AfterintegerSeconds until the rate limit resets. Only present on 429 responses.

Example Response Headers

HTTP/1.1 200 OK
Content-Type: application/json
X-RateLimit-Limit-Minute: 100
X-RateLimit-Remaining-Minute: 94
X-RateLimit-Limit-Day: 1200
X-RateLimit-Remaining-Day: 1047
X-RateLimit-Reset: 1713700800
X-RateLimit-Tier: free

Example 429 Response

When you exceed a rate limit, the response includes a Retry-After header:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit-Minute: 100
X-RateLimit-Remaining-Minute: 0
X-RateLimit-Limit-Day: 1200
X-RateLimit-Remaining-Day: 1100
X-RateLimit-Reset: 1713700860
X-RateLimit-Tier: free
Retry-After: 42
{
  "detail": "Rate limit exceeded for minute window(s). Upgrade to Premium for increased limits (2,000/min, 10,000/hour, 100,000/day) at https://swarms.world/platform/account for just $100/month."
}

Limits by Tier

FreePremium
Per minute1002,000
Per hour5010,000
Per day1,200100,000
Tokens per agent200,0002,000,000

Code Examples

import os
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/v1/agent/completions",
    headers=headers,
    json={
        "agent_config": {
            "agent_name": "test",
            "model_name": "gpt-4o",
            "system_prompt": "You are helpful.",
            "max_loops": 1,
        },
        "task": "Say hello.",
    },
)

# Read rate limit headers
remaining = int(response.headers["X-RateLimit-Remaining-Minute"])
limit = int(response.headers["X-RateLimit-Limit-Minute"])
tier = response.headers["X-RateLimit-Tier"]

print(f"Tier: {tier} | {remaining}/{limit} requests remaining this minute")

Retry Logic

Use the Retry-After header to implement automatic retry on 429 responses:
import time
import requests

def call_with_retry(url, headers, payload, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(url, headers=headers, json=payload)

        if response.status_code == 429:
            retry_after = int(response.headers.get("Retry-After", 60))
            print(f"Rate limited. Retrying in {retry_after}s...")
            time.sleep(retry_after)
            continue

        return response

    raise Exception("Max retries exceeded")

Best Practices

  1. Check Remaining-Minute before sending requests — if it’s low, slow down or queue requests.
  2. Use Retry-After on 429s — don’t guess the wait time, the header tells you exactly how long.
  3. Log your tier — use X-RateLimit-Tier to confirm your account is on the expected plan.
  4. Build dashboards — track Remaining-Day over time to understand your usage patterns and plan upgrades.