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
| Type | Description |
|---|---|
| RPM | Requests per minute limit |
| TPM | Tokens per minute limit |
| Concurrency | Limit on the number of requests processed simultaneously |
| Per-request context | Maximum input and output window allowed by the model |
| Token quota | Token quota or expiration time |
| User quota | Account balance, subscription benefits, or group quota |
| Channel quota | Upstream 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.
