Skip to content

Limits and Performance Optimization ​

The limits of CloudAIKit may come from users, tokens, models, channels, systems, and upstream service providers. Performance optimization can also reduce request costs, minimize context waste, and avoid unnecessary retry storms.

Common Limits ​

TypeDescription
RPMRequests per minute limit
TPMTokens per minute limit
ConcurrencyLimit on the number of requests processed simultaneously
Per-request contextMaximum input and output window allowed by the model
Token quotaToken quota or expiration time
User quotaAccount balance, subscription benefits, or group quota
Channel quotaUpstream key balance, rate limits, or availability

Optimization Recommendations ​

  • Minimize system prompts and historical messages; send only the context required for the current request.
  • Summarize, chunk, or retrieve long documents before calling a large language model.
  • Cache results that can be cached at the application layer.
  • Use streaming output to improve perceived latency.
  • Use exponential backoff for 429 and 5xx responses; do not retry at high frequency immediately.
  • Set separate token quotas, low-priority channels, and concurrency limits for batch tasks.

Fallback Strategies ​

Production systems should prepare a primary model, a backup model, and an error fallback. When the primary channel times out, the upstream service returns a 5xx error, or rate limiting is triggered, you can switch to a lower-cost model, shorten the context, disable non-critical tool calls, or prompt the user to try again later.

Retry Recommendations ​

Use exponential backoff with an upper limit, such as waiting 1 second, 2 seconds, and 4 seconds, while setting limits on the total number of retries and total elapsed time. Responses with status codes 400, 401, 403, and 404 usually indicate request or permission issues and should not be retried automatically. For 429, 502, 503, and 504 responses, retry only after confirming that the request is safe to retry.