route-claudecode
Version:
Advanced routing and transformation system for Claude Code outputs to multiple AI providers
51 lines • 1.66 kB
TypeScript
/**
* Enhanced Gemini Rate Limit Manager
* Intelligent 429 error handling with Round Robin key rotation and model fallback
* Project Owner: Jason Zhang
*/
interface KeyRotationResult {
apiKey: string;
model: string;
keyIndex: number;
fallbackApplied: boolean;
fallbackReason?: string;
}
/**
* Enhanced Gemini Rate Limit Manager - v2
*
* Features:
* - Prioritizes Key Rotation over Model Downgrade.
* - When a (Key, Model) combination gets a 429 error, it enters a 60-second cooldown.
* - If it fails again immediately after cooldown, it's permanently downgraded for that Key.
* - A model downgrade is only considered if ALL keys are in cooldown for the requested model.
*/
export declare class EnhancedRateLimitManager {
private apiKeys;
private keyModelState;
private providerId;
private modelFallbackConfig;
private config;
constructor(apiKeys: string[], providerId: string, config?: any);
/**
* Get available API key and model with intelligent fallback
*/
getAvailableKeyAndModel(requestedModel: string, requestId?: string): KeyRotationResult;
/**
* Report 429 error to update rate limit tracking
*/
report429Error(keyIndex: number, model: string, requestId?: string): void;
/**
* Zero Fallback Principle: No fallback models at provider level
*/
private getFallbackModels;
/**
* Get current rate limit status for all keys
*/
getStatus(): Record<string, any>;
/**
* Estimate token count for rate limiting
*/
estimateTokens(text: string): number;
}
export {};
//# sourceMappingURL=enhanced-rate-limit-manager.d.ts.map