feat: add LiteLLM as AI gateway provider#4644
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Introduces a new Plumbs LiteLLM through the UI/state layer: provider model syncing ( Reviewed by Cursor Bugbot for commit b4268ec. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR adds LiteLLM as a new AI gateway provider, enabling access to 100+ LLM backends through a LiteLLM proxy server. It follows the existing vLLM pattern throughout: OpenAI SDK with a custom
Confidence Score: 3/5Safe to merge for server-side execution, but end-to-end model discovery in the UI is broken without additional files that were not included in this PR. The server-side execution path (initialize, executeRequest, tool loop, streaming) is complete and correct. However, the client-side model discovery pipeline is entirely absent: no API route, no contract, no query hook case, and no ProviderModelsLoader entry for litellm. Without these, users can type in a model name manually but the model selector will show nothing for LiteLLM, making the feature appear non-functional in the UI. The four files that need to be added or updated to complete the frontend pipeline: apps/sim/app/api/providers/litellm/models/route.ts (new), apps/sim/lib/api/contracts/providers.ts, apps/sim/hooks/queries/providers.ts, and apps/sim/app/workspace/[workspaceId]/providers/provider-models-loader.tsx. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Browser (ProviderModelsLoader)
participant API as /api/providers/litellm/models ❌ missing
participant Init as litellmProvider.initialize()
participant Proxy as LiteLLM Proxy (/v1/models)
participant Exec as litellmProvider.executeRequest()
Note over Client,API: Frontend model discovery (NOT implemented)
Client--xAPI: GET /api/providers/litellm/models (no route exists)
Note over Init,Proxy: Server-side initialization (works correctly)
Init->>Proxy: GET /v1/models
Proxy-->>Init: "{ data: [{ id: 'anthropic/claude-...' }] }"
Init->>Init: "this.models = ['litellm/anthropic/...']"
Init->>Init: setProviderModels('litellm', models)
Note over Client,Exec: Execution flow (works correctly)
Client->>Exec: "POST /api/providers { provider: 'litellm', model: 'litellm/...' }"
Exec->>Proxy: "chat.completions.create (OpenAI SDK, baseURL=LITELLM_BASE_URL/v1)"
Proxy-->>Exec: ChatCompletion / Stream
Exec-->>Client: ProviderResponse / StreamingExecution
Reviews (1): Last reviewed commit: "fix: add litellm to attachments, provide..." | Re-trigger Greptile |
| name: 'LiteLLM', | ||
| icon: LitellmIcon, | ||
| description: 'LiteLLM proxy with an OpenAI-compatible API', | ||
| defaultModel: 'litellm/generic', |
There was a problem hiding this comment.
The
defaultModel value 'litellm/generic' is not a real model ID and will produce a confusing error when it is used as the initial default before any models are discovered (e.g. if the proxy is unreachable). Aligning with the vLLM pattern of leaving defaultModel as an empty string avoids sending a bogus model ID to the proxy.
| defaultModel: 'litellm/generic', | |
| defaultModel: '', |
Add API route, contract, query hook case, and ProviderModelsLoader entry so litellm models are fetched and synced to the store on workspace load, matching the vllm/ollama/openrouter/fireworks pattern. Also fixes defaultModel to empty string and adds litellm/ prefix early-return in blocks/utils.ts (reviewer feedback).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 475820a. Configure here.
Copy-paste artifact from vLLM provider. LiteLLM should only use LITELLM_BASE_URL, not fall back to azureEndpoint which could cause requests to be routed to the wrong server.

Summary
Adds LiteLLM as a provider, enabling access to 100+ LLM backends through a LiteLLM proxy server. Follows the vLLM provider pattern (OpenAI SDK with custom baseURL, dynamic model discovery via
/v1/models).Fixes #2859
Type of Change
Testing
Model discovery:
Basic completion through LiteLLM proxy:
Streaming:
Tool calling:
All tests use OpenAI SDK with
baseURL: http://localhost:4000/v1pointing at a LiteLLM proxy, which is exactly what the provider does.Deep-dive bugs found and fixed:
attachments.ts:formatMessagesForProvidermissing litellm (would hit exhaustivenevercheck at runtime)blocks/utils.ts: litellm not excluded from API key requirement check (dynamic providers don't need pre-configured keys)providers/utils.ts: missing metadata,getBaseModelProvidersexclusion, andgetApiKeyhandlerstores/providers: missingProviderNametype and store defaultsChecklist