feat: add LiteLLM as AI gateway provider#249
Open
RheagalFire wants to merge 6 commits into
Open
Conversation
Author
Author
|
@zaidmukaddam do you have any update on this PR? |
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.
Description
Adds LiteLLM as an AI gateway provider, enabling self-hosters to route queries through 100+ LLM providers (OpenAI, Anthropic, Azure, Bedrock, Vertex AI, Groq, Ollama, etc.) via a single LiteLLM proxy. Follows the existing
createOpenAICompatiblepattern used by ark, sarvam, zai, huggingface, novita, and minimax.Type of Change
Related Issues
No existing issues, but this addresses the self-hosting use case where users want to bring their own LLM provider keys through a unified gateway rather than configuring individual provider API keys.
Changes Made
ai/providers.ts- addedlitellmProviderviacreateOpenAICompatible()with configurableLITELLM_BASE_URLandLITELLM_API_KEYenv vars, plus onescira-litellmmodel entry usingLITELLM_MODELenv var (defaults togpt-4o-mini)ai/models.ts- added'litellm'toModelProvidertype union, addedlitellmentry toPROVIDERSrecord, addedscira-litellmmodel metadata entry, added'litellm'detection ingetModelProvider()functioncomponents/ui/form-component.tsx- added LiteLLM bullet train icon toProviderIconswitchcomponents/ui/model-selector.tsx- added LiteLLM bullet train icon toProviderIconswitchai/__tests__/litellm.test.ts- 11 unit tests for provider registration and model configTesting
Unit tests (11/11 pass):
Tests cover:
scira-litellmmodel entry exists with correct metadata (label, provider, experimental, requiresAuth, maxOutputTokens)getModelProvider()returns'litellm'forscira-litellmand any value containing "litellm"getModelProvider()does NOT return'litellm'for unrelated models (gpt, anthropic)getModelProviderInfo()returns correct LiteLLM provider infogetActiveProviders()includes LiteLLMgetModelsByProvider('litellm')returns at least one modelLint clean:
Live E2E - local dev with LiteLLM proxy routing to Claude Sonnet 4.6 via Azure Foundry:
Ran full local dev stack (Postgres, Redis, LiteLLM proxy, Next.js dev server). Selected LiteLLM from model selector, sent "hi there", received a response from Claude Sonnet 4.6 routed through the LiteLLM proxy. Screenshot attached below.
Server logs confirmed correct model routing:
Test Environment
Screenshots
Checklist
Additional Notes
Configuration for self-hosters:
Set these environment variables to connect to your LiteLLM proxy:
The LiteLLM proxy handles routing to any backend (Azure OpenAI, AWS Bedrock, Vertex AI, Anthropic, Ollama, etc.) so self-hosters get access to all providers without needing individual API keys configured in scira.
Why LiteLLM over adding more individual providers:
LiteLLM acts as a unified gateway. Instead of adding SDK integrations for Bedrock, Vertex AI, Azure, etc. one by one, self-hosters can point scira at a single LiteLLM proxy that handles provider routing, load balancing, cost tracking, and fallbacks across 100+ providers.