fix: make LiteLLM API key optional for self-hosted proxies#11921
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: make LiteLLM API key optional for self-hosted proxies#11921roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
LiteLLM supports and is often used without authentication in self-hosted or local environments. This change makes the API key field optional so users can configure LiteLLM with just a base URL. Changes: - Remove API key requirement from validation (require only base URL) - Update Refresh Models button to work without API key - Make apiKey optional in LiteLLM type definition - Update fetcher to accept undefined apiKey and skip Auth header - Update webviewMessageHandler to only require baseUrl - Add validation.baseUrl translation key - Add tests for no-API-key scenarios Closes #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. Feedback and guidance are welcome.
LiteLLM supports and is often used without authentication in self-hosted or local environments. Currently the extension UI enforces a mandatory API Key for the LiteLLM provider, preventing users from saving configurations or using the provider without entering a dummy key.
This change makes the API key field optional across the stack:
webview-ui/src/utils/validate.ts: Changed validation to require onlylitellmBaseUrl(notlitellmApiKey) for the LiteLLM providerwebview-ui/src/components/settings/providers/LiteLLM.tsx: UpdatedhandleRefreshModelsto only requireurland removed thelitellmApiKeycheck from the Refresh Models button disabled conditionsrc/shared/api.ts: Changed the LiteLLM type from{ apiKey: string; baseUrl: string }to{ apiKey?: string; baseUrl: string }src/core/webview/webviewMessageHandler.ts: Changed the condition fromif (litellmApiKey && litellmBaseUrl)toif (litellmBaseUrl)so model fetching works without an API keysrc/api/providers/fetchers/litellm.ts: Changed theapiKeyparameter type tostring | undefined(the Authorization header is already conditionally included only when an API key is provided)src/api/providers/lite-llm.ts: Updated fallback from"dummy-key"to"not-needed"for claritywebview-ui/src/i18n/locales/en/settings.json: Addedvalidation.baseUrltranslation keyTest Procedure
22 tests pass) including 2 new tests for undefined/empty API key scenariosNew tests added:
apiKeyisundefinedapiKeyis empty stringPre-Submission Checklist
Documentation Updates
Additional Notes
The
getLiteLLMModelsfetcher already had conditional logic to only add the Authorization header when an API key is present (line 21-23). This change simply allows the rest of the stack to take advantage of that existing behavior.Interactively review PR in Roo Code Cloud