feat(litellm): add LiteLLM as AI gateway provider#4739
Conversation
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).
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.
- byok.ts: add litellm branch to getApiKeyWithBYOK so workflow block execution can resolve the proxy key instead of throwing "API key is required for litellm ..." - check-api-validation-contracts.ts: bump route baseline 755 -> 756 to account for the new /api/providers/litellm/models route - .env.example: document LITELLM_BASE_URL / LITELLM_API_KEY - copilot edit-workflow validation: include LiteLLM in the list of user-configured prefixed providers shown to the model - providers/utils.ts: drop stray optional-chain on providers.litellm to match the vllm pattern - lint: apply biome formatting fixes (multi-line if, SVG path, multi-line DYNAMIC_MODEL_PROVIDERS)
- blocks/utils.ts getModelOptions(): include litellm models in the combined model dropdown — was previously dropping any proxy-discovered models from the agent block model picker. - get-blocks-metadata-tool.ts mockProvidersState: add litellm bucket so the server-side copilot block-metadata fallback can render model options when the providers store is not initialized. - blocks/utils.test.ts: add litellm to mock providers state (initial + beforeEach reset) and add a parallel store-bucket guard test mirroring the vLLM case. - providers/utils.test.ts: add parallel getApiKey test for litellm.
- icons.tsx: replace the placeholder letterform with the official LiteLLM brand mark embedded as a PNG data URI in an SVG image. - models.ts: set color: #040229 on the litellm provider definition to match the brand background.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Configuration & discovery: Runtime: New Tests & tooling: Unit tests for LiteLLM API-key and store-bucket behavior; API validation baseline 755 → 756 routes. Reviewed by Cursor Bugbot for commit b965f70. Configure here. |
Greptile SummaryThis PR adds LiteLLM as a first-class AI gateway provider, mirroring the existing vLLM integration end-to-end: dynamic model discovery via
Confidence Score: 5/5Safe to merge — the integration is a faithful, end-to-end port of the vLLM provider with no new data-loss, auth-bypass, or broken-contract issues introduced. The PR follows every established pattern from the vLLM provider: Zod validation of the upstream model list, BYOK key resolution, store/hook wiring, streaming, and multi-turn tool loops are all correctly implemented. The previous audit gaps are addressed and tests cover the new code paths. No files require special attention — the changes are additive and self-contained within the provider layer. Important Files Changed
Reviews (2): Last reviewed commit: "chore(litellm): validate /v1/models resp..." | Re-trigger Greptile |
…itialize() Match the API route handler — both code paths now run the same vllmUpstreamResponseSchema.parse() over the upstream /v1/models JSON instead of a raw type-cast, so malformed upstream payloads surface a descriptive ZodError instead of a downstream TypeError. Addresses Greptile review feedback on PR #4739.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b965f70. Configure here.
Summary
/v1/models, full OpenAI SDK call path, streaming, tool calling, JSON schema response format/api/providers/litellm/modelsroute,ProviderModelsLoader,useProviderModelshook, store defaults,ProviderId/ProviderName/AttachmentProviderunions, registry, env vars (LITELLM_BASE_URL,LITELLM_API_KEY)API key is required for litellm ...for any workflow run),getModelOptions()includes litellm models in the agent block picker, copilot server-side fallback state initialized, copilot edit-workflow message lists LiteLLM,.env.exampledocuments the new env varsgetApiKey('litellm', ...)and the litellm store-bucket guard#040229color on the provider definitionType of Change
Testing
Checklist