How mirrowel/llm-api-key-proxy works
The product combines a self-hosted OpenAI/Anthropic-compatible proxy with a reusable provider-rotation and resilience library. The main workflow is client request → proxy endpoint → rotating client → credential selection and limit checks → provider API → compatible response. Usage tracking, model metadata, and quota controls support that workflow. Some wiring is inferred from documented responsibilities and the tree; unsampled implementation details and uncertain links are omitted.
Main entry points: rotating_client.py Rotating Client · manager.py Usage Manager · main.py Proxy Server · executor.py Request Executor
Components 22
Proxy API
- Proxy Server
src/proxy_app/main.py - OpenAI Endpoint
src/proxy_app/main.py - Anthropic Endpoints
src/proxy_app/main.py - Proxy Utilities
src/proxy_app
Request Resilience
- Anthropic Translation
src/rotator_library/anthropic_compat/translator.py - Rotating Client
src/rotator_library/client/rotating_client.py - Request Executor
src/rotator_library/client/executor.py - Stream Retry
src/rotator_library/client/stream_retry_policy.py - Request Transforms
src/rotator_library/client/transforms.py
Provider Integrations
- Provider Factory
src/rotator_library/provider_factory.py - Provider Plugins
src/rotator_library/providers - LiteLLM Providers
src/rotator_library/litellm_providers.py - LLM Provider APIs
Usage Governance
- Usage Manager
src/rotator_library/usage/manager.py - Credential Selection
src/rotator_library/usage/selection/engine.py - Limit Checks
src/rotator_library/usage/limits/engine.py - Usage Tracking
src/rotator_library/usage/tracking/engine.py - Usage State
src/rotator_library/usage/persistence/storage.py
Model Intelligence
- Model Registry
src/rotator_library/model_info_service.py - Model Catalogs
- Model Definitions
src/rotator_library/model_definitions.py
Other components
- API Client
Connections 21
- API Client → OpenAI Endpoint: sends chat
- API Client → Anthropic Endpoints: sends messages
- OpenAI Endpoint → Proxy Server: handled by
- Anthropic Endpoints → Proxy Server: handled by
- Proxy Server → Rotating Client: dispatches requests
- Proxy Server → Model Registry: queries metadata
- Anthropic Endpoints → Anthropic Translation: translates format
- Rotating Client → Request Executor: delegates requests
- Request Executor → Stream Retry: applies retries
- Request Executor → Request Transforms: transforms requests
- Rotating Client → Provider Factory: resolves provider
- Provider Factory → Provider Plugins: creates provider
- Provider Plugins → LLM Provider APIs: calls provider
- LiteLLM Providers → LLM Provider APIs: supports provider calls
- Rotating Client → Usage Manager: manages credentials
- Usage Manager → Credential Selection: selects credential
- Credential Selection → Limit Checks: checks availability
- Usage Manager → Usage Tracking: records usage
- Usage Manager → Usage State: loads and saves
- Model Registry → Model Catalogs: fetches metadata
- Model Registry → Model Definitions: uses definitions