fix(logging): resolve model_map_value for proxy custom pricing - #31940
Conversation
Use deployment model for standard logging cost-map lookup when the router overrides response.model to a group alias, and flush stdout when printing the payload. Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThis PR fixes a bug where
Confidence Score: 5/5The changes are narrowly scoped to the logging payload builder and do not touch request handling, authentication, or cost calculation itself — safe to merge. The core fix in No files require special attention beyond what was already raised in prior review threads.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/litellm_logging.py | Two targeted changes: (1) passes base_model as the model arg to _select_model_name_for_cost_calc when custom_pricing=True, fixing a null model_map_value; (2) unconditionally falls back base_model to metadata["deployment"] when the metadata helper returns None; plus a minor flush=True on the debug print. |
| tests/logging_callback_tests/test_standard_logging_payload.py | Adds two new tests: one unit test for the get_model_cost_information custom-pricing fix, and one integration-style test exercising the metadata["deployment"] fallback path end-to-end in get_standard_logging_object_payload. |
Reviews (6): Last reviewed commit: "Merge branch 'litellm_internal_staging' ..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…d logging payload Address review: explain why the metadata["deployment"] fallback is unconditional, and add a test covering the get_standard_logging_object_payload code path. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Passing model=base_model unconditionally caused _get_provider_for_cost_calc to infer and prepend a provider prefix on all non-custom-pricing calls, changing model_map_key for existing deployments. Scope it to custom_pricing=True where the fix is actually needed. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Generated by Claude Code |
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
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 8fabf6f. Configure here.
8d0dc92
into
litellm_internal_staging
…AI#31940) * fix(logging): resolve model_map_value for proxy custom pricing Use deployment model for standard logging cost-map lookup when the router overrides response.model to a group alias, and flush stdout when printing the payload. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logging): add comment and test for deployment fallback in standard logging payload Address review: explain why the metadata["deployment"] fallback is unconditional, and add a test covering the get_standard_logging_object_payload code path. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(test): update model_map_key assertion for provider-prefixed keys Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logging): scope base_model to model param only under custom_pricing Passing model=base_model unconditionally caused _get_provider_for_cost_calc to infer and prepend a provider prefix on all non-custom-pricing calls, changing model_map_key for existing deployments. Scope it to custom_pricing=True where the fix is actually needed. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Mateo Wang <277851410+mateo-berri@users.noreply.github.com>
Fixes LIT-3719
Summary
model_map_valuebeing null inStandardLoggingPayloadwhen proxy model-group aliases overrideresponse.modeland custom pricing is enabledmetadata["deployment"]for cost-map lookup whenbase_modelis unsetNote
Low Risk
Changes only how standard logging resolves cost-map metadata for proxy/router aliases; request handling and billing math elsewhere are untouched, with targeted tests.
Overview
Fixes null
model_map_valuein standard logging when the proxy/router rewritesresponse.modelto a model-group alias while custom pricing is on.get_model_cost_informationnow passesbase_modelinto cost-name selection when custom pricing is enabled, so lookup does not rely only on the alias in the response object. When building the standard logging payload, ifbase_modelis missing it falls back tometadata["deployment"](the real deployment id the router records).Debug printing of standard logging payloads now flushes stdout so piped logging shows output promptly. New tests cover custom-pricing base-model selection and the deployment fallback.
Reviewed by Cursor Bugbot for commit 8fabf6f. Bugbot is set up for automated code reviews on this repo. Configure here.