🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

API Rate Manager

by @chenghaifeng08-creator

Smart API rate limit manager with auto-retry, queue, and cost optimization. Prevents 429 errors and manages API quotas efficiently.

Versionv1.0.0
Installs1
πŸ’‘ Examples

Example 1: ClawHub Skill Installation

const { RateManager } = require('api-rate-manager');

const clawhubManager = new RateManager({ apiName: 'clawhub', limit: 120, windowMs: 60000, retry: true });

// Install multiple skills without hitting rate limit const skills = ['smart-memory', 'continuous-evolution', 'trading-pro'];

for (const skill of skills) { await clawhubManager.call(() => { return clawhub.install(skill); }); }

Example 2: Perplexity Search

const searchManager = new RateManager({
  apiName: 'perplexity',
  limit: 100,
  windowMs: 60000,
  retry: true,
  onLimitHit: (info) => {
    console.log(⏳ Waiting ${info.resetIn/1000}s for rate limit reset...);
  }
});

// Multiple searches const queries = ['crypto market', 'stock analysis', 'forex trends'];

const results = await searchManager.batch( queries.map(q => () => web_search({ query: q })) );

Example 3: OpenAI API

const openaiManager = new RateManager({
  apiName: 'openai',
  limit: 60,
  windowMs: 60000,
  retry: true,
  maxRetries: 3
});

// Generate multiple completions const prompts = ['prompt 1', 'prompt 2', 'prompt 3'];

const completions = await openaiManager.batch( prompts.map(p => () => openai.createCompletion({ prompt: p })) );


βš™οΈ Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiName | string | required | Name of the API | | limit | number | required | Max requests per window | | windowMs | number | required | Time window in milliseconds | | retry | boolean | true | Auto-retry on rate limit | | maxRetries | number | 5 | Maximum retry attempts | | queueSize | number | 100 | Max queued requests | | onLimitHit | function | null | Callback when limit hit | | onRetry | function | null | Callback on retry |


πŸ“‹ Tips & Best Practices

1. Know Your Limits

// Check API documentation for limits
const limits = {
  clawhub: { limit: 120, windowMs: 60000 },
  perplexity: { limit: 100, windowMs: 60000 },
  openai: { limit: 60, windowMs: 60000 }
};

2. Add Buffer

// Use 80-90% of limit to be safe
new RateManager({
  limit: 100,  // API limit is 120
  windowMs: 60000
});

3. Monitor Usage

// Check status before large batch
const status = manager.getStatus();
if (status.remaining < 10) {
  console.log('Low remaining requests, consider waiting');
}

4. Handle Failures Gracefully

const result = await manager.call(() => api.call());
if (!result) {
  console.log('Call failed after retries, skipping...');
}


View on ClawHub
TERMINAL
clawhub install api-rate-manager

πŸ§ͺ Use this skill with your agent

Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

πŸ” Can't find the right skill?

Search 60,000+ AI agent skills β€” free, no login needed.

Search Skills β†’