Skip to content

fix: make LiteLLM API key optional for self-hosted proxies#11921

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/litellm-optional-api-key
Draft

fix: make LiteLLM API key optional for self-hosted proxies#11921
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/litellm-optional-api-key

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 13, 2026

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 only litellmBaseUrl (not litellmApiKey) for the LiteLLM provider
  • webview-ui/src/components/settings/providers/LiteLLM.tsx: Updated handleRefreshModels to only require url and removed the litellmApiKey check from the Refresh Models button disabled condition
  • src/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 from if (litellmApiKey && litellmBaseUrl) to if (litellmBaseUrl) so model fetching works without an API key
  • src/api/providers/fetchers/litellm.ts: Changed the apiKey parameter type to string | 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 clarity
  • webview-ui/src/i18n/locales/en/settings.json: Added validation.baseUrl translation key

Test Procedure

  • Ran the existing litellm test suite (22 tests pass) including 2 new tests for undefined/empty API key scenarios
  • All lint checks pass
  • All type checks pass across the monorepo

New tests added:

  1. Verifies requests are sent without Authorization header when apiKey is undefined
  2. Verifies requests are sent without Authorization header when apiKey is empty string

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on the linked issue
  • Self-Review: Performed a thorough self-review
  • Testing: New tests added for the optional API key scenario
  • Documentation Impact: No documentation updates required
  • Contribution Guidelines: Read and agree to the Contributor Guidelines

Documentation Updates

  • No documentation updates are required.

Additional Notes

The getLiteLLMModels fetcher 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LiteLLM provider should not require a mandatory API Key

1 participant