gemini-api-rate-limiting
CommunityPrevent Gemini API errors, ensure smooth operations.
Software Engineering#error handling#API integration#rate limiting#Gemini API#API management#exponential backoff#API queue
AuthorBerryKuipers
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Making many simultaneous calls to the Gemini API can quickly lead to 429 RESOURCE_EXHAUSTED errors, degrading user experience and wasting API quota. This Skill provides proven patterns to manage API call rates effectively.
Core Features & Use Cases
- Sequential Asynchronous Queue: Implements a
for...ofloop pattern to process API calls one at a time with strategic delays, preventing burst traffic. - API Timeouts: Adds timeouts to API calls to prevent hung requests and provide graceful error handling.
- Exponential Backoff: Provides a robust retry mechanism with exponential backoff for
429errors, ensuring resilience. - Use Case: When generating multiple AI-powered images or processing bulk data via the Gemini API, use this Skill to queue requests, manage delays, and handle errors gracefully, ensuring smooth operation without hitting rate limits.
Quick Start
Example: Process image generation sequentially with delays
async function processImageQueue(characters) {
for (const character of characters) {
await generateImage(character);
await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay
}
}
Example: Call API with exponential backoff
async function callWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try { return await fn(); }
catch (error) {
if (error.status === 429 && i < maxRetries - 1) {
const delayMs = Math.pow(2, i) * 1000;
await new Promise(resolve => setTimeout(resolve, delayMs));
} else { throw error; }
}
}
}
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: gemini-api-rate-limiting Download link: https://github.com/BerryKuipers/claude-code-toolkit/archive/main.zip#gemini-api-rate-limiting Please download this .zip file, extract it, and install it in the .claude/skills/ directory.