fix(router): pass custom_llm_provider to get_llm_provider for unprefixed model names#25334
Conversation
…xed model names Fixes 'LLM Provider NOT provided' errors when models are configured with custom_llm_provider but model names lack provider prefix (e.g., 'gpt-4.1-mini' instead of 'azure/gpt-4.1-mini'). Changes: - Router now passes deployment's custom_llm_provider to get_llm_provider() - Fixes 6 code paths: file creation, file content, batch operations, vector store - Adds regression tests for file creation and file content operations Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a
Confidence Score: 5/5Safe to merge — fix is correct and consistent across all six paths; only remaining findings are P2 test coverage suggestions. The two-step provider resolution pattern is applied uniformly and matches how other parts of the router already handle provider lookup. The files_endpoints.py change is safe because get_deployment_credentials_with_provider guarantees custom_llm_provider is always present. The two new tests are mock-only (matching project rules) and the first one strongly validates the core fix. The remaining gaps are P2 style improvements that do not affect merge safety. tests/test_litellm/test_router.py — missing coverage for acreate_batch, acancel_batch, avector_store_create, and sync generic_api_call paths.
|
| Filename | Overview |
|---|---|
| litellm/router.py | Six call-sites updated to read custom_llm_provider from deployment params before inferring via get_llm_provider; fix is correct and consistent, but four of the six paths lack regression tests. |
| litellm/proxy/openai_files_endpoints/files_endpoints.py | Explicitly passes credentials["custom_llm_provider"] to afile_delete; safe because get_deployment_credentials_with_provider always guarantees this key, and prepare_data_with_credentials already pops it from data to prevent duplication. |
| tests/test_litellm/test_router.py | Two new mock-only tests added; acreate_file test is thorough (asserts custom_llm_provider == 'azure'), but afile_content test only checks call count rather than the forwarded provider value, and four other fixed paths are untested. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Router method called\ne.g. acreate_file, acreate_batch] --> B[Select deployment\nfrom model_list]
B --> C[data = deployment.litellm_params.copy]
C --> D{data has\ncustom_llm_provider?}
D -- Yes --> E[custom_llm_provider =\ndata.get custom_llm_provider]
D -- No --> F[custom_llm_provider = None]
E --> G[get_llm_provider\nmodel=data.model\ncustom_llm_provider=custom_llm_provider]
F --> G
G -- success --> H[inferred_custom_llm_provider]
G -- exception --> I[custom_llm_provider = None]
H --> J[custom_llm_provider =\ncustom_llm_provider OR inferred]
J --> K[Pass custom_llm_provider\nexplicitly to litellm API call]
I --> L{async path?}
L -- Yes --> M[Skip setting provider\nin response_kwargs]
L -- No --> N[Set provider = None\nin kwargs]
K --> O[litellm routes to\ncorrect provider handler]
Reviews (1): Last reviewed commit: "fix(router): pass custom_llm_provider to..." | Re-trigger Greptile
Filter all explicitly-passed keys from remaining_kwargs before spreading into async_responses_websocket(). The router now injects custom_llm_provider into kwargs (via #25334), which collides with the explicit custom_llm_provider= argument.
- Add 8 content PRs that merged directly to the release branch outside the listed staging PRs: #23769 (Ramp callback), #25252 (JWT OAuth2 override), #25254 (AWS GovCloud mode), #25258 (batch-limit cleanup), #25334 (router custom_llm_provider), #25345 (Triton embeddings), #25347 (tag-based routing), #25358 (Baseten pricing attribution) - Add @kedarthakkar to new contributors (first-ever PR via #23769) - Update RELEASE_NOTES_GENERATION_INSTRUCTIONS: require walking git log range between release tags in addition to staging PRs, and verify new-contributor status per author rather than trusting the GH release body floor
- Add 8 content PRs that merged directly to the release branch outside the listed staging PRs: BerriAI#23769 (Ramp callback), BerriAI#25252 (JWT OAuth2 override), BerriAI#25254 (AWS GovCloud mode), BerriAI#25258 (batch-limit cleanup), BerriAI#25334 (router custom_llm_provider), BerriAI#25345 (Triton embeddings), BerriAI#25347 (tag-based routing), BerriAI#25358 (Baseten pricing attribution) - Add @kedarthakkar to new contributors (first-ever PR via BerriAI#23769) - Update RELEASE_NOTES_GENERATION_INSTRUCTIONS: require walking git log range between release tags in addition to staging PRs, and verify new-contributor status per author rather than trusting the GH release body floor
- Add 8 content PRs that merged directly to the release branch outside the listed staging PRs: #23769 (Ramp callback), #25252 (JWT OAuth2 override), #25254 (AWS GovCloud mode), #25258 (batch-limit cleanup), #25334 (router custom_llm_provider), #25345 (Triton embeddings), #25347 (tag-based routing), #25358 (Baseten pricing attribution) - Add @kedarthakkar to new contributors (first-ever PR via #23769) - Update RELEASE_NOTES_GENERATION_INSTRUCTIONS: require walking git log range between release tags in addition to staging PRs, and verify new-contributor status per author rather than trusting the GH release body floor
Summary
Fixes 'LLM Provider NOT provided' errors when models are configured with
custom_llm_providerbut model names lack provider prefix (e.g.,gpt-4.1-miniinstead ofazure/gpt-4.1-mini).Root Cause
The router was calling
get_llm_provider(model=data['model'])without passingcustom_llm_providerparameter, causing provider inference to fail for unprefixed model names.Changes
custom_llm_providertoget_llm_provider()in 6 code paths:_acreate_file)_ageneric_api_call_with_fallbacks_helper)acreate_batch)acancel_batch)avector_store_create)custom_llm_provider