Rate limits
Separate throughput limits from spending caps and handle throttling with bounded retries.
Limit dimensions
Requests may encounter CanalAPI gateway limits, public-endpoint IP limits, and upstream model capacity limits. Programs sharing one public egress IP may share an IP-based limit. Actual limits depend on the endpoint and deployment configuration; do not assume every key offers adjustable RPM, TPM, or concurrency controls.
Reduce bursts and duplicate requests instead of creating more keys. A key's spending cap is separate from request throughput.
Response headers
Throttled responses may include these headers. Upstream headers can differ, and successful responses are not guaranteed to include them.
| Header | Purpose |
|---|---|
Retry-After | Wait time; CanalAPI's gateway uses seconds, while upstream services may use an HTTP date |
X-RateLimit-Limit | Current limit, when supplied |
X-RateLimit-Remaining | Remaining requests, when supplied |
Do not depend on an absent X-RateLimit-Reset or interpret missing headers as unlimited capacity.
Hitting a limit
Example gateway response; the wait time is illustrative:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 5
{
"error": {
"message": "Rate limit exceeded.",
"type": "rate_limit_exceeded",
"code": "2004"
}
}An upstream 429 may use different type and code values. Record the status, error type, and X-Request-Id, never the key.
Recommended handling
- Honor a valid
Retry-After. If it exceeds the application's total deadline, return the error instead. - Without a wait hint, use exponential backoff with jitter, such as roughly 1, 2, and 4 seconds with at most three additional attempts. This is an example client policy, not a server guarantee.
- Account for SDK retries rather than stacking unlimited loops. Set total time, attempt limits, and cancellation.
- Retry only suitable operations. Do not blindly replay partial streams, executed tools, or operations with unknown outcomes.
- For repeated 429s, reduce concurrency, queue, or pause work. Do not rotate keys to bypass limits.
Capacity tips
- Cap concurrency, stagger scheduled jobs, and deduplicate requests.
- Avoid unnecessarily long contexts and outputs; evaluate lighter models with your own examples.
- Streaming can display output sooner, but does not guarantee less processing time, cost, or concurrency usage.
- Track latency, 429 frequency, and retry counts. Contact support about sustained capacity needs.
Quotas
| Situation | Typical response | Action |
|---|---|---|
| Too many requests in a short period | 429 | Wait, reduce concurrency, retry within limits |
| Insufficient account balance | 402 / insufficient_balance | Check and resolve available credit |
| Key spending cap exhausted | 403 / api_key_quota_exhausted | Inspect this key's spending cap |
Waiting briefly does not fix balance or key-cap issues. Check subscriptions for period allowances and overage policies. For other error types, inspect the body and use error handling or connection troubleshooting.