Keyrot
Star

One pool.
Many keys.
Zero downtime.

API key rotation and multiplexing for TypeScript. Automatic rate limiting, quota tracking, and circuit breaker patterns.

Rate LimitingQuota TrackingCircuit BreakerAuto Failover

Get Started

Install keyrot and start managing your API keys in minutes.

Installation

npm install keyrot

Basic Usage

import { createKeyPool } from 'keyrot';

const pool = createKeyPool({
  keys: [
    { id: 'key-1', value: 'sk-xxx', quota: { type: 'monthly', limit: 10000 }, rps: 10 },
    { id: 'key-2', value: 'sk-yyy', quota: { type: 'unlimited' }, rps: 5 },
  ],
  isRateLimited: (res) => res.status === 429,
  isError: (res) => res.status >= 500,
});

// Execute requests through the pool
const response = await pool.execute(async (keyValue) => {
  return fetch('https://api.example.com/data', {
    headers: { Authorization: `Bearer ${keyValue}` },
  });
});

Automatic Failover

Seamlessly switches to available keys when one is rate-limited or fails.

Quota Tracking

Track monthly, yearly, or total quotas with automatic reset handling.

Health Monitoring

Real-time pool health status: healthy, degraded, critical, or exhausted.

Circuit Breaker

Automatic failure detection with configurable recovery thresholds.

Demo

Interact with a live key pool running entirely in your browser.

Initializing...
Key Pool
Real-time status of all API keys in the pool
Controls
Test pool behavior

Simulate Errors

Force rate limit

Force server error

Request Log
Recent API requests (0 recorded)

No requests yet

Click "Make Request" to start

Built with keyrot - API key rotation and multiplexing

Demo runs entirely in your browser - no server required