Skip to content

chore(backport): billing fixes for LIT-145 and aiohttp 3.14.4 onto stable/1.105.x (1.105.3) - #47714

Merged
yuneng-berri merged 29 commits into
stable/1.105.xfrom
litellm_backport_lit145_batch_stable_1_105_x
Oct 21, 2026
Merged

yuneng-berri merged 29 commits into
stable/1.105.xfrom
litellm_backport_lit145_batch_stable_1_105_x

Conversation

@klu-berri

@klu-berri klu-berri commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • stable/1.105.x lacks the LIT-145 billing fixes merged to main this week
  • Proxy spend rows for timed-out, cancelled and retried requests were unpriced or mispriced on this line
  • The line's lock still carried the aiohttp advisories fixed in 3.14.4

How it solves it:

  • Cherry-picks 26 merged main PRs onto stable/1.105.x in main's merge order, one commit per PR
  • Adapts each pick to the line's own helper names and drops only main-only tests
  • Bumps aiohttp to 3.14.4 (yarl to 1.25.1) lock-only, then bumps the stable version to 1.105.3

Linear ticket

Resolves LIT-145

Picks

Source PRs in the order they were applied, each a single commit carrying its main squash sha in the body

Source PR Commit on this branch
#47183 7f233c6 fix(decisions): log every request field the caller sent on /v1/systemone and /v1/decisions
#47406 2e1879d feat(router): let a deployment set a timeout per service_tier
#47373 146df23 fix(cost): bill Gemini audio/image/video prompt tokens at the resolved input rate when no modality rate exists
#47394 da21169 fix(anthropic): apply tool_config cache-control points on chat and /v1/messages
#47435 be57872 fix(proxy): price the estimated input tokens on a read-timed-out request's spend row
#47456 6526d62 fix(logging): do not stamp a provider handoff when pre_call runs for a proxy-only failure
#47460 75a8b13 fix(vertex_ai): bill per-character text embeddings on Google's billableCharacterCount
#47466 68140a5 fix(batches): apply the Vertex regional endpoint uplift to batch cost
#47436 7e85fb8 fix(proxy): price the estimated input tokens on a client-cancelled (499) request's spend row
#47437 b7cad5b fix(proxy): price a billed failure row at the deployment's own rate like the success path
#47567 0be634a fix(logging): report the pay-as-you-go entry billing used on Azure PTU spillover
#47570 7312d21 fix(litellm_proxy): forward tool_config cache_control_injection_points to the downstream proxy
#47564 627b667 fix(decisions): log non-UTF-8 bytes as base64 so the request reaches validation and gets a 400
#47490 a9bb556 feat(proxy): lift every earlier billed timed-out retry attempt onto the failed request
#47571 1ef27b4 fix(proxy): requeue spend logs when a Postgres restart tears down the prisma engine mid-write
#47416 fd5eec9 feat(proxy): write one spend row per billed timed-out retry attempt
#47494 7ffaaab feat(proxy): opt-in free-tier allowance for Google Search grounding spend
#47614 4ef6f61 fix(proxy): flush the spend-log queue only for Responses turns the bridge reads back
#47611 9fa4898 fix(proxy): bill partial Responses API streams when the client disconnects
#47639 e4c41e9 fix(proxy): strip caller base_model from spend pricing and reject lone surrogates in multipart metadata
#47647 5912122 fix(proxy): price a billed failure row at the deployment's long-context tier like the success path
#47646 c83536c fix(proxy): scope the search free-tier counter to the request's provider
#47652 35204c3 fix(proxy): price a 499 spend row only for the proxy's own disconnect, and never after the call already completed
#47617 011c464 fix(router): price cost-based routing through model_info.base_model
#47648 063f75d fix(proxy): price earlier timed-out retry attempts at their own deployment's model rate
#47655 b15bb3e fix(logging): spilled over PTU requests without base_model log the served model's rates
deps fb6ed32 chore(deps): bump aiohttp to 3.14.4 in uv.lock
version 1509e15 chore(release): bump version to 1.105.3

Empty pick: #47565 is not applicable to this line. It fixes _tool_carries_ephemeral_mark, a helper #46411 added on main only; the line's prompt_caching_cache.py has no tool cache_control helpers and no tests/unit/router_utils/test_prompt_caching_cache.py

Adaptations to the line

Each pick keeps main's behavior and only swaps in the names this line has

Verification

Picked tests: every changed test file was run with the line's own venv (uv sync --frozen --extra proxy --group dev --group proxy-dev --group ci). All pass except two pre-existing environment failures that fail identically on the stable/1.105.x base: TestPrismaClientTokenAuthBehindThePool (needs prisma generate) and test_router_timeouts (needs REDIS_PORT)

Identifier checks: ruff check --select F821 over every changed file is clean, basedpyright --level error over the changed files reports zero reportUndefinedVariable, and every changed litellm/ module imports in the line's venv

Grype on uv.lock: aiohttp 3.14.3 had fixes at 3.14.4 (main is on 3.14.5), bumped lock-only with uvx uv@0.11.7 lock --upgrade-package aiohttp==3.14.4, which moves yarl to 1.25.1. Still reported, no lock-only fix available on this line: claude-agent-sdk 0.1.44 GHSA-h4mw-j7qp-8mwm (Critical, fix is 0.2.121 but pyproject.toml pins ==0.1.44), mlflow 3.15.0 GHSA-h7x2-h6g9-p789 (High, no fixed version listed), diskcache 5.6.3 GHSA-w8v5-vhqr-4h9v (Medium, no fix, main has it too)

Integration and e2e runs on the line venv, base of stable/1.105.x vs this branch where a failure needed classifying. tests/integration groups through a hand-started rig mirroring .circleci/scripts/run_integration.sh (scripted upstream on 8190, proxy on 4000, fresh Postgres 14 db per group, local Redis): cost 483 passed, 2 failed, both the claude-sonnet-5 stream_no_usage recount pins (48 vs pinned 47, 303 vs 301) and both fail the same way on the base, main already pins 48 and 303; database 35 passed; accounting 285 passed, 18 failed, 2 errors, of which 16 failures and both errors are KeyError: general_settings or litellm_settings because the line's tests/integration/proxy_config.yaml carries only a model_list, and the other two (test_cache_and_quota) fail identically on the base; providers 446 passed, 65 failed, 20 errors, all of them missing google.genai in the venv, the same truncated proxy config, the bedrock_runtime_peer collection error, or files that fail with the same counts on the base (test_decisions_wire, test_decisions_openai_format_wire, test_responses_bridge_stream_options: 6 failed 69 passed on both; the anthropic reasoning wire file: 1 failed 47 passed on both). tests/e2e against a live proxy on this branch with real OpenAI, Anthropic and Gemini: llm_translation (chat, stream, messages, responses, bridge streaming, custom pricing, cache control, embeddings, tool round trip) 58 passed, 3 failed, all three needing Azure or Cohere deployments the rig has no credentials for; quota_management/budgets 42 passed, 1 failed (test_cold_counter_reseed opens a RedisCluster, the rig runs a standalone Redis, same failure on the base); router 31 passed, 3 failed, 1 error, all Azure deployment, idle RSS budget or a model-create race in the rig. None of these failures are new on this PR: every one either fails identically on the base of stable/1.105.x (fc43640) or comes from the local rig (missing credentials, standalone Redis, missing google.genai, the line's truncated integration proxy config)

Gauntlet-mini relay

Run in degraded mode (no Agent tool in this session): the five lenses were run by hand against /tmp/wt_stable_1_105_x with base git merge-base origin/stable/1.105.x HEAD and the diff at /tmp/gm-diff-stable_1_105_x.patch, so this is slower and weaker than the fan-out

Headline: SURVIVED. Sub-claims: changed identifiers resolve (ruff F821, basedpyright undefined-variable, importer scan: all clean); picked tests pass against the line's own baseline (all green, two baseline-only environment failures listed above); callers on the line of the modified functions still work (tests/unit/proxy/hooks 943, tests/unit/responses 880, tests/unit/llms/anthropic 2158, tests/unit/router_utils 811, tests/unit/proxy/common_utils 1160, tests/unit/batches 215, tests/unit/decisions 87, tests/unit/litellm_core_utils/llm_cost_calc 323, tests/unit/proxy/db 1150 passed with the same 22 prisma-generate failures as the base); bumped deps behave (aiohttp 3.14.4 and yarl 1.25.1 import, tests/unit/llms/custom_httpx 356 passed); blackbox smoke of litellm.completion, Router.acompletion with base_model, a routed timeout and proxy_server.app import all succeed

Confirmed findings: none. Strongest dissent: the four picked tests that called main-only public names (handle_completed_batch, ProxyDBLogger, select_model_name_for_cost_calc, response_cost_calculator) failed on the first run and were rewritten to the line's private names inside their pick commits; the dropped #47490 test was the only one asserting main-only behavior. Per-lens: correctness 0 confirmed, dependents 0, blackbox 0, contract 0 (basedpyright rule histogram on the changed files moved only in the Unknown*/Any budget rules), conventions 0 (the added comments are the source PRs' own). Coverage notes: the live proxy leg on this line is in Screenshots / Proof of Fix (run after the relay), no gauntlet ledger row written

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • 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

Live leg on this line, no mocks: two proxies started from the line's venv with python litellm/proxy/proxy_cli.py --config <cfg> --port <port> --use_v2_migration_resolver, base = origin/stable/1.105.x worktree on port 4100 with Postgres 14 db litellm_105_base, tip = this branch on port 4200 with db litellm_105_tip, real OpenAI (openai/gpt-5.4-mini, $0.75/M input, $4.50/M output in the line's cost map), prisma generate run first. Same config on both legs apart from database_url:

model_list:
  - model_name: slow-mini
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
      timeout: 1
  - model_name: fast-mini
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
router_settings:
  num_retries: 0
general_settings:
  master_key: sk-lit145
  database_url: os.environ/DATABASE_URL

Result: the base timeout row has 24 prompt tokens and spend 0, the tip timeout row has the same 24 prompt tokens priced at 24 x $0.75/M = 1.8e-05 (#47435). The fast-mini row prices identically on both legs: 12 x $0.75/M + 8 x $4.50/M = 4.5e-05

Before (fc43640, base of stable/1.105.x)

slow-mini hits the 1s timeout and gets a 408

  1. curl -s -o /dev/null -w "%{http_code}\n" localhost:4100/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"slow-mini","user":"lit145-base-timeout","messages":[{"role":"user","content":"Write a 3000 word essay on the history of the Roman aqueducts."}]}'
  2. Output: 408 (body: litellm.Timeout: APITimeoutError - Request timed out ... timeout value=1.0)

fast-mini succeeds

  1. curl -s localhost:4100/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"fast-mini","user":"lit145-base-ok","messages":[{"role":"user","content":"Say hi in three words."}]}' | jq -c "{content: .choices[0].message.content, usage}"
  2. Output: {"content":"Hi there, friend.","usage":{"completion_tokens":8,"prompt_tokens":12,"total_tokens":20,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0}}}

spend rows after ~10s

  1. psql -d litellm_105_base -c "select end_user, status, prompt_tokens, completion_tokens, spend from \"LiteLLM_SpendLogs\" where end_user like 'lit145-%' order by \"startTime\""
  2. Output:
      end_user       | status  | prompt_tokens | completion_tokens |  spend  
---------------------+---------+---------------+-------------------+---------
 lit145-base-timeout | failure |            24 |                 0 |       0
 lit145-base-ok      | success |            12 |                 8 | 4.5e-05
(2 rows)

After (1509e15)

slow-mini hits the 1s timeout and gets a 408

  1. curl -s -o /dev/null -w "%{http_code}\n" localhost:4200/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"slow-mini","user":"lit145-tip-timeout","messages":[{"role":"user","content":"Write a 3000 word essay on the history of the Roman aqueducts."}]}'
  2. Output: 408 (body: litellm.Timeout: APITimeoutError - Request timed out ... timeout value=1.0)

fast-mini succeeds

  1. curl -s localhost:4200/v1/chat/completions -H "Authorization: Bearer sk-lit145" -H "Content-Type: application/json" -d '{"model":"fast-mini","user":"lit145-tip-ok","messages":[{"role":"user","content":"Say hi in three words."}]}' | jq -c "{content: .choices[0].message.content, usage}"
  2. Output: {"content":"Hi there, friend.","usage":{"completion_tokens":8,"prompt_tokens":12,"total_tokens":20,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0}}}

spend rows after ~10s

  1. psql -d litellm_105_tip -c "select end_user, status, prompt_tokens, completion_tokens, spend from \"LiteLLM_SpendLogs\" where end_user like 'lit145-%' order by \"startTime\""
  2. Output:
      end_user      | status  | prompt_tokens | completion_tokens |  spend  
--------------------+---------+---------------+-------------------+---------
 lit145-tip-timeout | failure |            24 |                 0 | 1.8e-05
 lit145-tip-ok      | success |            12 |                 8 | 4.5e-05
(2 rows)

Source PR proofs replayed on the line

Each source PR's "Screenshots / Proof of Fix" was replayed against the base of stable/1.105.x (fc43640, port 41xx) and this PR's tip (1509e15, port 42xx), both from the line venv, each with its own Postgres 14 database, real OpenAI, Anthropic, Gemini and Vertex AI where the source used them and a local scripted upstream where the source used one. Rows were read with psql. Where the line's base already differs from the source PR's merge base the base column says so instead of forcing the source's Before

Source PR What the source proved Base fc43640 Tip 1509e15
#47435 read timeout (gpt-4.1, timeout 1.5, 2 retries) bills the prompt 408, one failure row, 28 prompt tokens, spend 0 408, three failure rows (one per attempt), 28 prompt tokens, spend 5.6e-05 each (28 x $2/M)
#47437 the timed-out row uses the deployment's own rate (input_cost_per_token 1e-05) spend 0 0.00028 per attempt row (28 x 1e-05)
#47436 client hang-up (curl --max-time 1) writes a priced 499 row row with 0 tokens, spend 0 row with 28 prompt tokens, spend 0. A proxy from origin/main (3985795) writes the same 28 tokens, spend 0 on this rig, so the line matches main, the priced row from the source proof did not reproduce on any build here
#47416 #47490 #47648 per attempt rows, fallback hop priced at the fallback deployment's rate, attempted_retries in metadata one failure row, 28 tokens, spend 0, retries 1 three failure rows, 2.1e-05 (gpt-5.4-mini, 28 x $0.75/M) and 7e-05 (fallback gpt-5.4, 28 x $2.5/M)
#47652 a provider's own HTTP 499 is a plain upstream failure, not billed failure row, spend 0 failure row, spend 0 (same, intended)
#47611 a stream the client kills after output started bills what was received only the chat row (success, 0.00329) chat row plus a Responses failure row (28 prompt tokens, 0.00014) and a Messages row (572 completion tokens, 0.0173)
#47639 caller base_model prices the row, lone surrogate in multipart metadata is rejected base_model request 7.5e-05 (ignored), transcription with a lone surrogate returns 200 and the proxy logs UnicodeEncodeError base_model request 0.0001125, client cutoff request 0.0003725, transcription returns 400
#47394 cache_control_injection_points tool_config on Anthropic Anthropic 400 "cache_control_injection_points: Extra inputs are not permitted", /v1/messages 6203 input tokens, 0 cached chat call 1 cache_creation_input_tokens 5873, call 2 cache_read_input_tokens 5873, /v1/messages reads 5873
#47570 litellm_proxy deployment forwards the injection point to the downstream proxy downstream rejects with the same 400, downstream log has 0 cache_control marks chain reads 5873 cached on chat and messages, downstream log shows 'cache_control': {'type': 'ephemeral'} 4 times
#47460 Vertex text-embedding-005 billed on billableCharacterCount 1.1e-06 (11 tokens x 1e-07), no character_count in usage_object 8.75e-07 (35 chars x 2.5e-08), usage_object character_count 35. gemini-embedding-001 1.35e-06 on both (per token model)
#47647 a timed-out 200k+ prompt is billed at the deployment's above-200k tier failure row 283625 tokens, spend 0 (line base predates timeout billing) failure row 283625 x 5e-07 = 0.1418125, control success row 0.0042918 on both
#47494 opt-in search free tier (allowance lowered to 7 in a served cost map) three grounded Vertex calls billed in full (0.126 + 0.014 + 0.014 tool cost), no Redis counter 4 + 1 + 1 queries freed, rows 0.00158 / 0.00145 / 0.00042 against original 0.0576 / 0.0155 / 0.0144, counter litellm:search_free_tier:vertex_ai:gemini-3:2026-10 = 6
#47646 counter scoped per provider no counter litellm:search_free_tier:gemini:gemini-3:2026-10 = 1 and vertex_ai:gemini-3 = 6, each provider gets its own allowance
#47406 timeout_by_service_tier (upstream answers flex after 8 s, timeout 3, flex 12) 408 at 3 s on chat and responses with service_tier flex 200 after 8 s on both, x-litellm-timeout: 2 still 408 at 2 s, default tier 200 at 0.05 s on both
#47567 spilled over PTU row logs the pay-as-you-go rates (base_model azure/gpt-4.1) row spend 0.0006, in_rate 0.000002, out_rate 0.000008, azure_spillover from_deployment ptu-gpt41 identical, the line's base already logged the rates for the base_model case
#47655 spilled over PTU row without base_model logs the served model's rates spend 8.25e-05, model_map_key azure/gpt-5.4-nano, rates 2e-07 / 1.25e-06 spend 8.25e-05, model_map_key gpt-5.4-nano, same rates
#47183 /v1/systemone and /v1/decisions log every caller field to s3_v2 saved object messages carry only the state / input text, instructions absent saved object carries the full request body, instructions present on both routes
#47564 non UTF-8 bytes in the SDK decisions input are logged and 400 proxy 400 on raw bytes; SDK logs the repr of the bytes and raises BadRequestError 400 (the line's base already differed from the source's UnicodeDecodeError) proxy 400 unchanged; SDK logs base64 __4gbm90IHV0Zi04 and raises BadRequestError 400
#47617 cost-based routing prices a deployment through model_info.base_model x-litellm-model-id openai-custom-priced x4, router log item_cost 10.0 for azure-claude-base-model x-litellm-model-id azure-claude-base-model x4, item_cost 1.8e-05
#47373 gemini-3.1-pro video tokens above 200k billed at the resolved input rate (cost harness case) cost harness case gemini-3.1-pro-fallback_video_tokens_above_200k FAILED, x-litellm-response-cost 0.55167 != expected 1.05567 (tip's cases json copied onto the base worktree) both cases PASSED (above_200k and at_input_rate), the rest of the cost suite 475 passed, 2 failed, the same two claude-sonnet-5 recount pins as in Verification
#47571 spend-log writer requeues rows across Postgres restarts 60 requests, 4 restarts, 53 of 60 rows land, proxy log shows AttributeError 'NoneType' object has no attribute 'get' and no requeue line 60 of 60 rows land, proxy log shows "Re-queued 2 rows for retry on next tick" during restart 4

Not replayed: #47466 (Vertex batch regional uplift) needs a GCS bucket for the batch input file and this rig has none, #47614 (Responses turn spend-log flush) needs the perf lane gateway with Postgres 17 pg_stat_statements and its mock provider servers, and #47456 has no curl-visible seam (the source proof is the hook-level unit test, which ran in the picked tests)

Known metadata caveat on #47494 and #47646: on the tip every grounded row's spend and the Redis counter are right, but in 6 of 10 rows metadata.cost_breakdown.discount_amount is 0.0 and total_cost is the pre-allowance value (a proxy from origin/main 3985795 was 7 of 7 consistent). The line does not have #47019 (fix(logging): keep the async request's logging payload when the sync success thread runs late), so the sync success thread can rebuild standard_logging_object while the free-tier hook awaits Redis and the row is built from the rebuilt payload. #47019 does not cherry-pick cleanly onto this line (conflicts in litellm_logging.py and caching_handler.py) and is not picked here, that is a separate decision

Group A, OpenAI timeout / disconnect / retry / partial stream billing (#47435 #47437 #47436 #47416 #47490 #47648 #47652 #47611 #47639), config /tmp/grpA_1105/config.yaml, real OpenAI

base


### A1 #47435 read timeout (gpt41-timeout, timeout 1.5, num_retries 2)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4100/v1/chat/completions -d '{"model":"gpt41-timeout","user"...
HTTP 408 in 9.954537s
[exit 0]

### A2 #47437 deployment rate on timeout row (gpt41-rate, input_cost_per_token 1e-05)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4100/v1/chat/completions -d '{"model":"gpt41-rate","user":"l...
HTTP 408 in 9.523361s
[exit 0]

### A3 #47436 client hangs up after 1s (gpt41-cancel, cancel_on_disconnect)
$ curl -s --max-time 1 -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4100/v1/chat/completions -d '{"model":"gpt41-ca...
HTTP 000 in 1.004284s
[exit 28]

### A4 #47416 #47490 #47648 one row per billed timed-out attempt (timeout-mini -> fallback-big, timeout 1, num_retries 1)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4100/v1/chat/completions -d '{"model":"timeout-mini","user":...
HTTP 408 in 8.413441s
[exit 0]

### A5 #47652 upstream answers HTTP 499 (fake upstream on 8499)
$ curl -s -m 30 -o /dev/null -w 'HTTP %{http_code}\n' :4100/v1/chat/completions -d '{"model":"gpt-5.5-upstream-499","user":"lit...
HTTP 499
[exit 0]

### A6 #47611 streamed requests cut after output started (gpt-5.5)
$ curl -sN --max-time 4 :4100/v1/chat/completions -d '{"model":"gpt-5.5","user":"lit-a6-chat-base","stream":true,"messages":[{"...
107
[exit 0]
$ curl -sN --max-time 4 :4100/v1/responses -d '{"model":"gpt-5.5","user":"lit-a6-resp-base","stream":true,"reasoning":{"effort"...
99
[exit 0]
$ curl -sN --max-time 12 :4100/v1/messages -d '{"model":"gpt-5.5","max_tokens":4000,"stream":true,"metadata":{"user_id":"lit-a6...
1128
[exit 0]

### A7 #47639 caller base_model and lone surrogate metadata
$ curl -s :4100/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-plain-base","messages":[{"role":"user","content":"Say ...
{"completion_tokens":4,"prompt_tokens":14,"total_tokens":18,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning...
[exit 0]
$ curl -s :4100/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-bm-base","base_model":"gpt-4o-mini","messages":[{"role...
{"completion_tokens":3,"prompt_tokens":13,"total_tokens":16,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning...
[exit 0]
$ curl -s -m 1 -o /dev/null -w 'HTTP %{http_code}\n' :4100/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-bmcut-base"...
HTTP 200
[exit 28]
$ curl -s -o /dev/null -w 'HTTP %{http_code}\n' :4100/v1/audio/transcriptions -F model=whisper-1 -F file=@/tmp/grpA_1105/tone.w...
HTTP 200
[exit 0]

### spend rows (base)
 end_user | call_type | model | status | prompt_tokens | completion_tokens | spend | retries 
 lit-a1-base | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0 | 2
 lit-a2-base | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0 | 2
 lit-a3-base | acompletion | openai/gpt-4.1 | failure | 0 | 0 | 0 | 0
 lit-a4-base | acompletion | openai/gpt-5.4-mini | failure | 28 | 0 | 0 | 1
 lit-a5-base | acompletion | openai/gpt-5.5 | failure | 10 | 0 | 0 | 0
 lit-a6-chat-base | acompletion | openai/gpt-5.5 | success | 28 | 105 | 0.00329 | 0
 lit-a7-plain-base | acompletion | openai/gpt-4o | success | 14 | 4 | 7.500000000000001e-05 | 0
[exit 0]
 call_type | model | status | prompt_tokens | completion_tokens | spend | request_tags 
[exit 0]
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 691: surrogates not allowed
[exit 0]

tip


### A1 #47435 read timeout (gpt41-timeout, timeout 1.5, num_retries 2)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4200/v1/chat/completions -d '{"model":"gpt41-timeout","user"...
HTTP 408 in 9.069942s
[exit 0]

### A2 #47437 deployment rate on timeout row (gpt41-rate, input_cost_per_token 1e-05)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4200/v1/chat/completions -d '{"model":"gpt41-rate","user":"l...
HTTP 408 in 8.971055s
[exit 0]

### A3 #47436 client hangs up after 1s (gpt41-cancel, cancel_on_disconnect)
$ curl -s --max-time 1 -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4200/v1/chat/completions -d '{"model":"gpt41-ca...
HTTP 000 in 1.004275s
[exit 28]

### A4 #47416 #47490 #47648 one row per billed timed-out attempt (timeout-mini -> fallback-big, timeout 1, num_retries 1)
$ curl -s -o /dev/null -w 'HTTP %{http_code} in %{time_total}s\n' :4200/v1/chat/completions -d '{"model":"timeout-mini","user":...
HTTP 408 in 8.315959s
[exit 0]

### A5 #47652 upstream answers HTTP 499 (fake upstream on 8499)
$ curl -s -m 30 -o /dev/null -w 'HTTP %{http_code}\n' :4200/v1/chat/completions -d '{"model":"gpt-5.5-upstream-499","user":"lit...
HTTP 499
[exit 0]

### A6 #47611 streamed requests cut after output started (gpt-5.5)
$ curl -sN --max-time 4 :4200/v1/chat/completions -d '{"model":"gpt-5.5","user":"lit-a6-chat-tip","stream":true,"messages":[{"r...
152
[exit 0]
$ curl -sN --max-time 4 :4200/v1/responses -d '{"model":"gpt-5.5","user":"lit-a6-resp-tip","stream":true,"reasoning":{"effort":...
[exit 1]
$ curl -sN --max-time 12 :4200/v1/messages -d '{"model":"gpt-5.5","max_tokens":4000,"stream":true,"metadata":{"user_id":"lit-a6...
1130
[exit 0]

### A7 #47639 caller base_model and lone surrogate metadata
$ curl -s :4200/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-plain-tip","messages":[{"role":"user","content":"Say e...
{"completion_tokens":4,"prompt_tokens":14,"total_tokens":18,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning...
[exit 0]
$ curl -s :4200/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-bm-tip","base_model":"gpt-4o-mini","messages":[{"role"...
{"completion_tokens":8,"prompt_tokens":13,"total_tokens":21,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning...
[exit 0]
$ curl -s -m 1 -o /dev/null -w 'HTTP %{http_code}\n' :4200/v1/chat/completions -d '{"model":"gpt-4o","user":"lit-a7-bmcut-tip",...
HTTP 200
[exit 28]
$ curl -s -o /dev/null -w 'HTTP %{http_code}\n' :4200/v1/audio/transcriptions -F model=whisper-1 -F file=@/tmp/grpA_1105/tone.w...
HTTP 400
[exit 0]

### spend rows (tip)
 end_user | call_type | model | status | prompt_tokens | completion_tokens | spend | retries 
 lit-a1-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 5.6e-05 | 2
 lit-a1-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 5.6e-05 | 0
 lit-a1-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 5.6e-05 | 1
 lit-a2-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0.00028 | 2
 lit-a2-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0.00028 | 0
 lit-a2-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0.00028 | 1
 lit-a3-tip | acompletion | openai/gpt-4.1 | failure | 28 | 0 | 0 | 0
 lit-a4-tip | acompletion | openai/gpt-5.4-mini | failure | 28 | 0 | 7.000000000000001e-05 | 1
 lit-a4-tip | acompletion | openai/gpt-5.4-mini | failure | 28 | 0 | 2.1e-05 | 1
 lit-a4-tip | acompletion | openai/gpt-5.4-mini | failure | 28 | 0 | 7.000000000000001e-05 | 0
 lit-a5-tip | acompletion | openai/gpt-5.5 | failure | 10 | 0 | 0 | 0
 lit-a6-chat-tip | acompletion | openai/gpt-5.5 | success | 28 | 152 | 0.0047 | 0
 lit-a6-resp-tip | aresponses | openai/gpt-5.5 | failure | 28 | 0 | 0.00014 | 
 lit-a6-msg-tip | anthropic_messages | openai/gpt-5.5 | success | 28 | 572 | 0.0173 | 0
 lit-a7-plain-tip | acompletion | openai/gpt-4o | success | 14 | 4 | 7.500000000000001e-05 | 0
 lit-a7-bm-tip | acompletion | openai/gpt-4o | success | 13 | 8 | 0.0001125 | 0
 lit-a7-bmcut-tip | acompletion | openai/gpt-4o | success | 13 | 34 | 0.0003725 | 0
[exit 0]
 call_type | model | status | prompt_tokens | completion_tokens | spend | request_tags 
 atranscription | | failure | 0 | 0 | 0 | []
[exit 0]
[exit 0]
Group B, Anthropic cache_control_injection_points (#47394 #47570), real Anthropic

base


### B1 #47394 chat with tool_config injection point, two identical calls (claude-cache)
$ for i in 1 2; do curl -s :4110/v1/chat/completions -d @chat_claude-cache.json | jq -c '.usage // .error | {prompt_tokens, cac...
{"prompt_tokens":null,"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"message":"litellm.BadRequestError: AnthropicException - {\...
{"prompt_tokens":null,"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"message":"litellm.BadRequestError: AnthropicException - {\...

### B1 #47394 /v1/messages (claude-cache)
$ curl -s :4110/v1/messages -d @messages_claude-cache.json
{"input_tokens":6203,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_inpu...

### B2 #47570 litellm_proxy chain forwards the injection point, two identical chat calls then two messages calls (claude-chain)
$ for i in 1 2; do curl -s :4110/v1/chat/completions -d @chat_claude-chain.json | jq -c '.usage // .error | {prompt_tokens, cac...
{"prompt_tokens":null,"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"message":"litellm.BadRequestError: Error code: 400 - {'err...
{"prompt_tokens":null,"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"message":"litellm.BadRequestError: Error code: 400 - {'err...
$ for i in 1 2; do curl -s :4110/v1/messages -d @messages_claude-chain.json
{"type":"invalid_request_error","message":"litellm.BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: AnthropicExce...
{"type":"invalid_request_error","message":"litellm.BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: AnthropicExce...
60

tip


### B1 #47394 chat with tool_config injection point, two identical calls (claude-cache)
$ for i in 1 2; do curl -s :4210/v1/chat/completions -d @chat_claude-cache.json | jq -c '.usage // .error | {prompt_tokens, cac...
{"prompt_tokens":6203,"cache_creation_input_tokens":5873,"cache_read_input_tokens":0,"message":null}
{"prompt_tokens":6203,"cache_creation_input_tokens":0,"cache_read_input_tokens":5873,"message":null}

### B1 #47394 /v1/messages (claude-cache)
$ curl -s :4210/v1/messages -d @messages_claude-cache.json
{"input_tokens":330,"cache_creation_input_tokens":0,"cache_read_input_tokens":5873,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_in...

### B2 #47570 litellm_proxy chain forwards the injection point, two identical chat calls then two messages calls (claude-chain)
$ for i in 1 2; do curl -s :4210/v1/chat/completions -d @chat_claude-chain.json | jq -c '.usage // .error | {prompt_tokens, cac...
{"prompt_tokens":6203,"cache_creation_input_tokens":0,"cache_read_input_tokens":5873,"message":null}
{"prompt_tokens":6203,"cache_creation_input_tokens":0,"cache_read_input_tokens":5873,"message":null}
$ for i in 1 2; do curl -s :4210/v1/messages -d @messages_claude-chain.json
{"input_tokens":330,"output_tokens":4,"cache_read_input_tokens":5873}
{"input_tokens":330,"output_tokens":4,"cache_read_input_tokens":5873}
28
4
Group C, Gemini and Vertex (#47460 #47647 #47494 #47646), real Gemini API and Vertex AI

base


### C3 #47494 three grounded Vertex calls, allowance lowered to 7 per month in the served cost map, fresh counter
$ curl -s :4120/v1/chat/completions -d '{"model": "vertex-3-flash", "user": "c3-ground", "messages": [{"role": "user", "content...
x-litellm-response-cost: 0.1281915
{"text_tokens":42,"web_search_requests":9}
x-litellm-response-cost: 0.02939725
{"text_tokens":43,"web_search_requests":2}
x-litellm-response-cost: 0.01456025
{"text_tokens":37,"web_search_requests":1}

### C4 #47646 fresh counter, one Gemini API grounded call then one Vertex AI grounded call, counter scoped per provider
$ curl -s :4120/v1/chat/completions -d '{"model":"gemini-api-3-flash","user":"c4-gemini-api-3-flash","messages":[{"role":"user"...
{"id":"_CrYaoxtoOrPsg_e09P4Dw","model":"gemini-api-3-flash","pt":{"text_tokens":232,"web_search_requests":1}}
$ curl -s :4120/v1/chat/completions -d '{"model":"vertex-3-flash","user":"c4-vertex-3-flash","messages":[{"role":"user","conten...
{"id":"BCvYarPVAuOCpucP1fCDyA4","model":"vertex-3-flash","pt":{"text_tokens":36,"web_search_requests":4}}

### spend rows
 end_user | model | spend | prompt_tokens | chars 
 c1-emb | vertex_ai/text-embedding-005 | 0 | 0 | 
 c1-emb | vertex_ai/gemini-embedding-001 | 0 | 0 | 
 model | model_id | status | prompt_tokens | spend | usd_per_prompt_token 
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-timeout-dep | failure | 160611 | 0 | 0.000000000000
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-dep | success | 147933 | 0.00152338 | 0.000000010298
 end_user | custom_llm_provider | spend | original_cost | discount | tool_cost | ws 
 c3-ground | vertex_ai | 0.1281915 | 0.1281915 | 0.0 | 0.126 | 9
 c3-ground | vertex_ai | 0.02939725 | 0.02939725 | 0.0 | 0.028 | 2
 c3-ground | vertex_ai | 0.01456025 | 0.01456025 | 0.0 | 0.014 | 1
 c4-gemini-api-3-flash | gemini | 0.0167165 | 0.016716500000000002 | 0.0 | 0.014 | 1
 c4-vertex-3-flash | vertex_ai | 0.05817575 | 0.05817575 | 0.0 | 0.056 | 4

tip


### C3 #47494 three grounded Vertex calls, allowance lowered to 7 per month in the served cost map, fresh counter
$ curl -s :4220/v1/chat/completions -d '{"model": "vertex-3-flash", "user": "c3-ground", "messages": [{"role": "user", "content...
x-litellm-response-cost: 0.05758025
{"text_tokens":42,"web_search_requests":4}
x-litellm-response-cost: 0.0154535
{"text_tokens":43,"web_search_requests":1}
x-litellm-response-cost: 0.01441775
{"text_tokens":37,"web_search_requests":1}
litellm:search_free_tier:vertex_ai:gemini-3:2026-10 = 6

### C4 #47646 fresh counter, one Gemini API grounded call then one Vertex AI grounded call, counter scoped per provider
$ curl -s :4220/v1/chat/completions -d '{"model":"gemini-api-3-flash","user":"c4-gemini-api-3-flash","messages":[{"role":"user"...
{"id":"byvYapqmG8iIqtsPhPmJ0A0","model":"gemini-api-3-flash","pt":{"text_tokens":262,"web_search_requests":1}}
$ curl -s :4220/v1/chat/completions -d '{"model":"vertex-3-flash","user":"c4-vertex-3-flash","messages":[{"role":"user","conten...
{"id":"eivYauj5KfqL9LsPx4m4gAI","model":"vertex-3-flash","pt":{"text_tokens":36,"web_search_requests":6}}
litellm:search_free_tier:vertex_ai:gemini-3:2026-10 = 6
litellm:search_free_tier:gemini:gemini-3:2026-10 = 1

### spend rows
 end_user | model | spend | prompt_tokens | chars 
 c1-emb | vertex_ai/text-embedding-005 | 0 | 0 | 
 c1-emb | vertex_ai/gemini-embedding-001 | 0 | 0 | 
 model | model_id | status | prompt_tokens | spend | usd_per_prompt_token 
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-timeout-dep | failure | 160611 | 0.0160611 | 0.000000100000
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-dep | success | 147933 | 0.00152338 | 0.000000010298
 end_user | custom_llm_provider | spend | original_cost | discount | tool_cost | ws 
 c3-ground | vertex_ai | 0.001580249999999998 | 0.05758025 | 0.0 | 0.056 | 4
 c3-ground | vertex_ai | 0.0014535 | 0.0154535 | 0.0 | 0.014 | 1
 c3-ground | vertex_ai | 0.0004177499999999997 | 0.01441775 | 0.0 | 0.014 | 1
 c4-gemini-api-3-flash | gemini | 0.002678999999999999 | 0.016679 | 0.0 | 0.014 | 1
 c4-vertex-3-flash | vertex_ai | 0.001939499999999997 | 0.0859395 | 0.0 | 0.084 | 6

base, #47460 rerun without the user param


### C1 #47460 rerun without the unsupported user param, Vertex text embeddings, 43 chars (35 billable)
$ curl -s :4120/v1/embeddings -d '{"model": "vertex_ai/text-embedding-005", "input": "The quick brown fox jumps over the lazy d...
x-litellm-response-cost: 1.1e-06
{"model":"vertex_ai/text-embedding-005","usage":{"completion_tokens":0,"prompt_tokens":11,"total_tokens":11,"completion_tokens_details":null,"promp...
$ curl -s :4120/v1/embeddings -d '{"model": "vertex_ai/gemini-embedding-001", "input": "The quick brown fox jumps over the lazy...
x-litellm-response-cost: 1.35e-06
{"model":"vertex_ai/gemini-embedding-001","usage":{"completion_tokens":0,"prompt_tokens":9,"total_tokens":9,"completion_tokens_details":null,"promp...
 model | spend | prompt_tokens | billable_chars 
 vertex_ai/text-embedding-005 | 0 | 0 | 
 vertex_ai/gemini-embedding-001 | 0 | 0 | 
 vertex_ai/text-embedding-005 | 1.1e-06 | 11 | 
 vertex_ai/gemini-embedding-001 | 1.35e-06 | 9 | 

tip, #47460 rerun


### C1 #47460 rerun without the unsupported user param, Vertex text embeddings, 43 chars (35 billable)
$ curl -s :4220/v1/embeddings -d '{"model": "vertex_ai/text-embedding-005", "input": "The quick brown fox jumps over the lazy d...
x-litellm-response-cost: 8.75e-07
{"model":"vertex_ai/text-embedding-005","usage":{"completion_tokens":0,"prompt_tokens":11,"total_tokens":11,"completion_tokens_details":null,"promp...
$ curl -s :4220/v1/embeddings -d '{"model": "vertex_ai/gemini-embedding-001", "input": "The quick brown fox jumps over the lazy...
x-litellm-response-cost: 1.35e-06
{"model":"vertex_ai/gemini-embedding-001","usage":{"completion_tokens":0,"prompt_tokens":9,"total_tokens":9,"completion_tokens_details":null,"promp...
 model | spend | prompt_tokens | billable_chars 
 vertex_ai/text-embedding-005 | 0 | 0 | 
 vertex_ai/gemini-embedding-001 | 0 | 0 | 
 vertex_ai/text-embedding-005 | 8.75e-07 | 11 | 35
 vertex_ai/gemini-embedding-001 | 1.35e-06 | 9 | 35

base, #47647 rerun with a 1.75M char prompt


### C2 #47647 rerun with a 1.75M character prompt (above the 200k token tier), read timeout on the tiered deployment, then the same prompt on the c...
$ curl -s -w '\nHTTP %{http_code} in %{time_total}s\n' :4120/v1/chat/completions -d @timeout_body2.json
{"error":{"message":"litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.541 seconds\n\nDeployment Info: request_timeout: None\...
HTTP 408 in 7.927574s
$ curl -s -w '\nHTTP %{http_code} in %{time_total}s\n' :4120/v1/chat/completions -d @success_body2.json | jq -c '.usage // .err...
{"completion_tokens":1,"prompt_tokens":261462,"total_tokens":261463,"completion_tokens_details":{"text_tokens":1},"prompt_tokens_details":{"cached_...
 model | model_id | status | prompt_tokens | spend | usd_per_prompt_token 
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-timeout-dep | failure | 283625 | 0 | 0.000000000000
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-dep | success | 261462 | 0.0042918 | 0.000000016415

tip, #47647 rerun


### C2 #47647 rerun with a 1.75M character prompt (above the 200k token tier), read timeout on the tiered deployment, then the same prompt on the c...
$ curl -s -w '\nHTTP %{http_code} in %{time_total}s\n' :4220/v1/chat/completions -d @timeout_body2.json
{"error":{"message":"litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.543 seconds\n\nDeployment Info: request_timeout: None\...
HTTP 408 in 8.791866s
$ curl -s -w '\nHTTP %{http_code} in %{time_total}s\n' :4220/v1/chat/completions -d @success_body2.json | jq -c '.usage // .err...
{"completion_tokens":1,"prompt_tokens":261462,"total_tokens":261463,"completion_tokens_details":{"text_tokens":1},"prompt_tokens_details":{"cached_...
 model | model_id | status | prompt_tokens | spend | usd_per_prompt_token 
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-timeout-dep | failure | 283625 | 0.1418125 | 0.000000500000
 gemini/gemini-2.5-flash-lite | flash-lite-tiered-dep | success | 261462 | 0.0042918 | 0.000000016415

tip, #47494 breakdown probe, 6 calls

 end_user | spend | bd_total | discount | ws 
--- restarted with --detailed_debug
{"tag":"probe-debug-1","pt":{"text_tokens":37,"web_search_requests":2}}
{"tag":"probe-debug-2","pt":{"text_tokens":37,"web_search_requests":1}}
{"tag":"probe-debug-3","pt":{"text_tokens":37,"web_search_requests":1}}
 end_user | spend | bd_total | discount | ws 
 probe-debug-1 | 0.0006465000000000012 | 0.0006465000000000012 | 0.028 | 2
 probe-debug-2 | 0.0007515000000000004 | 0.0007515000000000004 | 0.014 | 1
 probe-debug-3 | 0.000699 | 0.014699 | 0.0 | 1
3

main 3985795, #47494 breakdown probe, 6 calls

{"tag":"probe-main-1","pt":{"text_tokens":37,"web_search_requests":1}}
{"tag":"probe-main-2","pt":{"text_tokens":37,"web_search_requests":1}}
{"tag":"probe-main-3","pt":{"text_tokens":37,"web_search_requests":1}}
{"tag":"probe-main-4","pt":{"text_tokens":37,"web_search_requests":2}}
{"tag":"probe-main-5","pt":{"text_tokens":37,"web_search_requests":1}}
{"tag":"probe-main-6","pt":{"text_tokens":37,"web_search_requests":1}}
 end_user | spend | bd_total | discount | ws 
Group D, scripted upstreams (#47406 #47567 #47655 #47183 #47564 #47617), fake upstream /tmp/grpD_1105/fake_upstream.py

base


### D1 #47406 timeout_by_service_tier, scripted upstream answers flex after 8s, deployment timeout 3, flex 12
$ post chat/completions '{"model":"openai-gpt-5.1","service_tier":"flex","messages":[{"role":"user","content":"hi"}]}'
{"error":{"message":"litellm.Timeout: APITimeoutError - Request timed out. Error_str: Request timed out. - timeout value=3.0, time taken=3.12 secon...
HTTP 408, elapsed 3.426791s
$ post responses '{"model":"openai-gpt-5.1","service_tier":"flex","input":"hi"}'
{"error":{"message":"litellm.Timeout: Timeout Error: OpenAIException - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.001 ...
HTTP 408, elapsed 3.115545s
$ post chat/completions '{"model":"openai-gpt-5.1","messages":[{"role":"user","content":"hi"}]}'
HTTP 200, elapsed 0.052099s
$ post chat/completions '{"model":"openai-gpt-5.1","service_tier":"flex","messages":[{"role":"user","content":"hi"}]}'
{"error":{"message":"litellm.Timeout: APITimeoutError - Request timed out. Error_str: Request timed out. - timeout value=2.0, time taken=2.01 secon...
HTTP 408, elapsed 2.138971s

### D5 #47564 raw 0xFF 0xFE bytes to /v1/decisions through the proxy, then the SDK call with bytes input and a failure callback
$ curl -s -w '\nHTTP %{http_code}\n' :4130/v1/decisions --data-binary @bad_utf8_body.bin
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 1 validation error for dict[str,any]\n Invalid JSON: invalid unicode code ...
HTTP 400
logged messages: [{'role': 'user', 'content': '"b\'\\\\xff\\\\xfe not utf-8\'"'}]
caller sees: BadRequestError status_code= 400
litellm.BadRequestError: Invalid Decisions request: 2 validation errors for OpenAIDecisionRequestBody

### D6 #47617 cost-based routing, deployment priced only through model_info.base_model vs a custom priced deployment
$ for i in 1 2 3 4; do curl -s -D - -o /dev/null :4130/v1/chat/completions -d '{"model":"sonnet-pool","messages":[{"role":"user...
x-litellm-model-id: openai-custom-priced
x-litellm-model-id: openai-custom-priced
x-litellm-model-id: openai-custom-priced
x-litellm-model-id: openai-custom-priced
 1 item_cost: 0.0001, item_tpm: 0, item_rpm: 0, model_id: openai-custom-priced
 4 item_cost: 10.0, item_tpm: 0, item_rpm: 0, model_id: azure-claude-base-model

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill | gpt-4.1-ptu | 0 | 0 | 0 | | | | 

tip


### D1 #47406 timeout_by_service_tier, scripted upstream answers flex after 8s, deployment timeout 3, flex 12
$ post chat/completions '{"model":"openai-gpt-5.1","service_tier":"flex","messages":[{"role":"user","content":"hi"}]}'
HTTP 200, elapsed 8.354853s
$ post responses '{"model":"openai-gpt-5.1","service_tier":"flex","input":"hi"}'
HTTP 200, elapsed 8.164360s
$ post chat/completions '{"model":"openai-gpt-5.1","messages":[{"role":"user","content":"hi"}]}'
HTTP 200, elapsed 0.069294s
$ post chat/completions '{"model":"openai-gpt-5.1","service_tier":"flex","messages":[{"role":"user","content":"hi"}]}'
{"error":{"message":"litellm.Timeout: APITimeoutError - Request timed out. Error_str: Request timed out. - timeout value=2.0, time taken=2.0 second...
HTTP 408, elapsed 2.148012s

### D5 #47564 raw 0xFF 0xFE bytes to /v1/decisions through the proxy, then the SDK call with bytes input and a failure callback
$ curl -s -w '\nHTTP %{http_code}\n' :4230/v1/decisions --data-binary @bad_utf8_body.bin
{"error":{"message":"litellm.BadRequestError: Invalid Decisions request: 1 validation error for dict[str,any]\n Invalid JSON: invalid unicode code ...
HTTP 400
logged messages: [{'role': 'user', 'content': '{"input": "__4gbm90IHV0Zi04", "questions": [{"type": "predicate", "instructions": "Is this about a b...
caller sees: BadRequestError status_code= 400
litellm.BadRequestError: Invalid Decisions request: 2 validation errors for OpenAIDecisionRequestBody

### D6 #47617 cost-based routing, deployment priced only through model_info.base_model vs a custom priced deployment
$ for i in 1 2 3 4; do curl -s -D - -o /dev/null :4230/v1/chat/completions -d '{"model":"sonnet-pool","messages":[{"role":"user...
x-litellm-model-id: azure-claude-base-model
x-litellm-model-id: azure-claude-base-model
x-litellm-model-id: azure-claude-base-model
x-litellm-model-id: azure-claude-base-model
 4 item_cost: 0.0001, item_tpm: 0, item_rpm: 0, model_id: openai-custom-priced
 1 item_cost: 1.8e-05, item_tpm: 0, item_rpm: 0, model_id: azure-claude-base-model

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill | gpt-4.1-ptu | 0 | 0 | 0 | | | | 

base, #47183 rerun


### D2 #47567 rerun with team_id on the PTU deployment (required on this line), scripted Azure upstream returns x-ms-is-spilled-over, prompt 100 / ...
$ curl -s -D - :4130/v1/chat/completions -d '{"model":"gpt-4.1-ptu","messages":[{"role":"user","content":"hi"}],"user":"spill2"...
x-litellm-response-cost: 0.0006
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### D4 #47183 rerun, /v1/systemone and /v1/decisions on a System One stand-in, s3_v2 objects saved by a PUT stand-in
$ curl -s :4130/v1/systemone -d '{"model": "jev-fake", "state": {"message": "My card was charged twice."}, "questions": {"billi...
{"model":"jev-fake","answers":{"billing":{"type":"noul","noul":0.93}},"usage":{"input_tokens":25,"output_tokens":0}}
$ curl -s :4130/v1/decisions -d '{"model": "jev-fake", "input": "My card was charged twice.", "questions": [{"type": "predicate...
{"model":"jev-fake","answers":[{"type":"predicate","name":null,"probability":0.93}],"usage":{"input_tokens":25,"input_tokens_details":{"cached_toke...
3
call_type: acompletion messages: [{"role": "user", "content": "hi"}]
 'Is this about a billing problem?' in object: False
call_type: asystemone messages: [{"role": "user", "content": "{\"message\": \"My card was charged twice.\"}"}]
 'Is this about a billing problem?' in object: False
call_type: adecisions messages: [{"role": "user", "content": "My card was charged twice."}]
 'Is this about a billing problem?' in object: False

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill | gpt-4.1-ptu | 0 | 0 | 0 | | | | 
 spill-probe | gpt-4.1-ptu | 0 | 0 | 0 | | | | 

tip, #47183 rerun


### D2 #47567 rerun with team_id on the PTU deployment (required on this line), scripted Azure upstream returns x-ms-is-spilled-over, prompt 100 / ...
$ curl -s -D - :4230/v1/chat/completions -d '{"model":"gpt-4.1-ptu","messages":[{"role":"user","content":"hi"}],"user":"spill2"...
x-litellm-response-cost: 0.0006
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### D4 #47183 rerun, /v1/systemone and /v1/decisions on a System One stand-in, s3_v2 objects saved by a PUT stand-in
$ curl -s :4230/v1/systemone -d '{"model": "jev-fake", "state": {"message": "My card was charged twice."}, "questions": {"billi...
{"model":"jev-fake","answers":{"billing":{"type":"noul","noul":0.93}},"usage":{"input_tokens":25,"output_tokens":0}}
$ curl -s :4230/v1/decisions -d '{"model": "jev-fake", "input": "My card was charged twice.", "questions": [{"type": "predicate...
{"model":"jev-fake","answers":[{"type":"predicate","name":null,"probability":0.93}],"usage":{"input_tokens":25,"input_tokens_details":{"cached_toke...
3
call_type: acompletion messages: [{"role": "user", "content": "hi"}]
 'Is this about a billing problem?' in object: False
call_type: asystemone messages: [{"role": "user", "content": "{\"state\": {\"message\": \"My card was charged twice.\"}, \"questions\": {\"billing\...
 'Is this about a billing problem?' in object: True
call_type: adecisions messages: [{"role": "user", "content": "{\"input\": \"My card was charged twice.\", \"questions\": [{\"type\": \"predicate\",...
 'Is this about a billing problem?' in object: True

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill | gpt-4.1-ptu | 0 | 0 | 0 | | | | 

base, #47567 #47655 rerun with unique upstream ids


### D2 #47567 rerun (fake upstream now returns unique ids, earlier rows collided on request_id chatcmpl-fake-1), PTU deployment with base_model, sc...
$ curl -s -D - :4130/v1/chat/completions -d '{"model":"gpt-4.1-ptu","messages":[{"role":"user","content":"hi"}],"user":"spill3"...
x-litellm-response-cost: 0.0006
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### D3 #47655 rerun, PTU deployment without base_model, served model azure/gpt-5.4-nano, spilled over
$ curl -s -D - :4130/v1/chat/completions -d '{"model":"gpt-5.4-nano-ptu","messages":[{"role":"user","content":"Reply with the s...
x-litellm-model-id: ptu-gpt-54-nano
x-litellm-response-cost: 8.25e-05
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill3 | azure/gpt-4.1 | 0.0006 | 100 | 50 | azure/gpt-4.1 | 0.000002 | 0.000008 | {"from_deployment": "ptu-gpt41"}
 spill3 | azure/gpt-4.1 | 0.0006 | 100 | 50 | azure/gpt-4.1 | 0.000002 | 0.000008 | {"from_deployment": "ptu-gpt41"}
 spill3-nano | azure/gpt-5.4-nano | 8.25e-05 | 100 | 50 | azure/gpt-5.4-nano | 0.0000002 | 0.00000125 | {"from_deployment": "ptu-gpt41"}

tip, #47567 #47655 rerun


### D2 #47567 rerun (fake upstream now returns unique ids, earlier rows collided on request_id chatcmpl-fake-1), PTU deployment with base_model, sc...
$ curl -s -D - :4230/v1/chat/completions -d '{"model":"gpt-4.1-ptu","messages":[{"role":"user","content":"hi"}],"user":"spill3"...
x-litellm-response-cost: 0.0006
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### D3 #47655 rerun, PTU deployment without base_model, served model azure/gpt-5.4-nano, spilled over
$ curl -s -D - :4230/v1/chat/completions -d '{"model":"gpt-5.4-nano-ptu","messages":[{"role":"user","content":"Reply with the s...
x-litellm-model-id: ptu-gpt-54-nano
x-litellm-response-cost: 8.25e-05
llm_provider-x-ms-is-spilled-over: true
llm_provider-x-ms-spillover-from-deployment: ptu-gpt41

### spend rows
 end_user | model | spend | pt | ct | model_map_key | in_rate | out_rate | azure_spillover 
 spill3 | azure/gpt-4.1 | 0.0006 | 100 | 50 | azure/gpt-4.1 | 0.000002 | 0.000008 | {"from_deployment": "ptu-gpt41"}
 spill3 | azure/gpt-4.1 | 0.0006 | 100 | 50 | azure/gpt-4.1 | 0.000002 | 0.000008 | {"from_deployment": "ptu-gpt41"}
 spill3-nano | azure/gpt-5.4-nano | 8.25e-05 | 100 | 50 | gpt-5.4-nano | 0.0000002 | 0.00000125 | {"from_deployment": "ptu-gpt41"}

Type

🆕 New Feature
🐛 Bug Fix

Caveats (if any)

Medium

Low

  • tests/unit/proxy/db and the Prisma token tests need prisma generate locally

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/fc365d3ce825449f9eb0fcaac0ddde69
Open in Devin Desktop: https://app.devin.ai/desktop/session/fc365d3ce825449f9eb0fcaac0ddde69?variant=devin
Requested by: @kerrylu-berri

…one and /v1/decisions (#47183)

* fix(decisions): log every request field the caller sent on /v1/systemone and /v1/decisions

* fix(decisions): serialize the logged request with model_dump_json so no mutable dict is built

* refactor(decisions): drop the state-only messages pick in function_setup, prepare_call logs the request

* fix(decisions): return the single logged message so no mutable list type is annotated

* fix(decisions): log the caller's raw request fields before validation so a rejected request is still recorded

* fix(decisions): serialize the raw request fields with pydantic_core so question objects and mapping proxies log as JSON

* fix(decisions): log the caller request at the SDK entry so requests rejected before prepare_call are recorded too

* test(decisions): assert the exact BadRequestError for the rejected-questions case

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47183 to stable/1.105.x.
Cherry-picked from 53821f6 (main).
* feat(router): let a deployment set a timeout per service_tier

Adds timeout_by_service_tier and stream_timeout_by_service_tier to a deployment's
litellm_params. A request whose service_tier matches a key uses that value in place
of the deployment's timeout or stream_timeout. A timeout the client sends still wins
and requests without a matching tier are unchanged

Co-authored-by: adc77 <amandogra2016@gmail.com>

* style(router): sort the request_timeout_resolver import

* fix(router): read the service tier maps without the untyped params get

* fix(router): look the service tier timeout up through a typed get

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: adc77 <amandogra2016@gmail.com>

Backport of #47406 to stable/1.105.x.
Cherry-picked from 62ce515 (main).
…d input rate when no modality rate exists (#47373)

* fix(cost): bill Gemini audio/image/video prompt tokens at the resolved input rate when no modality rate exists

Co-authored-by: shivam <shivam@berri.ai>

* style(cost): ruff format the modality cost calls

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: shivam <shivam@berri.ai>

Backport of #47373 to stable/1.105.x.
Cherry-picked from 09e9193 (main).
…1/messages (#47394)

* fix(anthropic): apply tool_config cache-control points on chat and /v1/messages

A cache_control_injection_points entry with location tool_config was spread into
the Anthropic request body on /v1/chat/completions, which Anthropic rejected with
400 Extra inputs are not permitted, and the native /v1/messages path dropped the
point silently. Both paths now put the point's control on the last tool Anthropic
caches and never forward the key.

Co-authored-by: Tan Nguyen <tan@pressingly.net>

* refactor(anthropic): validate tool_config inputs instead of casting them

Keeps the lint gates flat: the helper takes untyped tools and points and
narrows them with the existing object validators, the chat transform builds
the body with the marked tools instead of writing into optional_params, and
the handler reads a typed view of kwargs.

* fix(openai): keep tool_config cache points out of extra_body, add integration test

The cache hook hands a tool_config point on for the provider step, and for
providers that call through the OpenAI SDK every non-OpenAI param rides in
extra_body, so OpenAI answered 400 Unrecognized request argument supplied.
The new integration file drives a live proxy against scripted Anthropic,
Bedrock Converse and OpenAI upstreams for /v1/chat/completions and
/v1/messages.

* test(integration): cover tool_config cache points on bridged /v1/messages

Three new cases on /v1/messages for models without a native Anthropic
messages path: OpenAI through the Responses bridge and Gemini through the
chat bridge never see cache_control_injection_points in the body, and
Bedrock Nova through the chat bridge gets the cachePoint on toolConfig

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Tan Nguyen <tan@pressingly.net>

Backport of #47394 to stable/1.105.x.
Cherry-picked from 93b79d2 (main).
…est's spend row (#47435)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47435 to stable/1.105.x.
Cherry-picked from 7b76b2b (main).
…a proxy-only failure (#47456)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47456 to stable/1.105.x.
Cherry-picked from 3fa1587 (main).
…leCharacterCount (#47460)

Vertex text embedding predict responses report metadata.billableCharacterCount, the
unit Google bills text-embedding-005 and text-multilingual-embedding-002 on. Carry it
into usage.prompt_tokens_details.character_count and, when the model carries
input_cost_per_character, bill that count instead of the token count so the prompt is
charged under one unit. Per-token embeddings (gemini-embedding-001) are unchanged.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47460 to stable/1.105.x.
Cherry-picked from d29200f (main).
…#47466)

* fix(batches): apply the Vertex regional endpoint uplift to batch cost

batch_cost_calculator takes vertex_location and multiplies by the model's
regional_endpoint_uplift_multiplier through get_vertex_regional_endpoint_uplift,
and every batch cost path (aretrieve_batch pricing, completed-batch logging,
native Vertex batch rows, the proxy batch cost poll and its per-line items)
resolves the deployment's location and passes it down

Co-authored-by: Mrun25 <165297479+Mrun25@users.noreply.github.com>

* test(logging): point the resolver tests at resolve_vertex_location_for_cost

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Mrun25 <165297479+Mrun25@users.noreply.github.com>

Backport of #47466 to stable/1.105.x.
Cherry-picked from c6c303a (main).
…99) request's spend row (#47436)

* fix(proxy): price the estimated input tokens on a client-cancelled (499) request's spend row

* fix(proxy): read the provider handoff before the proxy-only error handler stamps it so a pre-handoff 499 is not priced

* fix(proxy): drop the pre-logging handoff read now that pre_call no longer stamps proxy-only failures

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47436 to stable/1.105.x.
Cherry-picked from 0e7c490 (main).
…ike the success path (#47437)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47437 to stable/1.105.x.
Cherry-picked from fb555b0 (main).
…U spillover (#47567)

get_standard_logging_object_payload decided custom_pricing from
litellm_params alone, so on an Azure PTU spillover response
model_map_information kept the deployment's zeroed PTU entry while
response_cost already used the standard model rate. Reuse the billing
side LitellmLogging._custom_pricing_for so both read the same decision

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47567 to stable/1.105.x.
Cherry-picked from 4222523 (main).
…s to the downstream proxy (#47570)

PR #47394 withheld cache_control_injection_points from the OpenAI SDK extra_body for
every provider on that path, which also covers litellm_proxy. The downstream LiteLLM
proxy applies the point itself, so litellm_proxy keeps forwarding it while OpenAI and the
other OpenAI-compatible providers still never receive it

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47570 to stable/1.105.x.
Cherry-picked from 04e9ed4 (main).
…validation and gets a 400 (#47564)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47564 to stable/1.105.x.
Cherry-picked from ce63f48 (main).
…he failed request (#47490)

* feat(proxy): lift every earlier billed timed-out retry attempt onto the failed request

_billed_earlier_attempts reads the router's previous_models records, keeps the Timeout ones other than the final attempt (matched on deployment_id plus attempted_retries, since the count restarts after a fallback hop and the fallback handler re-logs the exhausting attempt) and prices each at the deployment that served it. post_call_failure_hook lifts the tuple as billed_failed_attempts; nothing writes it yet. previous_models joins the router-reserved metadata fields so a client-planted record never reaches it

* fix(proxy): price earlier timed-out attempts from the prompt estimate only

The final row may lift a mid-stream recovered usage (prompt plus delivered chunks) or a failed_attempts_usage sum; earlier attempts never produced output, so they are priced from _estimated_prompt_usage, and when failed_attempts_usage already bills them into the final row none is lifted again

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47490 to stable/1.105.x.
Cherry-picked from 7a4a255 (main).
… prisma engine mid-write (#47571)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47571 to stable/1.105.x.
Cherry-picked from ccd0d4e (main).
…47416)

_failure_spend_rows yields the final row plus one re-keyed row per lifted billed_failed_attempts entry (<request_id>-attempt-<position>, the attempt's usage, cost, retry count and deployment id), each written through DBSpendUpdateWriter.update_database so it also deducts from key, team and user spend

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47416 to stable/1.105.x.
Cherry-picked from ad8ca53 (main).
…pend (#47494)

* feat(proxy): opt-in free-tier allowance for Google Search grounding spend

* fix(proxy): declare the search free tier counter's service target

* test(cost_map): allow search_free_requests in the cost map schema

* fix(proxy): skip cache hits and never free more than the billed cost in the search free tier

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47494 to stable/1.105.x.
Cherry-picked from e63aec0 (main).
…idge reads back (#47614)

Every /v1/responses spend log asked its worker to flush the queue right away so a
chained previous_response_id could find the row. Only the chat-completions bridge
reads that row. Native Responses providers hold the conversation upstream, so their
rows now wait for the batch write like chat rows do

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47614 to stable/1.105.x.
Cherry-picked from 423362b (main).
…nects (#47611)

* fix(proxy): bill partial Responses API streams when the client disconnects

Streamed /v1/responses requests and the default-route OpenAI and Azure /v1/messages requests behind them logged a 499 with zero spend when the client went away mid-stream, while /v1/chat/completions already billed the chunks it had sent. The Responses API iterator now keeps the response.created payload and can hand the disconnect cleanup a response.incomplete event with counted usage and the served service_tier, and the messages-route byte stream and router wrappers delegate to it.

* fix(proxy): satisfy lint gates for partial Responses API disconnect billing

Make the disconnect helper public so the proxy, router and messages adapter can import it without reportPrivateUsage, type the SSE byte stream as an AsyncGenerator so aclose is known, read litellm_call_id off the logging object, and keep the new tests on Final locals with the recorder injected through dynamic_async_success_callbacks instead of litellm.callbacks.

* fix(router): bill the primary stream's tokens after a mid-stream hop and chat-bridge Responses streams on disconnect

The router's fallback wrapper now folds the primary Responses stream's relayed tokens into the fallback's disconnect event the way _combine_responses_fallback_usage does for a natural end of stream, and LiteLLMCompletionStreamingIterator (chat-only providers served through /v1/responses) builds its disconnect event from the chat completion chunks it collected. stamp_responses_usage_cost is now public so the bridge module can price that event.

* Potential fix for pull request finding 'CodeQL / Log Injection'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

Backport of #47611 to stable/1.105.x.
Cherry-picked from f0ae445 (main).
…e surrogates in multipart metadata (#47639)

* fix(proxy): strip caller base_model from spend pricing and reject lone surrogates in multipart metadata

* fix(proxy): type the parsed multipart metadata so basedpyright does not grow reportArgumentType

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47639 to stable/1.105.x.
Cherry-picked from 2a26895 (main).
…xt tier like the success path (#47647)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47647 to stable/1.105.x.
Cherry-picked from 70ece35 (main).
…der (#47646)

* fix(proxy): scope the search free-tier counter to the request's provider

* fix(proxy): read the provider with get so partial spend payloads still get the free tier

* test(proxy): give the grounded spend payload fixture its provider

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47646 to stable/1.105.x.
Cherry-picked from 640f2d8 (main).
…, and never after the call already completed (#47652)

* fix(proxy): price a 499 spend row only for the proxy's own disconnect, and never after the call already completed

* fix(proxy): gate the zero-cost 499 row on the success log being enqueued, not merely claimed

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47652 to stable/1.105.x.
Cherry-picked from ffb7133 (main).
…47617)

* fix(router): price cost-based routing through model_info.base_model

* fix(router): keep cost-based routing pricing helpers fully typed

* fix(router): drop typing.cast from cost-based routing pricing helpers

* fix(router): read the cost map through a typed accessor in cost-based routing

* fix(router): avoid a Final rebind inside the cost-based routing loop

* refactor(router): share deployment_pricing_models across spend, listing and cost-based routing

* refactor(router): keep the /v1/models listing key inline, share pricing models for spend and routing

* refactor(router): inline the deployment pricing-model wrapper in cost-based routing

* refactor(router): read deployment pricing models through one shared helper

deployment_pricing_models(deployment) now owns the model_info.base_model / litellm_params.base_model /
litellm_params.model unpacking, used by cost-based routing and the /v1/models listing. pricing_models(base_model, model)
stays for the failure-row spend estimate, which already holds the two names

* refactor(router): share the str-keyed mapping validator with cost-based routing

* ci: re-run after flaky test_aiohttp_transport read timeout in llms-providers

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47617 to stable/1.105.x.
Cherry-picked from 0c6731e (main).
…yment's model rate (#47648)

* fix(proxy): bill every earlier timed-out retry attempt at its own deployment's model rate

* fix(router): read the retry record's base_model through the typed metadata helper

* fix(router): keep the four-record retry breadcrumb cap

* fix(router): carry a deployment's litellm_params base_model on its retry record

* chore(router): place the cast-ok reason on the cast line and list the base_model helper as covered through log_retry

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47648 to stable/1.105.x.
Cherry-picked from 27efc38 (main).
…rved model's rates (#47655)

* fix(logging): report pay-as-you-go rates for spilled over PTU requests without base_model

* fix(logging): keep the provider response model so spilled over PTU payloads price the served model

* fix(logging): keep a provider_response_model the response already carries

* fix(logging): read the carried provider_response_model through a typed adapter

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport of #47655 to stable/1.105.x.
Cherry-picked from 6b1f4ed (main).
Lock-only bump for GHSA-2g87-pp6c-29x5, GHSA-5wr8-gcqf-gqf3 and GHSA-494j-54xm-rwp3
(aiohttp 3.14.3 -> 3.14.4, yarl 1.23.0 -> 1.25.1 moves with its new floor). main is on 3.14.5.
pyproject constraint aiohttp>=3.14.2,<4.0 is unchanged.
@klu-berri
klu-berri requested a review from a team October 21, 2026 01:10
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot changed the title chore(backport): LIT-145 billing fixes and aiohttp 3.14.4 onto stable/1.105.x (1.105.3) chore(backport): billing fixes for LIT-145 and aiohttp 3.14.4 onto stable/1.105.x (1.105.3) Oct 21, 2026
@yuneng-berri yuneng-berri reopened this Oct 21, 2026
@yuneng-berri
yuneng-berri merged commit 116b996 into stable/1.105.x Oct 21, 2026
3 of 5 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_backport_lit145_batch_stable_1_105_x branch October 21, 2026 08:02

This branch was successfully deployed

No deployments
e2e-changed — b77c7b8f Deployed Oct 21, 2026 by yuneng-berri via oauth #6028
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.

3 participants