Skip to content

feat: add LiteLLM as AI gateway provider#249

Open
RheagalFire wants to merge 6 commits into
zaidmukaddam:mainfrom
RheagalFire:feat/add-litellm-provider
Open

feat: add LiteLLM as AI gateway provider#249
RheagalFire wants to merge 6 commits into
zaidmukaddam:mainfrom
RheagalFire:feat/add-litellm-provider

Conversation

@RheagalFire

Copy link
Copy Markdown

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 createOpenAICompatible pattern used by ark, sarvam, zai, huggingface, novita, and minimax.

Type of Change

  • New feature (non-breaking change which adds functionality)

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 - added litellmProvider via createOpenAICompatible() with configurable LITELLM_BASE_URL and LITELLM_API_KEY env vars, plus one scira-litellm model entry using LITELLM_MODEL env var (defaults to gpt-4o-mini)
  • ai/models.ts - added 'litellm' to ModelProvider type union, added litellm entry to PROVIDERS record, added scira-litellm model metadata entry, added 'litellm' detection in getModelProvider() function
  • components/ui/form-component.tsx - added LiteLLM bullet train icon to ProviderIcon switch
  • components/ui/model-selector.tsx - added LiteLLM bullet train icon to ProviderIcon switch
  • ai/__tests__/litellm.test.ts - 11 unit tests for provider registration and model config

Testing

  • Tested locally
  • Added/updated unit tests
  • Added/updated integration tests
  • All tests pass

Unit tests (11/11 pass):

$ bunx vitest run ai/__tests__/litellm.test.ts

Test Files  1 passed (1)
      Tests  11 passed (11)
   Duration  483ms

Tests cover:

  • LiteLLM provider exists in PROVIDERS record with correct metadata (id, name, icon, hasNew)
  • scira-litellm model entry exists with correct metadata (label, provider, experimental, requiresAuth, maxOutputTokens)
  • Model description mentions "gateway"
  • getModelProvider() returns 'litellm' for scira-litellm and any value containing "litellm"
  • getModelProvider() does NOT return 'litellm' for unrelated models (gpt, anthropic)
  • getModelProviderInfo() returns correct LiteLLM provider info
  • getActiveProviders() includes LiteLLM
  • getModelsByProvider('litellm') returns at least one model

Lint clean:

$ bun run lint
(no errors)

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:

Search API: {
  model: 'scira-litellm',
  requestedModel: 'scira-litellm',
  group: 'web',
  isAutoRouted: false
}

Test Environment

  • OS: macOS Darwin 25.4.0
  • Browser: Chrome
  • Node Version: v22.x (via Bun)

Screenshots

Screenshot 2026-05-23 at 00 32 12

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Configuration for self-hosters:

Set these environment variables to connect to your LiteLLM proxy:

LITELLM_BASE_URL=http://localhost:4000/v1   # Your LiteLLM proxy URL
LITELLM_API_KEY=sk-your-litellm-key         # Your LiteLLM proxy API key
LITELLM_MODEL=gpt-4o-mini                   # Default model on your 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.

@RheagalFire

Copy link
Copy Markdown
Author

cc @zaidmukaddam

@RheagalFire

Copy link
Copy Markdown
Author

@zaidmukaddam do you have any update on this PR?

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.

1 participant