feat: add LiteLLM as AI gateway provider#45
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
Author
|
cc @elder-plinius - would love your review when you get a chance! |
Contributor
|
Reviewed the wiring — it's logically sound (LiteLLM via the OpenRouter-compatible adapter, base URL |
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
Changes
src/types/index.ts- Added'litellm'to theLLMProviderunion typesrc/llm/index.ts- AddedLiteLLMAdapter(extendsOpenRouterAdaptersince LiteLLM proxy speaks the same OpenAI-compatible wire protocol), factory functioncreateLiteLLMBackbone(), registered increateAdapter()switch andcreateBestAvailableBackbone()priority chainsrc/config/index.ts- Added LiteLLM config block (baseUrl,defaultModel),LITELLM_API_KEY/LITELLM_BASE_URL/LITELLM_MODELenv vars,AVAILABLE_MODELSentry,hasLiteLLMProxy()helper, and wired through all provider helper methods (getLLMConfig,getConfiguredProviders,buildFallbackChain,setDefaultProvider,setDefaultModel,exportConfig,createEnvTemplate)src/setup.ts- Added interactivesetupLiteLLMProxy()wizard (prompts for proxy URL, optional API key, default model; tests connection with save-anyway fallback)src/index.ts- ExportedcreateLiteLLMBackboneTests
1. TypeScript type check:
npx tsc --noEmitpasses clean (zero errors).2. Full test suite: All 328 tests pass across 28 test files.
3. Live E2E against LiteLLM proxy (Azure Foundry backend):
Proxy config:
litellm --config config.yaml --port 4111routinganthropic/claude-sonnet-4-6through Azure Foundry.Full chain verified:
LLMBackbone('litellm') -> LiteLLMAdapter -> fetch(proxy/v1/chat/completions) -> LiteLLM proxy -> Azure Foundry -> Claude Sonnet 4.6 -> parsed LLMResponse. Chat, streaming, and tool calling all work.Risk / Compatibility
LITELLM_BASE_URLenv var or explicit config - no auto-detection from a default localhost URL (avoids false positives).createBestAvailableBackbone()priority chain between Venice and Anthropic.TEMPEST_MODEL_FALLBACKis enabled.Example usage
Environment variables:
CLI:
Programmatic:
Setup wizard: