Documentation

API Reference

Limits

Understanding API rate limits and how they apply to your A4F account.

Checking Rate Limits and Plan Status

To check the rate limits applicable to your API key, your current plan, and other usage details, you can make a GET request to the A4F /v1/usage endpoint. This endpoint provides a comprehensive overview of your account status.

Your A4F API key must be included in the Authorization header as a Bearer token.

GET https://api.a4f.co/v1/usage
import requests
import json
A4F_API_KEY = "A4F_API_KEY"
A4F_USAGE_URL = "https://api.a4f.co/v1/usage"
headers = {
"Authorization": f"Bearer {A4F_API_KEY}",
}
try:
response = requests.get(A4F_USAGE_URL, headers=headers)
response.raise_for_status()
usage_data = response.json()
print(json.dumps(usage_data, indent=2))
except requests.exceptions.RequestException as e:
print(f"Request to check limits failed: {e}")
except json.JSONDecodeError:
print("Failed to decode JSON response from usage endpoint.")
except Exception as e:
print(f"An error occurred: {e}")

Response Format from /v1/usage

If you submit a valid API key, you will get a JSON response. The structure of this response is detailed by our Python backend. The Dashboard page on this website consumes data from /api/dashboard-stats, which in turn fetches and processes data from /v1/usage.

An illustrative example of the data you might receive is shown below. Key fields related to limits include account_information.plan and rate_limits (containing rpm and rpd).

{
"account_information": {
"username": "your_username",
"plan": "pro",
"is_enabled": true,
"api_key": "ddc-paid-xxxx...yyyy",
// ... other account details
},
"subscription_details": {
"creation_date": "2024-05-01T10:00:00Z",
"total_validity_days": 30,
"remaining_days": 25,
"timeline_history": [
{ "plan": "free", "activated_at": "2024-05-01T10:00:00Z" },
{ "plan": "pro", "activated_at": "2024-05-06T12:00:00Z" }
]
},
"billing_information": {
"total_paid": 25.00,
"cumulative_token_cost": 0.12
},
"rate_limits": {
"rpm": 10,
"rpd": null
},
"usage_statistics": {
"total_requests": {
"count": 1250,
"successful_requests": 1240
},
"token_consumption": {
"combined": {
"input_tokens": 500000,
"output_tokens": 150000,
"total_tokens": 650000
}
}
},
"model_usage": {
"provider-1/chatgpt-4o-latest": {
"total_requests": 500,
"successful_requests": 498,
},
"provider-3/claude-3-haiku": {
"total_requests": 750,
"successful_requests": 742,
}
}
}

Plan-Based Limits

A4F's rate limits are primarily determined by your subscription plan. Each plan (e.g., Free, Basic, Pro) has specific RPM and RPD allowances.

  • Free Plan: Typically has the most restrictive limits (e.g., 5 RPM, 100 RPD). Designed for testing and light usage.
  • Basic Plan: Offers higher RPM (e.g., 10 RPM) and usually no RPD limit (or a very high one) for paid models. Suitable for individual developers and moderate usage.
  • Pro Plan: Provides the same RPM as Basic (e.g., 10 RPM) but with access to all SOTA models, full context windows, and priority support. Designed for power users and applications requiring consistent access to top-tier models.

Please refer to our Pricing Page for the most up-to-date details on the limits associated with each plan.

If you exceed your plan's rate limits, the A4F API will return a 429 Too Many Requests HTTP status code. You should implement appropriate retry logic with backoff in your application to handle these situations.

DDoS Protection and Fair Use

A4F employs DDoS protection mechanisms (e.g., via Cloudflare) to safeguard our services. Requests that dramatically exceed reasonable usage patterns or appear abusive may be blocked by these protective layers, even if they are within your plan's nominal RPM/RPD limits.

We expect users to adhere to fair use principles. Persistently hitting rate limits or engaging in activity that degrades service quality for other users may result in temporary or permanent suspension of API access.

Plan Validity and API Key Status

If your subscription plan expires (e.g., end of billing cycle for a paid plan without renewal), your rate limits and model access may revert to Free tier levels, or your API key might be disabled if no valid plan is active.

The /v1/usage endpoint (and your Dashboard) will indicate your current plan, its validity (remaining_days in subscription_details), and the status of your API key (is_enabled in account_information).

If your API key is disabled (is_enabled: false) or your plan has expired, you will likely receive 401 Unauthorized or 403 Forbidden errors. Please ensure your subscription is active and your payment information is up to date to maintain uninterrupted service.

Was this page helpful?