Skip to content
Skillv1.0.0

anima-rate-limits

Implement rate limiting for Anima API code generation requests. Use when batching component generation, handling rate limit errors, or optimizing API throughput for large design systems. Trigger: "ani

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/anima-rate-limits/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill anima-rate-limits. Copyright stays with the author (MIT).

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

Prerequisites

  • Confirm the account's current generation quota and concurrency contract before choosing reservoir, reservoirRefreshAmount, or maxConcurrent; treat the table above as a starting point, not authorization to exceed a plan.
  • Store ANIMA_TOKEN, FIGMA_TOKEN, and FIGMA_FILE_KEY in the runtime secret manager or injected environment, and verify that the token has only the scopes required for the selected file. Never put tokens in source, fixtures, logs, generated receipts, or retry payloads.
  • Define an explicit allowlist of Figma files and node IDs, a bounded batch size, a maximum retry budget, and an approved output directory. Use synthetic or sandbox designs for load tests and confirm that generated output contains no customer data before persisting it.
  • Install the pinned SDK and Bottleneck versions, and decide whether a generation is safe to repeat. If the upstream operation is not idempotent, persist a redacted request fingerprint and resume only the failed node IDs.

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));
    }
  }
}

Error Handling

  • For HTTP 429, honor a bounded Retry-After value when present; otherwise use exponential backoff with jitter and let the limiter continue to enforce the account-wide reservoir. Do not create a second uncoordinated retry loop around the same request.
  • Do not retry 401/403 authentication or permission failures, invalid node/file parameters, or policy rejections. Stop the batch, report the node ID and redacted status, and repair credentials or scope before resuming.
  • Retry only bounded transient 5xx and network failures. Cap attempts and total elapsed time, cancel queued work after the budget is exhausted, and preserve the successful results separately from failed node IDs so a resume cannot regenerate the whole batch accidentally.
  • Treat timeout, process restart, and partial writes as ambiguous outcomes: check the request fingerprint or cache before resubmitting, write output atomically, and quarantine incomplete files. Logs and receipts may contain counts, status classes, and hashes, but not tokens, design contents, user identifiers, or generated source.
  • Alert when the observed rate, queue depth, quota remaining, or failure ratio crosses the configured threshold. A human must approve any change to concurrency or quota settings; rollback means restoring the last known-good limiter configuration and draining queued work.

Examples

For a sandbox batch, keep the work bounded and make the outcome auditable without exposing design data:

const nodeIds = ['synthetic-card', 'synthetic-button'];
const receipt = {
  batchId: 'sandbox-2026-01-15-a',
  requested: nodeIds.length,
  succeeded: 0,
  failed: 0,
  contactsExported: 0,
};

for (const nodeId of nodeIds) {
  try {
    await throttledGenerate({ fileKey: process.env.FIGMA_FILE_KEY, nodesId: [nodeId], settings });
    receipt.succeeded++;
  } catch (error) {
    receipt.failed++;
    // Store only a redacted status and node fingerprint; never serialize `error` or source.
  }
}
console.log(JSON.stringify({ ...receipt, tokenPresent: Boolean(process.env.ANIMA_TOKEN) }));

An acceptable completion receipt is requested=2; succeeded=2; failed=0; contacts_exported=0 with the sandbox ID and limiter settings recorded separately. A production batch should use the same controls, a reviewed allowlist, and an owner-approved change record before increasing concurrency.

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.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-anima-rate-limits/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-anima-rate-limits.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-anima-rate-limits",
  "kind": "skill",
  "name": "anima-rate-limits",
  "description": "Implement rate limiting for Anima API code generation requests. Use when batching component generation, handling rate limit errors, or optimizing API throughput for large design systems. Trigger: \"anima rate limit\", \"anima throttling\", \"anima batch generation\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "design",
      "figma",
      "anima",
      "rate-limiting",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Implement rate limiting for Anima API code generation requests. Use when batching component generation, handling rate limit errors, or optimizing API throughput for large design systems. Trigger: \"anima rate limit\", \"anima throttling\", \"anima batch generation\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/anima-rate-limits/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/anima-rate-limits/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/anima-rate-limits/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(npm:*)"
    ],
    "license": "MIT"
  },
  "instructions": "# Anima Rate Limits\n\n## Overview\n\nAnima 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.\n\n## Rate Limit Tiers\n\n| Tier | Generations/min | Concurrent | Notes |\n|------|----------------|------------|-------|\n| Partner (standard) | 10 | 2 | Most common |\n| Enterprise | 30 | 5 | Custom agreement |\n\n## Prerequisites\n\n- Confirm the account's current generation quota and concurrency contract before choosing `reservoir`, `reservoirRefreshAmount`, or `maxConcurrent`; treat the table abo",
  "cost": {
    "context_tokens": 1466
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-anima-rate-limits/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.