ID

ideogram-rate-limits

Implements exponential backoff and request queuing to manage Ideogram's concurrent request limits.

Install

mkdir -p .claude/skills/ideogram-rate-limits && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2738" && unzip -o skill.zip -d .claude/skills/ideogram-rate-limits && rm skill.zip

Installs to .claude/skills/ideogram-rate-limits

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Implement Ideogram rate limiting, backoff, and request queuing patterns.
72 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Implement exponential backoff with jitter for API retries
  • Control concurrency of Ideogram API requests using a queue
  • Apply a token bucket algorithm for client-side rate limiting
  • Process batches of Ideogram requests with progress tracking
  • Handle HTTP 429 rate limit errors

How it works

The skill provides code for exponential backoff with jitter to retry failed requests, a concurrency-limited queue to manage in-flight requests, and a token bucket for client-side rate limiting. These mechanisms prevent exceeding Ideogram's API limits.

Inputs & outputs

You give it
Ideogram API requests (e.g., image generation prompts)
You get back
Processed Ideogram API responses, managed within rate limits

When to use ideogram-rate-limits

  • Implement retry logic for Ideogram
  • Optimize image generation throughput
  • Handle API rate limit errors
  • Manage concurrent API requests

About this skill

Ideogram Rate Limits

Overview

Handle Ideogram's rate limits with exponential backoff, request queuing, and concurrency control. Ideogram enforces a default limit of 10 in-flight requests (concurrent, not per-minute). Image generation takes 5-15 seconds per call, so this limit can be hit quickly during batch operations.

Prerequisites

  • IDEOGRAM_API_KEY configured
  • Understanding of async patterns
  • p-queue npm package (optional, for queue-based approach)

Ideogram Rate Limit Model

AspectDetail
TypeConcurrent in-flight requests
Default limit10 simultaneous requests
Error codeHTTP 429
Retry headerNot guaranteed -- use exponential backoff
Higher limitsContact [email protected]
Generation time5-15s per image (varies by model/resolution)

Instructions

Step 1: Exponential Backoff with Jitter

async function withBackoff<T>(
  operation: () => Promise<T>,
  config = { maxRetries: 5, baseMs: 1000, maxMs: 30000, jitterMs: 500 }
): Promise<T> {
  for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
    try {
      return await operation();
    } catch (err: any) {
      if (attempt === config.maxRetries) throw err;

      const status = err.status ?? err.response?.status;
      // Only retry on 429 (rate limited) or 5xx (server error)
      if (status && status !== 429 && status < 500) throw err;

      const exponential = config.baseMs * Math.pow(2, attempt);
      const jitter = Math.random() * config.jitterMs;
      const delay = Math.min(exponential + jitter, config.maxMs);

      console.warn(`Rate limited (attempt ${attempt + 1}/${config.maxRetries}). Waiting ${delay.toFixed(0)}ms`);
      await new Promise(r => setTimeout(r, delay));
    }
  }
  throw new Error("Unreachable");
}

Step 2: Concurrency-Limited Queue

import PQueue from "p-queue";

// Ideogram allows 10 in-flight -- use 8 to leave headroom
const ideogramQueue = new PQueue({ concurrency: 8 });

async function queuedGenerate(prompt: string, options: any = {}) {
  return ideogramQueue.add(async () => {
    const response = await fetch("https://api.ideogram.ai/generate", {
      method: "POST",
      headers: {
        "Api-Key": process.env.IDEOGRAM_API_KEY!,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        image_request: { prompt, model: "V_2", ...options },
      }),
    });

    if (response.status === 429) {
      throw Object.assign(new Error("Rate limited"), { status: 429 });
    }
    if (!response.ok) throw new Error(`Generate failed: ${response.status}`);
    return response.json();
  });
}

// Process 50 prompts safely -- queue manages concurrency
const prompts = Array.from({ length: 50 }, (_, i) => `Design variant ${i + 1}`);
const results = await Promise.all(prompts.map(p => queuedGenerate(p)));

Step 3: Token Bucket Rate Limiter

class TokenBucket {
  private tokens: number;
  private lastRefill: number;

  constructor(
    private maxTokens: number = 10,
    private refillRate: number = 1, // tokens per second
  ) {
    this.tokens = maxTokens;
    this.lastRefill = Date.now();
  }

  async acquire(): Promise<void> {
    this.refill();
    if (this.tokens > 0) {
      this.tokens--;
      return;
    }
    // Wait for next token
    const waitMs = (1 / this.refillRate) * 1000;
    await new Promise(r => setTimeout(r, waitMs));
    this.refill();
    this.tokens--;
  }

  private refill() {
    const now = Date.now();
    const elapsed = (now - this.lastRefill) / 1000;
    this.tokens = Math.min(this.maxTokens, this.tokens + elapsed * this.refillRate);
    this.lastRefill = now;
  }
}

const bucket = new TokenBucket(10, 1);

async function throttledGenerate(prompt: string) {
  await bucket.acquire();
  return queuedGenerate(prompt);
}

Step 4: Batch with Progress Tracking

async function batchGenerate(
  prompts: string[],
  onProgress?: (done: number, total: number) => void
) {
  const results: any[] = [];
  const errors: { prompt: string; error: Error }[] = [];

  for (let i = 0; i < prompts.length; i++) {
    try {
      const result = await withBackoff(() => queuedGenerate(prompts[i]));
      results.push(result);
    } catch (err) {
      errors.push({ prompt: prompts[i], error: err as Error });
    }
    onProgress?.(i + 1, prompts.length);
  }

  console.log(`Batch complete: ${results.length} success, ${errors.length} failed`);
  return { results, errors };
}

Error Handling

ScenarioDetectionAction
429 receivedHTTP statusExponential backoff + retry
All retries exhaustedMax attempts reachedLog and skip, continue batch
Burst spikeQueue depth > 20Pause new submissions
Credits exhausted402 statusAlert, stop batch immediately

Output

  • Reliable API calls with automatic retry on 429
  • Concurrency-controlled request queue
  • Token bucket for sustained throughput
  • Batch processing with progress and error tracking

Resources

Next Steps

For security configuration, see ideogram-security-basics.

When not to use it

  • When Ideogram's default limit of 10 in-flight requests is sufficient

Prerequisites

`IDEOGRAM_API_KEY` configured`p-queue` npm package (optional, for queue-based approach)

Limitations

  • Ideogram enforces a default limit of 10 in-flight requests
  • Image generation takes 5-15 seconds per call
  • Higher limits require contacting Ideogram

How it compares

This skill provides specific code implementations for handling Ideogram's concurrent in-flight request rate limit, unlike a generic retry mechanism that might not account for the specific limit type.

Compared to similar skills

ideogram-rate-limits side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
ideogram-rate-limits (this skill)227dReviewIntermediate
groq-performance-tuning127dNo flagsIntermediate
openrouter-streaming-setup127dReviewIntermediate
firecrawl-reliability-patterns327dReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

groq-performance-tuning

jeremylongshore

Optimize Groq API performance with caching, batching, and connection pooling. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Groq integrations. Trigger with phrases like "groq performance", "optimize groq", "groq latency", "groq caching", "groq slow", "groq batch".

111

openrouter-streaming-setup

jeremylongshore

Implement streaming responses with OpenRouter. Use when building real-time chat interfaces or reducing time-to-first-token. Trigger with phrases like 'openrouter streaming', 'openrouter sse', 'stream response', 'real-time openrouter'.

111

firecrawl-reliability-patterns

jeremylongshore

Implement FireCrawl reliability patterns including circuit breakers, idempotency, and graceful degradation. Use when building fault-tolerant FireCrawl integrations, implementing retry strategies, or adding resilience to production FireCrawl services. Trigger with phrases like "firecrawl reliability", "firecrawl circuit breaker", "firecrawl idempotent", "firecrawl resilience", "firecrawl fallback", "firecrawl bulkhead".

36

linear-rate-limits

jeremylongshore

Handle Linear API rate limiting and quotas effectively. Use when dealing with rate limit errors, implementing throttling, or optimizing API usage patterns. Trigger with phrases like "linear rate limit", "linear throttling", "linear API quota", "linear 429 error", "linear request limits".

09

generating-grpc-services

jeremylongshore

Generate gRPC service definitions, stubs, and implementations from Protocol Buffers. Use when creating high-performance gRPC services. Trigger with phrases like "generate gRPC service", "create gRPC API", or "build gRPC server".

13

perplexity-performance-tuning

jeremylongshore

Optimize Perplexity API performance with caching, batching, and connection pooling. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Perplexity integrations. Trigger with phrases like "perplexity performance", "optimize perplexity", "perplexity latency", "perplexity caching", "perplexity slow", "perplexity batch".

13

Search skills

Search the agent skills registry