-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Is your enhancement related to a problem? Provide a clear and concise description.
The current credential management relies primarily on:
- Static environment variables (e.g.,
OPENAI_API_KEY_1,GEMINI_API_KEY_1) set at deployment time. - The interactive credential tool (
python -m rotator_library.credential_tool) and TUI for initial setup. - Local file storage for OAuth tokens (
oauth_creds/) or manual export to environment variables for stateless deployments.
This works well for self-hosted local/VPS setups but creates significant friction when deploying to cloud/hosting platforms (Render, Railway, Vercel, Fly.io, etc.):
- The instance owner must manually collect, configure, and update all provider API keys and OAuth profiles upfront.
- OAuth flows are interactive (browser-based with callback ports), which are challenging or impossible in serverless/stateless environments without open ports or persistent storage.
- There is no built-in way for end-users of a publicly hosted instance to provide their own credentials (BYO keys/OAuth) for providers they have access to.
- Adding new keys or OAuth profiles requires redeployment, environment variable updates, or manual intervention, limiting flexibility for shared/public proxies.
Proposed Enhancement
Introduce dynamic runtime credential and OAuth profile management to complement the existing static methods, with the following features:
-
Runtime Addition/Updating via API or Web UI:
- Admin-protected endpoints (e.g.,
/admin/credentials/add,/admin/credentials/list) to add, update, or remove API keys and OAuth profiles without restart/redeploy. - Optional simple web dashboard (built on the existing TUI logic or a lightweight framework) for credential management.
- Admin-protected endpoints (e.g.,
-
User-Provided (BYO) Credentials:
- Support for clients to pass their own provider API keys via request headers (e.g.,
X-Provider-Key: sk-...for OpenAI) or query params, with fallback to server-configured keys. - Per-request OAuth token injection (e.g., via headers) for providers requiring it.
- Optional virtual key system (inspired by LiteLLM Proxy) where users can generate scoped keys tied to specific providers/models.
- Support for clients to pass their own provider API keys via request headers (e.g.,
-
Improved OAuth Handling for Hosted Deployments:
- Automatic token refresh using stored refresh tokens (without requiring interactive flows post-initial setup).
- Support for user-initiated OAuth flows via redirect URLs compatible with hosted environments (e.g., using the proxy's own domain as callback).
- Secure persistent storage option (e.g., optional SQLite/Redis backend for tokens, encrypted at rest).
-
Backward Compatibility & Security:
- Retain full support for existing
.env-based static configuration as the default. - Mix static (admin/global) and dynamic (user-provided) credentials with configurable precedence (e.g., prefer user-provided if present).
- Built-in safeguards: rate limiting/quota tracking per credential, audit logging, and role-based access (admin vs. user).
- Retain full support for existing
Use Cases & Benefits
- Public/shared hosted instances can support a wide range of providers without the owner needing to obtain/pay for every key.
- Users can bring their own high-limit/paid accounts for specific providers (e.g., Gemini paid tier, Anthropic, etc.).
- Easier multi-user/team deployments: members add their own credentials dynamically.
- Better suitability for serverless/cloud platforms where static env vars are limiting.
- Enhanced resilience: more keys available through community/user contributions without manual admin work.
Additional Notes
- Leverage existing LiteLLM integration and rotator_library for key rotation/failover.
- Start with API-key providers, then extend to OAuth-heavy ones (Gemini, Antigravity, iFlow).
- Consider optional database integration for persistence (while keeping in-memory/ephemeral as default).
- Security is critical—happy to discuss authentication methods (e.g., master key, JWT).
This would make the proxy much more flexible for hosted and multi-user scenarios while preserving its excellent local/self-hosted experience. Thanks for the great project! Open to feedback or helping with implementation details.