feat: add LiteLLM as custom model provider#168
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
Signed-off-by: RheagalFire <arishalam121@gmail.com>
ebbeb75 to
fa511f6
Compare
Author
|
cc @aavshr |
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
Motivation
LiteLLM acts as a unified AI gateway. Instead of configuring individual provider API keys, users can point Surf at a single LiteLLM proxy that handles provider routing, load balancing, and cost tracking across 100+ providers. Useful for users who need providers not yet directly supported (e.g., AWS Bedrock, Vertex AI, Mistral, Cohere), or teams running a centralized LLM proxy.
Changes
packages/types/src/ai.types.ts- addedLiteLLM = 'LiteLLM'toCUSTOM_MODELSenum, added LiteLLM entry toCUSTOM_MODEL_DEFINITIONSwith default proxy URL, model docs link, and API key docs linkpackages/icons/src/lib/Icons/LiteLLM.svelte- new icon component (bullet train, matching LiteLLM's brand)packages/icons/src/lib/main.ts- registered LiteLLM icon in the icon map and exportsTests
Live E2E - basic completion via LiteLLM proxy routing to Claude Sonnet 4.6:
Live E2E - streaming via LiteLLM proxy:
SSE chunks parsed correctly through the same
/v1/chat/completionsendpoint Surf uses for Ollama and OpenRouter custom models.Error handling - invalid model:
All 3 tests use raw
fetch("http://localhost:4000/v1/chat/completions")matching the exact call path Surf uses for custom models viaOPEN_AI_PATH_SUFFIX.Risk / Compatibility
Example usage
1. Start a LiteLLM proxy:
2. In Surf Settings > AI > Custom Model, select "LiteLLM"
3. Enter model name using LiteLLM's
provider/modelformat:4. Edit the proxy URL
5. Enter your LiteLLM proxy API key (if required)