Anima Rate Limits
Overview
Anima API has per-minute rate limits on code generation. Each generateCode call processes one Figma node through AI — it's compute-intensive and rate-limited accordingly.
Rate Limit Tiers
| Tier |
Generations/min |
Concurrent |
Notes |
| Partner (standard) |
10 |
2 |
Most common |
| Enterprise |
30 |
5 |
Custom agreement |
Instructions
Step 1: Throttled Generator with Bottleneck
// src/anima/throttled-generator.ts
import Bottleneck from 'bottleneck';
import { Anima } from '@animaapp/anima-sdk';
const limiter = new Bottleneck({
maxConcurrent: 2,
minTime: 6000, // 10 per minute = 1 every 6 seconds
reservoir: 10,
reservoirRefreshInterval: 60000,
reservoirRefreshAmount: 10,
});
const anima = new Anima({ auth: { token: process.env.ANIMA_TOKEN! } });
async function throttledGenerate(params: any) {
return limiter.schedule(() => anima.generateCode(params));
}
// Batch generate with automatic throttling
async function batchGenerate(nodeIds: string[], settings: any) {
const results = [];
for (const nodeId of nodeIds) {
const result = await throttledGenerate({
fileKey: process.env.FIGMA_FILE_KEY!,
figmaToken: process.env.FIGMA_TOKEN!,
nodesId: [nodeId],
settings,
});
results.push({ nodeId, files: result.files });
console.log(`Generated ${nodeId}: ${result.files.length} files`);
}
return results;
}
export { throttledGenerate, batchGenerate };
Step 2: 429 Retry Handler
async function generateWithRetry(anima: Anima, params: any, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await anima.generateCode(params);
} catch (err: any) {
if (err.response?.status !== 429 || attempt === maxRetries) throw err;
const wait = Math.min(60000, 10000 * attempt); // Wait up to 60s
console.log(`Rate limited — waiting ${wait / 1000}s`);
await new Promise(r => setTimeout(r, wait));
}
}
}
Output
- Bottleneck-throttled code generation matching API limits
- Batch generator for design system-scale operations
- 429 retry handler with progressive backoff
Resources
Next Steps
For security practices, see anima-security-basics.
1---2name: anima-rate-limits3description: |4 Implement rate limiting for Anima API code generation requests.5 Use when batching component generation, handling rate limit errors,6 or optimizing API throughput for large design systems.7 Trigger: "anima rate limit", "anima throttling", "anima batch generation".8allowed-tools: Read, Write, Edit, Bash(npm:*)9version: 1.0.010license: MIT11author: Jeremy Longshore <jeremy@intentsolutions.io>12tags: [saas, design, figma, anima, rate-limiting]13compatible-with: claude-code14---1516# Anima Rate Limits1718## Overview1920Anima API has per-minute rate limits on code generation. Each `generateCode` call processes one Figma node through AI — it's compute-intensive and rate-limited accordingly.2122## Rate Limit Tiers2324| Tier | Generations/min | Concurrent | Notes |25|------|----------------|------------|-------|26| Partner (standard) | 10 | 2 | Most common |27| Enterprise | 30 | 5 | Custom agreement |2829## Instructions3031### Step 1: Throttled Generator with Bottleneck3233```typescript34// src/anima/throttled-generator.ts35import Bottleneck from 'bottleneck';36import { Anima } from '@animaapp/anima-sdk';3738const limiter = new Bottleneck({39 maxConcurrent: 2,40 minTime: 6000, // 10 per minute = 1 every 6 seconds41 reservoir: 10,42 reservoirRefreshInterval: 60000,43 reservoirRefreshAmount: 10,44});4546const anima = new Anima({ auth: { token: process.env.ANIMA_TOKEN! } });4748async function throttledGenerate(params: any) {49 return limiter.schedule(() => anima.generateCode(params));50}5152// Batch generate with automatic throttling53async function batchGenerate(nodeIds: string[], settings: any) {54 const results = [];55 for (const nodeId of nodeIds) {56 const result = await throttledGenerate({57 fileKey: process.env.FIGMA_FILE_KEY!,58 figmaToken: process.env.FIGMA_TOKEN!,59 nodesId: [nodeId],60 settings,61 });62 results.push({ nodeId, files: result.files });63 console.log(`Generated ${nodeId}: ${result.files.length} files`);64 }65 return results;66}6768export { throttledGenerate, batchGenerate };69```7071### Step 2: 429 Retry Handler7273```typescript74async function generateWithRetry(anima: Anima, params: any, maxRetries = 3) {75 for (let attempt = 1; attempt <= maxRetries; attempt++) {76 try {77 return await anima.generateCode(params);78 } catch (err: any) {79 if (err.response?.status !== 429 || attempt === maxRetries) throw err;80 const wait = Math.min(60000, 10000 * attempt); // Wait up to 60s81 console.log(`Rate limited — waiting ${wait / 1000}s`);82 await new Promise(r => setTimeout(r, wait));83 }84 }85}86```8788## Output8990- Bottleneck-throttled code generation matching API limits91- Batch generator for design system-scale operations92- 429 retry handler with progressive backoff9394## Resources9596- [Anima API Docs](https://docs.animaapp.com/docs/anima-api)97- [Bottleneck npm](https://www.npmjs.com/package/bottleneck)9899## Next Steps100101For security practices, see `anima-security-basics`.102