[PR #14046] [CLOSED] feat(api-keys): implement multi-API key management with selection str… #62223

Closed
opened 2026-05-06 06:13:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/14046
Author: @abdalrohman
Created: 5/19/2025
Status: Closed

Base: devHead: dev


📝 Commits (4)

  • 297f345 feat(api-keys): implement multi-API key management with selection strategies
  • 2caae01 fix(ui): resolve TypeScript type assertion issue in ApiKeyManager component
  • 6254608 fix(components): Resolve UI issues with API key management and i18n
  • e5b0519 Merge branch 'open-webui:dev' into dev

📊 Changes

7 files changed (+1011 additions, -15 deletions)

View changed files

📝 backend/open_webui/env.py (+1 -0)
📝 backend/open_webui/routers/openai.py (+148 -5)
backend/open_webui/utils/api_key_selection.py (+266 -0)
docs/api-key-management.md (+127 -0)
📝 src/lib/components/AddConnectionModal.svelte (+78 -10)
src/lib/components/common/ApiKeyManager.svelte (+153 -0)
src/lib/utils/apiKeySelection.ts (+238 -0)

📄 Description

implement multi-API key management with selection strategies

Overview

This PR introduces multi-API key management system for Open WebUI, allowing users to configure multiple API keys for providers and select between different key selection strategies.

Key Features

  • Add API key selection utility in both TypeScript and Python with consistent implementations
  • Implement four key selection strategies:
    • Random: Selects a random key for each request
    • Round-Robin: Cycles through keys in sequence
    • Least Recently Used (LRU): Selects the key that was used least recently
    • Weighted: Selects keys based on assigned weights
  • Create ApiKeyManager component for the UI to manage multiple keys
  • Update OpenAI router to support multiple API keys with strategy-based selection
  • Add comprehensive documentation for the API key management feature

Technical Implementation

  • In-memory caching system to optimize key selection performance
  • Configurable TTL for cached selections
  • Key validation support with fallback mechanisms
  • Debug logging with masked API keys for security
  • Consistent API between frontend and backend implementations

Status: Initial Implementation

This PR represents the initial implementation of the multi-API key management feature. While functional, it requires further work before being considered production-ready:

Future Enhancements

  • Integration with other providers beyond OpenAI
  • Performance optimization for high-volume API requests
  • Additional selection strategies based on rate limits and quotas
  • Enhanced error handling and fallback mechanisms
  • Comprehensive test coverage
  • UI improvements for better user experience

We welcome feedback and contributions to help evolve this feature into a robust solution for the Open WebUI ecosystem.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/14046 **Author:** [@abdalrohman](https://github.com/abdalrohman) **Created:** 5/19/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (4) - [`297f345`](https://github.com/open-webui/open-webui/commit/297f345f14356614f7edbf7e54eebdac307dd695) feat(api-keys): implement multi-API key management with selection strategies - [`2caae01`](https://github.com/open-webui/open-webui/commit/2caae0164ad17ccc78b428a265d1549b53ea59e2) fix(ui): resolve TypeScript type assertion issue in ApiKeyManager component - [`6254608`](https://github.com/open-webui/open-webui/commit/625460810fe06eea0982d88bbfaea04808481703) fix(components): Resolve UI issues with API key management and i18n - [`e5b0519`](https://github.com/open-webui/open-webui/commit/e5b051940edb054c9708bd5771a6266380d85d82) Merge branch 'open-webui:dev' into dev ### 📊 Changes **7 files changed** (+1011 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/env.py` (+1 -0) 📝 `backend/open_webui/routers/openai.py` (+148 -5) ➕ `backend/open_webui/utils/api_key_selection.py` (+266 -0) ➕ `docs/api-key-management.md` (+127 -0) 📝 `src/lib/components/AddConnectionModal.svelte` (+78 -10) ➕ `src/lib/components/common/ApiKeyManager.svelte` (+153 -0) ➕ `src/lib/utils/apiKeySelection.ts` (+238 -0) </details> ### 📄 Description # implement multi-API key management with selection strategies ## Overview This PR introduces multi-API key management system for Open WebUI, allowing users to configure multiple API keys for providers and select between different key selection strategies. ### Key Features - Add API key selection utility in both TypeScript and Python with consistent implementations - Implement four key selection strategies: - Random: Selects a random key for each request - Round-Robin: Cycles through keys in sequence - Least Recently Used (LRU): Selects the key that was used least recently - Weighted: Selects keys based on assigned weights - Create ApiKeyManager component for the UI to manage multiple keys - Update OpenAI router to support multiple API keys with strategy-based selection - Add comprehensive documentation for the API key management feature ### Technical Implementation - In-memory caching system to optimize key selection performance - Configurable TTL for cached selections - Key validation support with fallback mechanisms - Debug logging with masked API keys for security - Consistent API between frontend and backend implementations ## Status: Initial Implementation This PR represents the initial implementation of the multi-API key management feature. While functional, it requires further work before being considered production-ready: ### Future Enhancements - Integration with other providers beyond OpenAI - Performance optimization for high-volume API requests - Additional selection strategies based on rate limits and quotas - Enhanced error handling and fallback mechanisms - Comprehensive test coverage - UI improvements for better user experience We welcome feedback and contributions to help evolve this feature into a robust solution for the Open WebUI ecosystem. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 06:13:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#62223