Skip to content

fix(router): don't log 'Could not identify azure model' when the deployment name resolves from the cost map - #33292

Closed
mihidumh wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
mihidumh:fix/azure-base-model-inference
Closed

fix(router): don't log 'Could not identify azure model' when the deployment name resolves from the cost map#33292
mihidumh wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
mihidumh:fix/azure-base-model-inference

Conversation

@mihidumh

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #33172

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Production observation (litellm proxy 1.92.0 on Azure, real traffic): every request to a multi-deployment azure group without base_model logs

Could not identify azure model 'gpt-5.4'. Set azure 'base_model' for accurate max tokens, cost tracking, etc.

— thousands of ERROR lines/day — even though azure/gpt-5.4 is an exact key in the shipped cost map and get_router_model_info's existing if model is None: model = _model fallback resolves it correctly. We verified on the live proxy that hand-setting model_info.base_model = litellm_params.model on every such row (56 rows on one env) changes nothing about resolution and only silences the log — i.e. the ERROR was spurious for exactly the deployments that need no operator action.

While investigating I found membership in litellm.model_cost can't be the discriminator on its own: Router.__init__ auto-registers every deployment name into the map as a zeroed stub (register_model: model=... not in built-in cost map ... will default to 0). The check therefore requires the fallback entry to carry usable limits/costs.

Unit tests (new TestAzureBaseModelFallbackLogging in tests/test_litellm/test_router.py):

Before (base 10d5804b3e): test_map_known_deployment_name_resolves_without_error_log FAILS (spurious ERROR fires); other 2 pass.

After (this PR, 261f9546c5):

$ pytest tests/test_litellm/test_router.py::TestAzureBaseModelFallbackLogging -q
3 passed

covering: (1) map-known deployment name → no ERROR + model_info carries the map's max tokens/costs, (2) genuinely unmappable name → ERROR still logged, zeroed-stub return unchanged, (3) explicit base_model still wins.

ruff format --check / ruff check pass on litellm/router.py.

Type

🐛 Bug Fix

Changes

  • In get_router_model_info's azure branch: when base_model is unset, check whether the azure/<deployment model name> entry in the cost map carries usable limits/costs (guarding against Router-init's zeroed auto-registration stubs). If so, log at debug — the existing fallback resolution handles it. Otherwise keep the existing error.
  • No behavior change to resolution itself — only the logging level is corrected for the already-working path.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes spurious per-request ERROR log lines for Azure deployments whose model name is a direct key in the built-in cost map (e.g., azure/gpt-4o). The fix is logging-only — no change to resolution logic or returned values.

  • In get_router_model_info, when base_model is unset for an Azure deployment, the PR checks whether the azure/<model> key in litellm.model_cost carries a positive max_input_tokens, max_tokens, or input_cost_per_token. If so, it downgrades the log from ERROR to DEBUG; otherwise the ERROR is preserved as before.
  • Three unit tests cover the new branching: known deployment → no error log, unmappable name → error preserved, explicit base_model → continues to win.

Confidence Score: 5/5

Safe to merge — the change is restricted to log level selection and does not affect model resolution, cost tracking, or token-limit enforcement.

The change touches only one branch inside get_router_model_info and only adjusts whether a message is logged at ERROR vs DEBUG. The (value or 0) > 0 guards are consistent across all three checked fields, correctly rejecting zeroed stubs and explicit-zero entries. Actual resolution is unchanged. Tests are well-constructed mocks that reproduce the exact before/after behavior described in the PR.

No files require special attention.

Important Files Changed

Filename Overview
litellm/router.py Logging-only change in get_router_model_info: downgrades Azure "Could not identify model" ERROR to DEBUG when the deployment name resolves to a cost-map entry with usable (>0) limits or costs. Resolution behavior is unchanged.
tests/test_litellm/test_router.py Adds TestAzureBaseModelFallbackLogging with three new mock-only tests covering the happy path (no error log), the genuine-miss path (error preserved), and the explicit-base-model path. No real network calls; fixture correctly isolates the cost map.

Reviews (2): Last reviewed commit: "fix(router): use consistent positive che..." | Re-trigger Greptile

Comment thread litellm/router.py Outdated
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mihidumh

Copy link
Copy Markdown
Contributor Author

@greptileai — made the _fallback_resolves checks consistent: all three fields (max_input_tokens, max_tokens, input_cost_per_token) now require a positive value, so an entry with explicit-zero limits can no longer suppress the error log.

@mihidumh
mihidumh force-pushed the fix/azure-base-model-inference branch from 5801549 to 7e63df3 Compare July 22, 2026 22:43
@mihidumh
mihidumh requested a review from a team July 22, 2026 22:43
@mihidumh
mihidumh changed the base branch from litellm_oss_daily_2026_07_14 to litellm_oss_daily_2026_07_20 July 22, 2026 22:43
@mihidumh
mihidumh changed the base branch from litellm_oss_daily_2026_07_20 to litellm_internal_staging July 28, 2026 23:17
@mihidumh
mihidumh force-pushed the fix/azure-base-model-inference branch from 7e63df3 to d2b06c6 Compare July 28, 2026 23:18
@mihidumh

Copy link
Copy Markdown
Contributor Author

Rebased onto litellm_internal_staging (per the current CONTRIBUTING.md) and retargeted — this had been sitting on litellm_oss_daily_2026_07_20, which was retired in 8a0bb4c two days after this PR was moved onto it, so the CI failures were all base age rather than anything in the diff. Force-pushed because the rebase needed a conflict resolution in tests/test_litellm/test_router.py, where #34564 added tests in the same place; both test blocks are kept, the litellm/router.py change is unchanged.

@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing mihidumh:fix/azure-base-model-inference (fa2b896) with litellm_internal_staging (47a7e17)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (5290150) during the generation of this report, so 47a7e17 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@mihidumh
mihidumh force-pushed the fix/azure-base-model-inference branch from d2b06c6 to 1362157 Compare August 20, 2026 05:50
…oyment name resolves from the cost map

get_router_model_info already falls back to resolving the azure
deployment's model name against the model cost map when base_model is
unset — and for deployments named after real azure models (e.g.
azure/gpt-4o) that resolution returns correct max tokens and costs. The
unconditional ERROR was therefore spurious for exactly the deployments
that need no operator action, and on busy proxies it logs thousands of
times per day per multi-deployment group.

Log at debug when the fallback entry carries usable limits/costs
(membership alone is not enough: Router init auto-registers every
deployment name as a zeroed stub), keep the ERROR otherwise.

Fixes BerriAI#33172

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mihidumh
mihidumh force-pushed the fix/azure-base-model-inference branch from 1362157 to 6c8e319 Compare August 20, 2026 07:05
…ack gate

Review follow-up: token-limit fields used 'is not None' while the cost
field used '> 0' — a cost-map entry explicitly storing 0 limits could
suppress the error log without carrying usable resolution data. All
three checks now require a positive value.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mihidumh

Copy link
Copy Markdown
Contributor Author

Closing — superseded by #37869, which merged this branch's commit (authorship preserved) into litellm_internal_staging on 2026-08-21. Thanks @tin-berri.

@mihidumh mihidumh closed this Aug 23, 2026
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.

[Feature]: infer azure base_model when the deployment model name exactly matches a cost-map key (stop 'Could not identify azure model' spam)

1 participant