Skip to content

fix(router): pass custom_llm_provider to get_llm_provider for unprefixed model names#25334

Merged
krrish-berri-2 merged 1 commit intomainfrom
litellm_fix-llm-provider-inference-for-unprefixed-models
Apr 9, 2026
Merged

fix(router): pass custom_llm_provider to get_llm_provider for unprefixed model names#25334
krrish-berri-2 merged 1 commit intomainfrom
litellm_fix-llm-provider-inference-for-unprefixed-models

Conversation

@Sameerlite
Copy link
Copy Markdown
Collaborator

@Sameerlite Sameerlite commented Apr 8, 2026

Summary

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).

Root Cause

The router was calling get_llm_provider(model=data['model']) without passing custom_llm_provider parameter, causing provider inference to fail for unprefixed model names.

Changes

  • Router now passes deployment's custom_llm_provider to get_llm_provider() in 6 code paths:
    • File creation (_acreate_file)
    • File content (_ageneric_api_call_with_fallbacks_helper)
    • Batch creation (acreate_batch)
    • Batch cancellation (acancel_batch)
    • Vector store creation (avector_store_create)
    • Generic API calls (sync version)
  • File delete endpoint now explicitly passes custom_llm_provider
  • Added 2 regression tests
image

…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
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 8, 2026 10:56am

Request Review

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Apr 8, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing litellm_fix-llm-provider-inference-for-unprefixed-models (ee885f1) with main (62757ff)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR fixes a LLM Provider NOT provided error in the LiteLLM Router when deployments configure custom_llm_provider explicitly but use unprefixed model names (e.g. gpt-4.1-mini instead of azure/gpt-4.1-mini). Previously, six code paths in the router called get_llm_provider(model=data[\"model\"]) without forwarding the deployment's stored custom_llm_provider, causing provider inference to fail. The fix consistently reads custom_llm_provider from deployment[\"litellm_params\"] before calling get_llm_provider, then falls back to the inferred value. A parallel fix in the proxy delete_file endpoint ensures the resolved provider is explicitly threaded through to litellm.afile_delete.

  • Applies the same two-step lookup (data.get(\"custom_llm_provider\")get_llm_provider inference → or fallback) across six router methods: _acreate_file, _ageneric_api_call_with_fallbacks_helper, acreate_batch, acancel_batch, avector_store_create, and the sync generic_api_call.
  • Adds explicit custom_llm_provider=credentials[\"custom_llm_provider\"] to the afile_delete proxy endpoint (safe because get_deployment_credentials_with_provider always guarantees this key).
  • Two regression tests added for acreate_file and afile_content; the remaining four fixed paths (acreate_batch, acancel_batch, avector_store_create, sync generic) are not covered by new tests.

Confidence Score: 5/5

Safe 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.

Vulnerabilities

No security concerns identified. The change only affects provider resolution logic within the router and does not touch authentication, authorization, credential storage, or user-controlled input handling. The credentials[\"custom_llm_provider\"] access in files_endpoints.py is safe because get_deployment_credentials_with_provider always populates this key before returning.

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "fix(router): pass custom_llm_provider to..." | Re-trigger Greptile

Comment thread tests/test_litellm/test_router.py
Comment thread tests/test_litellm/test_router.py
@krrish-berri-2 krrish-berri-2 merged commit 6a0e0ce into main Apr 9, 2026
103 of 107 checks passed
@krrish-berri-2 krrish-berri-2 deleted the litellm_fix-llm-provider-inference-for-unprefixed-models branch April 9, 2026 04:27
yuneng-berri added a commit that referenced this pull request Apr 10, 2026
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.
yuneng-berri added a commit that referenced this pull request Apr 14, 2026
- 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
Benniphx pushed a commit to Benniphx/litellm that referenced this pull request Apr 15, 2026
- 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
ishaan-berri pushed a commit that referenced this pull request Apr 15, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants