feat: make LiteLLM API key optional for self-hosted instances#11920
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
feat: make LiteLLM API key optional for self-hosted instances#11920roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
The LiteLLM provider now only requires a Base URL. The API Key field is optional, allowing users with self-hosted or local LiteLLM proxies to use the extension without entering a dummy key. Changes: - validate.ts: require only litellmBaseUrl (not litellmApiKey) for LiteLLM - LiteLLM.tsx: allow Refresh Models with just a Base URL - shared/api.ts: make apiKey optional in litellm type - webviewMessageHandler.ts: fetch models when baseUrl is set (no key needed) - litellm.ts fetcher: accept undefined apiKey, skip Auth header when absent - lite-llm.ts handler: use empty string instead of "dummy-key" fallback - Added "baseUrl" validation translation key - Added tests for optional API key scenarios Fixes #11918
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11918
Description
This PR attempts to address Issue #11918. The LiteLLM provider previously required a mandatory API Key, but LiteLLM is often used without authentication in self-hosted or local environments. This change makes the API Key optional while keeping the Base URL required.
Key changes:
webview-ui/src/utils/validate.ts: Changed the LiteLLM validation to require onlylitellmBaseUrl(notlitellmApiKey)webview-ui/src/components/settings/providers/LiteLLM.tsx: UpdatedhandleRefreshModelsand the Refresh Models button to only require a Base URLsrc/shared/api.ts: MadeapiKeyoptional in the litellm type definitionsrc/core/webview/webviewMessageHandler.ts: Changed the model fetch condition to only requirelitellmBaseUrlsrc/api/providers/fetchers/litellm.ts: UpdatedgetLiteLLMModelsto acceptstring | undefinedfor apiKey, skip Authorization header when absentsrc/api/providers/lite-llm.ts: Use empty string instead of"dummy-key"fallback so no unnecessary Authorization header is sentwebview-ui/src/i18n/locales/en/settings.json: AddedbaseUrlvalidation translation keyThe fetcher already had logic to conditionally include the Authorization header only when an API key is provided, so the main work was removing the mandatory validation and adjusting types/conditions throughout the codebase.
Feedback and guidance are welcome.
Test Procedure
webview-ui/src/utils/__tests__/validate.spec.tsfor LiteLLM validation:src/api/providers/fetchers/__tests__/litellm.spec.tsfor undefined API key casePre-Submission Checklist
Interactively review PR in Roo Code Cloud