feat: add LiteLLM as AI gateway provider#1016
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
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.
Summary
http://localhost:4000/v1.Motivation
OpenWhispr currently supports 5 cloud providers (OpenAI, Anthropic, Gemini, Groq, plus a generic "Custom" endpoint). Users who want providers not directly supported (Bedrock, Azure OpenAI, Mistral, Cohere, Together AI, etc.) must use the generic Custom provider and manually configure everything.
LiteLLM is an AI gateway that proxies 100+ LLM providers through a single OpenAI-compatible endpoint. With this PR, users can:
litellm --model anthropic/claude-sonnet-4-6(or deploy the proxy server)Changes
src/services/ai/inferenceProviders/litellm.ts- newlitellmProviderimplementingInferenceProvider(follows the Groq provider pattern)src/services/ai/inferenceProviders/index.ts- registeredlitellminPROVIDER_REGISTRYsrc/services/ai/providers.ts- addedlitellmcase to AI SDK factory (reusescreateOpenAIwith custombaseURL)src/services/ReasoningService.ts- addedlitellmto cloud provider lists, API key handling, and endpoint resolutionsrc/components/ReasoningModelSelector.tsx- added toCLOUD_PROVIDER_IDS, rendersOpenAICompatiblePanelwith LiteLLM-specific defaultssrc/components/chat/useChatStreaming.ts- addedlitellmto cloud provider detectionsrc/stores/settingsStore.ts- addedlitellmto provider type unionTests
1. TypeScript type check:
2. Prettier format check:
Implementation details
ctx.callChatCompletionsApi()(same pattern as Groq) - the shared context handles request formatting, retries, and response parsing.createOpenAI({ apiKey, baseURL })from@ai-sdk/openaiin the AI SDK factory since LiteLLM proxy exposes an OpenAI-compatible API.OpenAICompatiblePanelrenders withdefaultBaseUrl="http://localhost:4000/v1"for LiteLLM, so users see the correct default proxy URL./v1/models.Risk / Compatibility
@ai-sdk/openaiand the sharedcallChatCompletionsApiinfrastructure.OpenAICompatiblePanel).Example usage
http://localhost:4000/v1(default)anthropic/claude-sonnet-4-6