| name | castai-rate-limits |
| description | Handle CAST AI API rate limits with backoff and request queuing.
Use when hitting 429 errors, optimizing API call patterns,
or implementing rate-aware batch operations.
Trigger with phrases like "cast ai rate limit", "cast ai 429",
"cast ai throttle", "cast ai API limits".
|
| allowed-tools | Read, Write, Edit |
| version | 1.4.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kubernetes","cost-optimization","castai"] |
| compatibility | Designed for Claude Code |
CAST AI Rate Limits
Overview
The CAST AI REST API enforces rate limits per API key. The autoscaler agent communicates cluster state at 15-second intervals. For custom API integrations, implement exponential backoff and request queuing to avoid hitting limits.
Prerequisites
- CAST AI API key configured
- Understanding of the API endpoints you call
Rate Limit Behavior
| Aspect | Value |
|---|
| Rate limit scope | Per API key |
| Response on limit | HTTP 429 with Retry-After header |
| Agent sync interval | Every 15 seconds |
| Recommended polling | No more than once per 30 seconds |
Instructions
Step 1: Detect Rate Limits from Response Headers
async function castaiRequest(path: string): Promise<Response> {
const response = await fetch(`https://api.cast.ai${path}`, {
headers: { "X-API-Key": process.env.CASTAI_API_KEY! },
});
const remaining = response.headers.get("X-RateLimit-Remaining");
const reset = response.headers.get("X-RateLimit-Reset");
if (remaining) {
console.log(`Rate limit remaining: ${remaining}, resets: `);
}
(response. === ) {
retryAfter = (response..() ?? );
(retryAfter);
}
response;
}
{
() {
();
}
}