CanalAPI
Developer Guide

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.

HeaderPurpose
Retry-AfterWait time; CanalAPI's gateway uses seconds, while upstream services may use an HTTP date
X-RateLimit-LimitCurrent limit, when supplied
X-RateLimit-RemainingRemaining 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.

  1. Honor a valid Retry-After. If it exceeds the application's total deadline, return the error instead.
  2. 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.
  3. Account for SDK retries rather than stacking unlimited loops. Set total time, attempt limits, and cancellation.
  4. Retry only suitable operations. Do not blindly replay partial streams, executed tools, or operations with unknown outcomes.
  5. 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

SituationTypical responseAction
Too many requests in a short period429Wait, reduce concurrency, retry within limits
Insufficient account balance402 / insufficient_balanceCheck and resolve available credit
Key spending cap exhausted403 / api_key_quota_exhaustedInspect 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.

On this page