Repository navigation
feat(cost): warn and count $0 cost on billable requests - #42345
Conversation
A request that carries usage but prices to $0 on a model whose pricing
entry has a non-zero rate now logs one warning naming the model, the
pricing entry, and the missing rate, and increments
litellm_zero_cost_requests_total{requested_model, model, model_id,
api_provider, reason}. Free models (every used rate is 0), requests
without usage, and unmapped models stay silent. The diagnostic rides on
the standard logging payload as zero_cost_diagnostic
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
| ) | ||
|
|
||
|
|
||
| def _cause(diagnostic: StandardLoggingZeroCostDiagnostic) -> str: |
There was a problem hiding this comment.
Fixed in 535b442: the exhaustive match now returns assert_never in its fallback arm, so every path returns explicitly.
There was a problem hiding this comment.
Correction: CodeQL still flags this at the tip because it does not model match exhaustiveness. Every arm returns explicitly, assert_never included
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
bugbot run |
…tween two zero-cost findings
|
bugbot run |
| if finding is None or self.zero_cost_warned: | ||
| return | ||
| self.zero_cost_warned = True | ||
| verbose_logger.warning(finding[1]) |
There was a problem hiding this comment.
Fires only when the model resolved to a pricing entry; free-form request text reaches it only via a wildcard deployment with custom pricing
…its, count failure rows
|
bugbot run |
|
bugbot run |
|
bugbot run |
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 9526660. Configure here.
…aying at $0 The zero-cost diagnostic tests from #42345 used a per-second-only entry as their misconfigured fixture, which this branch now bills. Switch that fixture to a per-query-only entry, which is still selected as the deployment's own pricing and still prices chat usage at $0, and add a per-second test asserting the call duration is billed with no diagnostic Also let a caller's explicit total_time outrank the logging window in completion_cost, so the SDK precedence stays stamped response, caller, logging
…ery provider (#42403) * fix(cost): honor per-second custom pricing on chat completions for every provider * test(cost): assert a per-second priced deployment bills instead of staying at $0 The zero-cost diagnostic tests from #42345 used a per-second-only entry as their misconfigured fixture, which this branch now bills. Switch that fixture to a per-query-only entry, which is still selected as the deployment's own pricing and still prices chat usage at $0, and add a per-second test asserting the call duration is billed with no diagnostic Also let a caller's explicit total_time outrank the logging window in completion_cost, so the SDK precedence stays stamped response, caller, logging * test(response_metadata): move the per-second pricing regression into the mapped tests/unit file * fix(cost_calculator): keep media-mode per-second rates off the wall-clock path A video, transcription, speech, or realtime entry's per-second rates price media seconds, which their dedicated cost paths bill from the media itself. The generic per-second branch now skips those modes, so a video status poll on a per-second video model bills nothing instead of the seconds the poll took to answer. --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
…v1/messages (#42417) * fix(cost): honor per-second custom pricing on chat completions for every provider * test(cost): assert a per-second priced deployment bills instead of staying at $0 The zero-cost diagnostic tests from #42345 used a per-second-only entry as their misconfigured fixture, which this branch now bills. Switch that fixture to a per-query-only entry, which is still selected as the deployment's own pricing and still prices chat usage at $0, and add a per-second test asserting the call duration is billed with no diagnostic Also let a caller's explicit total_time outrank the logging window in completion_cost, so the SDK precedence stays stamped response, caller, logging * test(response_metadata): move the per-second pricing regression into the mapped tests/unit file * fix(cost): bill a deployment's per-second rates on /v1/responses and /v1/messages The proxy builds the request's logging state before the router picks a deployment, and only the chat path re-read the deployment's input_cost_per_second / output_cost_per_second afterwards. The shared update step every other route runs (Logging.update_from_kwargs) now seeds those custom pricing keys from the router-merged kwargs too, so custom_pricing flips on and the cost calculator prices the call against the router-registered deployment id on every surface. * fix(cost): price a /v1/messages call off the response time the proxy reports A /v1/messages result is a plain dict, so the proxy keeps its response time on the logging object. The cost step now reads it there for a non-streamed call, so the cost header and the spend log bill the same duration. * fix(anthropic): bill a deployment's per-second rate only on the native /v1/messages route Move the custom pricing copy from the shared logging refresh into the native Messages handler, reusing the helper the Responses handler already had, so generateContent and other routes keep their current billing * fix(cost): pass only per-second rates to native /v1/messages cost tracking Other deployment overrides keep billing as on main, matching chat's per-second gate * test(anthropic): pin per-second-only pricing on native /v1/messages with a long-context-rate deployment * fix(cost): bill native /v1/messages from logging setup, as main did, to the end the proxy reports --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
TLDR
Problem this solves:
How it solves it:
litellm_zero_cost_requests_total{requested_model, model, model_id, api_provider, reason}missing_pricing_key,pricing_not_applied,cost_calculation_errorzero_cost_diagnostic), Grafana panel addedUser Flow
Before
The operator only finds out days later, from $0 spend rows on a priced deployment, that a pricing key was missing, and nothing in the logs or metrics pointed at it
per-second-priced-chat(openai/gpt-5.4-nanowithinput_cost_per_secondandoutput_cost_per_secondset, no per-token rate), a deploymentfree-chat(same model,input_cost_per_token: 0andoutput_cost_per_token: 0inmodel_info) and a plaingpt-5.4-nanodeployment to the proxy config, turns on theprometheuscallback and boots the proxyPOST https://litellm-domain/v1/chat/completionswith{"model": "per-second-priced-chat", "messages": [{"role": "user", "content": "Say hi in three words"}]}and gets a 200 whose body carriesusage.prompt_tokens: 11andusage.completion_tokens: 7, withx-litellm-response-cost-input: 0.0andx-litellm-response-cost-output: 0.0in the headers"stream": trueand"stream_options": {"include_usage": true}and the final chunk carries the same kind of usage, again priced at $0free-chatand againstgpt-5.4-nano: thefree-chatresponses are $0 too, thegpt-5.4-nanoones carryx-litellm-response-cost: 1.22e-05https://litellm-domain/ui/?page=logs: theper-second-priced-chatrows show spend$0next to 11 prompt and 7 completion tokens, indistinguishable from thefree-chatrows, and onlygpt-5.4-nanoshows a non-zero spendWARNINGorERRORand finds nothing about any of these requestsGET https://litellm-domain/metrics/with the admin key and finds no series about zero-cost requests, so nothing can be alerted on and the $0 rows go into the bill as truthAfter
The $0 request on the per-second deployment now logs one warning naming the deployment and the two missing per-token rates and shows up in
litellm_zero_cost_requests_total, whilefree-chatandgpt-5.4-nanostay silentper-second-priced-chat(openai/gpt-5.4-nanowithinput_cost_per_secondandoutput_cost_per_secondset, no per-token rate), a deploymentfree-chat(same model,input_cost_per_token: 0andoutput_cost_per_token: 0inmodel_info) and a plaingpt-5.4-nanodeployment to the proxy config, turns on theprometheuscallback and boots the proxyPOST https://litellm-domain/v1/chat/completionswith{"model": "per-second-priced-chat", "messages": [{"role": "user", "content": "Say hi in three words"}]}and gets a 200 whose body carriesusage.prompt_tokens: 11andusage.completion_tokens: 7, withx-litellm-response-cost-input: 0.0andx-litellm-response-cost-output: 0.0in the headers"stream": trueand"stream_options": {"include_usage": true}and the final chunk carries the same kind of usage, again priced at $0free-chatand againstgpt-5.4-nano: thefree-chatresponses are $0 too, thegpt-5.4-nanoones carryx-litellm-response-cost: 1.22e-05https://litellm-domain/ui/?page=logs: theper-second-priced-chatrows still show spend$0next to 11 prompt and 7 completion tokens, since this change flags the $0 instead of repricing itWARNINGand finds exactly one line perper-second-priced-chatrequest,Billable request priced at $0 and logged as such (model_group=per-second-priced-chat model=openai/gpt-5.4-nano provider=openai prompt_tokens=11 completion_tokens=7): pricing entry '<deployment id>' has no input_cost_per_token, output_cost_per_token. Set the missing rate in the deployment's model_info or in the model cost map, or set every rate to 0 to mark the model free. Counted in litellm_zero_cost_requests_total{reason="missing_pricing_key"}, and no such line forfree-chatorgpt-5.4-nanoGET https://litellm-domain/metrics/with the admin key and findslitellm_zero_cost_requests_total{api_provider="openai",model="openai/gpt-5.4-nano",model_id="<deployment id>",reason="missing_pricing_key",requested_model="per-second-priced-chat"} 2.0, one count per request, and no series forfree-chatorgpt-5.4-nano, so the missing rate can be alerted on the day it starts costing moneyRelevant issues
Docs: BerriAI/litellm-docs#1608
Affected release
Linear ticket
Resolves LIT-7898
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Both legs run the same flow against the same topology and differ only in the commit the proxy is booted from: a fresh Postgres database per leg,
--num_workers 2, theprometheuscallback, real OpenAI calls, and this config (the four deployments the User Flow names plus the publishedgpt-5-nanoas the priced control)The proxy reads its cost map from
LITELLM_MODEL_COST_MAP_URL, a locally served copy ofmodel_prices_and_context_window.jsonwheregpt-5.4-nanoandgpt-5.4-nano-2026-03-17hadinput_cost_per_tokenandoutput_cost_per_tokenremoved with their audio rates kept, so the run also covers a published entry that lost its per-token rate. That makes plaingpt-5.4-nanoa second $0 deployment here rather than the priced control the User Flow describes, andgpt-5-nano(published rates untouched) plays that priced control instead.PROMETHEUS_MULTIPROC_DIRis set so/metrics/aggregates both workersRates the proxy resolved per deployment, identical on both legs (
/model/info, reduced to the relevant keys)Before (1baa26d)
Proxy booted from
1baa26d36bon port 27790 with--num_workers 2/v1/chat/completions
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)/v1/messages
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)/v1/responses
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)Spend logs
Metrics
litellm_spend_metric_totalis split per service tier, so two series per deployment)Proxy log
After (fb9c202)
The
litellm/tree offb9c2020ddis byte-identical to4088ac4982, which touches onlytests/test_litellm/. The tip95266607bcis that tree plus the merge ofmainatccafff8b68(bringing #42385, which prices a terminal Responses stream event by its inner response;_response_cost_calculatorhands that samepriced_resultto the diagnostic, so it judges what the calculator priced), a regression test for that routing at2fccf559df, and the generated OpenAPI snapshot restored at95266607bc. The one cell of this run the merge can change is/v1/responsesstreaming, where the completed event now carries usage into the diagnostic:test_terminal_responses_stream_event_is_judged_by_its_inner_responsecovers it for the per-second and free deployments and fails when the diagnostic is handed the event wrapper instead, and CircleCI'sintegration-costjob atccafff8b68(483 tests, 0 failures, 12 of them Responses API cases against the live provider through the proxy) shows the priced path unchanged. The/v1/responses at 95266607bcblock below re-runs that surface live at the tipProxy booted from
fb9c2020ddon port 46283 with--num_workers 2/v1/chat/completions
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)/v1/messages
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)/v1/responses
x-litellm-*headers and the usage object)x-litellm-*headers and the usage object)/v1/responses at 9526660
Same config, cost map, and prompt as above, against a proxy booted from the tip
95266607bcon port 36318 with--num_workers 1and a fresh spend database, so the merge of #42385's terminal-event routing is proven on the wire and not only by its unit test. Output filtered to thex-litellm-*headers; the usage line is dropped here because the display filter above mis-capturesoutput_tokens(it prints 0 for every call), and the spend rows below carry the token counts the proxy loggedGET /spend/logs?start_date=<today>&end_date=<tomorrow>&summarize=false, one per request, streams included)GET /metrics/, filtered tolitellm_zero_cost_requests_total): one increment per $0 request on the two deployments whose pricing entry lacks the per-token rates, both streams counted, nothing forfree-chatorgpt-5-nanogrep 'priced at \$0'): exactly four warnings, one per $0 request on those two deployments, each naming the model, the pricing entry, and the two missing keys; no line forfree-chat(every rate 0) orgpt-5-nano(priced)Spend logs
Metrics
litellm_spend_metric_totalis split per service tier, so two series per deployment)Proxy log
Surprises
/v1/messages,/v1/responses: PR leaves alonex-litellm-response-costheader absent on $0 responses: PR leaves alonelitellm_spend_metric_totalsplit perservice_tier, two series each: leaves alonemodel=and pricing entry vary between passes: PR causesgpt-5-nanoon/v1/messagesreportsoutput_tokens: 0, priced5.5e-07: leaves aloneautorouter_baseline_cache.py:180warning on every boot: PR leaves aloneType
🆕 New Feature
Caveats (if any)
Low
Custom per-second pricing on an
openai/chat deployment prices to $0 today (pre-existing:cost_per_tokendispatchesopenaito its per-token calculator before the generic branch that honors per-second rates, so this PR only surfaces it, as the QA flow shows). Left unfixed here because repricing is a cost-calculation decision the ticket did not ask for (whether chat honors per-second rates at all, or config load should reject them) and the warning now names the two per-token keys to set; tracked as LIT-8315pricing_not_appliedcovers "entry has the rate, cost still $0": it names no key, so the log line and thereasonlabel are the lead. Left as is because the only way to name more would be re-deriving why the calculator returned $0 inside the warning path, which duplicates the calculator for a case no run has hit yet, while the pricing entry, model, provider, and usage in the line already narrow itThe counter is unbounded only by model labels the other metrics already carry,
reasonhas three valuesx-litellm-response-costis absent (not0.0) on a $0 response, pre-existing and untouched hereCircleCI
integration-cost(23 failures, job 2198806) andintegration-providers(1 failure, job 2198811) were red at4088ac4982and identically red onmain's own pipelines 90021 (ef8103a, jobs 2198752/2198753) and 90023 (9fad216, jobs 2198864/2198859), which carry none of this PR's code: 22 Responses API streams (native and chat-bridged) logging an all-zerocost_breakdownwhilespendis right, traced to feat(edenai): add Eden AI provider across chat, Responses, Messages, embeddings, audio, images and video #41101's copy of litellm's own stampedusage.costinto the provider-cost hidden param (LIT-8313, fixed onmainby fix(logging): price terminal Responses stream events from their inner response #42385), thegpt-5.6-responses_previous_response_idcase test(integration): endpoint, breakdown component and failure support in the cost harness #41999 added, and the fal H3 video wire test from feat(fal_ai): add MiniMax H3 text-to-video and reference-to-video #42286 and fix(fal_ai): surface fal errors in video status and content instead of completed and generic 500 #42306 (LIT-8312). Since the merge ofmainatccafff8b68both jobs are green on this branch (integration-cost, 483 tests, 0 failures; integration-providers, 27 tests, 0 failures)Four
build_and_testjobs, none a required check, are red at the tip with the failure setsmain's own pipelines 90021 and 90023 carry:llm_translation_testing, 12 failures (ten fireworks_ai translation cases, a hosted_vllm optional-params unhashable list, a bedrock moonshot stream; branch, main);local_testing_part1, 2 bedrock capability-parity cases intest_get_model_info(branch, main);unit, 1 timing budget,test_scan_message_stays_linear_on_adversarial_credential_lines[assignment-flood]at 11.5s against 10s (branch, main); andusing_litellm_on_windows, whose Install Dependencies step (uv syncdownloads) hit the 10-minute no-output timeout before any test ran (branch, main, the same step and timeout).litellm_router_unit_testingis green at the tip (job 2199359) and failed once atccafff8b68(job 2199271) ontest_acompletion_stream_counts_request_before_headers_and_tokens_once_on_completionwith(11, 0) == (11, 1): the router keys rpm and tpm by%H-%M, so a run that straddles a minute boundary counts the request in one minute and the tokens in the next, which is that exact shape; the file is untouched by this PR, passes 151/151 locally at the tip, and is green onmain's 90021 and 90023Two CodeQL alerts stay open at the tip, both answered in their review threads and neither blocking (the CodeQL check-run is green):
py/mixed-returnson_causeinzero_cost_diagnostic.py, where everymatcharm returns explicitly withassert_neverin the fallback arm and CodeQL does not modelmatchexhaustiveness, andpy/log-injectionon the warning line inlitellm_logging.py, where the logged value is the pricing entry's name, reachable from request text only through a wildcard deployment that carries custom pricingDecisions
missing_pricing_keywhen the usage needs a rate the entry does not declare,pricing_not_appliedwhen the entry declares every rate the usage needs but the total still came out $0,cost_calculation_errorwhen the calculator raised on a request that carried usage against a known pricing entry. Alternative considered: one reason, rejected because the fix differs per reasoninput_cost_per_token,output_cost_per_token, and the audio variants when audio tokens are present) is explicitly0in the entry. Cached tokens count as text input. Alternative: "all rates in the entry are 0", rejected because a Gemini audio request against a text-only entry would look freelitellm.model_cost[key], or the deployment'smodel_infowhen not registered), never onget_model_info, which defaults absent rates to 0 and hides the gap. An entry "declares a rate" when any key containingcostorpricingholds a positive number, recursively through nested mappings and lists (tiered pricing), validated with a pydanticTypeAdapterinstead of a castresponse_cost_failure_debug_information.cost_calculation_errortherefore requires a resolved pricing entryhidden_params["response_cost"]copy-through, so a $0 precomputed early (LIT-3057) is flagged too. Both sites skip unbilled non-inference call types (get_responses,list_input_items, vector store reads, and so on) the same way the calculator doesadditional_response_cost, so a $0 model cost with a positive additional cost is not flaggedresponse_cost = Nonemeans "not computed", not $0: the hook stays silent on ithidden_paramscopy-through, and on the Anthropic and Responses bridges a second pass that resolves a different cost-map key,gpt-5.4-nano-2026-03-17thengpt-5.4-nano), and router retries reuse it too. The diagnostic stored is the last evaluation, so a later evaluation that prices above $0 clears it and a retry that lands on a priced deployment is not counted. The warning is emitted on the first $0 finding and azero_cost_warnedflag on the logging object keeps every later finding silent, whatever was evaluated in between. Alternatives: warn whenever the diagnostic changes, rejected because the bridged routes then logged two lines per request; warn whenever a finding lands while no diagnostic is stored, rejected because the streaming bridges evaluate the usage-less completed event between two findings and logged two lines per streamed request (both caught by QA at earlier tips)model_infodict), then the cost map by the selected cost model, the response model, and the requested model, in that order, matching what the calculator prices againstprompt_tokens: "n/a") is covered by a regression testrequested_model,model,model_id,api_provider,reason.reasonis added only whenprometheus_metrics_configlabel filters keep it, so a filtered config does not raise on.labels()StandardLoggingPayload(zero_cost_diagnostic), so every logging integration can consume it, not only PrometheusLiteLLMlogger once per request and names the counter and reason label, so the log line and the metric cross-reference each othercost_calculator._get_usage_objectbecame publicget_usage_objectinstead of a private cross-module importinput_cost_per_secondon anopenai/chat deployment prices to $0, open PR fix(cost): compute timing metrics before response_cost for input_cost_per_second pricing #31558) is out of scope and only surfaced by this changereduceinstead of recursion, so a malformed entry can never loop or overflow the stackcost_calculation_errorbranch, so a free model whose cost calculation errored, or a metadata-only entry with nothing to compare against, is not counted as a mispriced request (review findings at the two previous tips)model_infois the pricing entry the request is judged against; the global cost-map entry keyed by the model name is consulted only for a registered router id, so an operator-declared free deployment is never judged by the published rates (review finding at the previous tip)custom_pricingfor both the calculation and the diagnostic so the two cannot drift again (review finding at the previous tip)cache_hitis set instead of warning about a request the provider was never billed for (dependency walk at the previous tip)litellm_zero_cost_requests_totalthe way the success event does, and the warning's "Counted in" line holds on both paths. The failure event's label values gainedrequested_modelandapi_providerso the counter carries the same labels on both paths; the other failure metrics filter to their own label sets and are unchanged (dependency walk at the previous tip)/live-pr-risk
Verdict: no breaking change and no regression on any dependent path this run drove live; the additive contract changes are listed below for the record. The dependency graph was walked at
fb9c2020ddtwice (one sweep over the hidden reference kinds, one target list built from the diff alone, reconciled here), the code that commit added got its own walk,4088ac4982and2fccf559dfchange onlytests/test_litellm/, and95266607bcrestores a generated file. Merge-ref drift:mainmoved 165 commits from the merge base1baa26d36bto9cc5b78c33with none touching the seven code files this PR changes, then #42385 (3bbbf7f693) changedlitellm_logging.pyunder this PR's hook, somainatb720909dacwas merged in atccafff8b68:_response_cost_calculatornow prices a terminal Responses stream event by its inner response, and the conflict was resolved by handing thatpriced_resultto_custom_pricing_for, to the cost calculation, and to all three_record_zero_cost_diagnosticcalls, so the diagnostic judges the response the calculator priced (regression testtest_terminal_responses_stream_event_is_judged_by_its_inner_responseat2fccf559df, which fails when the event wrapper is passed instead). Since that mergemaingained five commits to5d3d99eb9f; two touchlitellm/types/utils.pyin hunks disjoint from this PR's (echoed_cost_map_fieldsfrom #41944, image serialization from #42336), andgit merge-treeof the tip ontoorigin/mainis cleanBreaking
None observed. Evidence: run 5 above, base
1baa26d36bvs headfb9c2020dd, each on two uvicorn workers, over/v1/chat/completions,/v1/messagesand/v1/responses, streaming and non-streaming, against the same three deployments. Both legs answer 200 with the same usage and the samex-litellm-response-cost*headers, both write 24 spend rows with the samespendvalues (/spend/logs?summarize=false), and the head differs only by the 12 warning lines and the twolitellm_zero_cost_requests_totalseries it adds. The SDK path was A/B'd the same way at1baa26d36band4088ac4982:litellm.completionand the streamed variant under both trees, with aCustomLoggercapturingstandard_logging_object, reportresponse_cost: 0.0on both sides, and only the head carrieszero_cost_diagnostic(missing_pricing_key,gpt-5.4-nano-2026-03-17,input_cost_per_tokenandoutput_cost_per_token) and one warning line per callBackward incompatible
litellm.cost_calculator._get_usage_objectis now the publicget_usage_object. At the merge base the name has zero references outsidecost_calculator.pyacross the repo (ui/,tests/,enterprise/,cookbook/, notebooks) and both docs checkouts, so no caller,patch(...)string, or docs page depends on the old oneStandardLoggingPayloadgainszero_cost_diagnostic(None, orreason/pricing_model/missing_pricing_keys, the last a tuple that serializes as a JSON array). Additive: every whole-payload sink goes throughsafe_json_dumps(Datadog, Azure Sentinel, SQS, S3, PostHog, generic API, Azure Storage) orjson.dumps(default=str)(GCS); the whole-payload forwarders (Braintrust metadata, LangSmith inputs, Rubrik, Noma) ship it as JSON; OTEL sets attributes by explicit key and never enumerates the payload; the fixed-field mappers (MLflow, PostHog, New Relic, Datadog LLM Obs, Langfuse, Argilla, Literal AI, PagerDuty, Datadog cost management) read named keys only. No payload-shaped pydantic model forbids extras (the oneextra: "forbid"underintegrations/is the OTEL config object). Traced, not drivenUserAPIKeyLabelValuesgainsrequested_modelandapi_provider.litellm_llm_api_failed_requests_metricfilters to its own label set and is unchanged (test_prometheus_zero_cost_metric.py,test_prometheus_invalid_key_filtering.py);_extract_status_codeand_should_skip_metrics_for_invalid_keyread onlystatus_codelitellm_zero_cost_requests_total, registered inDEFINED_PROMETHEUS_METRICSandPrometheusMetricLabels. Under aprometheus_metrics_configallowlist that excludes it the counter factory returns a no-op metric, and a label filter that dropsreasonstill counts (test_label_filter_that_drops_reason_still_counts_the_request). It is deliberately not in_org_label_metrics, so it never gets the auto-appended org labelslitellm_spend_metriccarriesLiteLLMlogger, ungated byset_verbose. On the Anthropic and Responses bridges itsmodel=names the cost-map key the bridge priced with (Decision 8, the "vary between passes" surprise above)Regression risk
Loggingobject (router.pythreadslitellm_logging_objthrough both). The stored diagnostic is the last evaluation, so a retry that lands on a priced deployment is not counted, but a warning already printed for the $0 attempt stays printed. Unit-tested on the logging object (TestZeroCostDiagnostic), not driven through a live fallback configLoggingobject through_reset_success_emission_dedupe, which pops the success dedupe markers and notzero_cost_warned: the settled poll's payload and counter are right, a second warning line is not printed. Not booted herepricing_entry_for_cost_calcruns once more per $0-priced response, in the response path: twolitellm.model_costlookups plus model-name selection. Not measured; a proxy with a large custom cost map and mostly $0 traffic is the shape that would notice_record_partial_usage_for_failure, the Responses iterator's_record_failed_response_usage, the realtime websocket) reach the counter through the failure event added atfb9c2020dd. Covered by the hand-built failure payload test, not by a provider stream cut mid-wayDependency graph
tested = unit test through the changed code; live = driven base vs head in run 5; traced = read, not run; unreachable = no environment in this run
_response_cost_calculatorviaupdate_response_metadata(chat, completions, embeddings, images, audio, moderations, rerank, responses non-stream): live for/v1/chat/completionsand/v1/responses, tested at method level for the rest_process_hidden_params_and_response_costcopy-through (the second pass, LIT-3057's precomputed $0): live on all six route and stream cells, tested_logging_obj_cost_or_noneand the streaming success handler: live (streaming cells withstream_options.include_usage)_response_cost_from_logging_objfor dict responses: live for/v1/messages, Google:generateContenttraced_stamp_responses_usage_cost: live (/v1/responsesstreaming)get_standard_logging_object_payload: tested (thecache_hitguard clears the diagnostic), not live_record_partial_usage_for_failure,_record_failed_response_usage, realtime partial usage, guardrail-rejected stream viarecord_assembled_response_for_failure): tested at the Prometheus failure event, not live0.0(/anthropic/*,/vertex_ai/*,/bedrock/*): traced, same copy-through site_turn_cost(once per turn): unreachablelitellm.completionwith a callback: live base vs head (below); SDK streaming_stamp_streaming_usage_costand_response_cost_calculator_async: traced_custom_pricing_for(added atfb9c2020dd): two callers, both private inlitellm_logging.py; PTU spillover tested both ways (test_ptu_deployment_is_judged_by_the_entry_the_calculator_priced_with)cache_hitread by_record_zero_cost_diagnostic: written in_success_handler_helper_fn, testedreasonlabel filter: tested (four tests) and live (/metrics/scrape, two series at 6.0)ui/: the field is written to no column andui/litellm-dashboard/srchas no reference to it; spend rows compared live, 24 rows each leg with identicalspendget_usage_objectrename: tested (import and call), zero external dependentscookbook/litellm_proxy_server/grafana_dashboard/dashboard_all_metrics/): additive panel, file parses, not imported into a Grafanacost_tracking.md,prometheus.md,logging_spec.md)Not verified
BidiGenerateContentwebsocket): no Vertex Live session in this runlitellm.cacheon: unit test only/v1/realtime, guardrail-rejected streams: unit test at the failure event only0.0: not drivencost_calculator.py,litellm_logging.py,prometheus.py,llm_cost_calc/, types), so base vs head parity of the wire request is read off the diff, not recordedFinal Attestation
Every required check is green at the tip. CircleCI's
integrationworkflow (integration-cost,integration-providers) is green on this branch since the merge ofmainatccafff8b68; the four non-requiredbuild_and_testreds are classified in the Low caveats above, each with its identical failure onmain's own pipelines