Commit graph

53311 commits

Author SHA1 Message Date
yuneng-jiang
b2e44bf862
Merge pull request #47726 from BerriAI/litellm_backport_p0_batch_translation_cost_stable_1_104_x
fix(batches)!: backport P0 batch-cost, pricing and translation fixes to stable/1.104.x for v1.104.6
2026-10-20 23:32:24 -07:00
Yuneng Jiang
bd382afc17
Merge stable/1.104.x (#47718) into litellm_backport_p0_batch_translation_cost_stable_1_104_x
# Conflicts:
#	litellm/model_prices_and_context_window_backup.json
#	litellm/proxy/hooks/proxy_track_cost_callback.py
#	litellm/responses/litellm_completion_transformation/streaming_iterator.py
#	model_prices_and_context_window.json
#	tests/test_litellm/proxy/hooks/test_proxy_track_cost_callback.py
#	tests/unit/test_utils.py
2026-10-20 23:07:37 -07:00
yuneng-jiang
01823bd07f
Merge pull request #47718 from BerriAI/litellm_backport_lit145_stable_1_104_x
fix(proxy): backport the LIT-145 spend tracking fixes to stable/1.104.x for v1.104.6
2026-10-20 23:04:12 -07:00
Yuneng Jiang
7b0e159628
bump: litellm 1.104.5 -> 1.104.6 2026-10-20 22:42:33 -07:00
Yuneng Jiang
240d4157f8
bump: litellm 1.104.5 -> 1.104.6, litellm-enterprise 0.1.71 -> 0.1.71.post1 2026-10-20 22:42:08 -07:00
Yuneng Jiang
b465d97ead
Merge stable/1.104.x (v1.104.5) into litellm_backport_lit145_stable_1_104_x
# Conflicts:
#	uv.lock
2026-10-20 22:42:07 -07:00
Mrinal Chanshetty
aa960d620a fix(anthropic): carry main's dangerous-tool-use beta map entries; skip worker-kill chaos test
The bundled beta map stripped dangerous-tool-use-2026-09-03 for providers
main supports it on, so safeguards requests went upstream without the beta
whenever the proxy used the bundled map. The worker-SIGKILL chaos test needs
OwnedProxy.replacing_worker, which this line's integration harness lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 21:27:07 -07:00
Mrinal Chanshetty
c4b5c45196 Merge branch 'stable/1.104.x' into litellm_backport_p0_batch_translation_cost_stable_1_104_x 2026-10-20 18:40:29 -07:00
Mrinal Chanshetty
810db3747d bump: version 1.104.5 2026-10-20 18:24:14 -07:00
Mrinal Chanshetty
f13eb6d8fb chore: bump litellm-enterprise 0.1.71 -> 0.1.71.post1 2026-10-20 18:24:14 -07:00
Mrinal Chanshetty
b8e89a881b chore(cost-map): accept the mirrored map's search_free_requests and token_count_model.litellm_provider in the schema 2026-10-20 18:24:13 -07:00
Mrinal Chanshetty
9c28744ad5 test: retarget cost-map tests to the rows mirrored from main 2026-10-20 18:24:13 -07:00
Mrinal Chanshetty
631e26f361 chore(cost-map): mirror model_prices_and_context_window.json and backup from main at 6083cf9776 2026-10-20 18:24:13 -07:00
Mrinal Chanshetty
23e0a798c0 chore(deps): bump aiohttp to 3.14.5 and claude-agent-sdk to 0.2.165 to match main 2026-10-20 18:24:13 -07:00
devin-ai-integration[bot]
827cc15bfc bump: version 1.104.5 2026-10-21 01:14:53 +00:00
devin-ai-integration[bot]
97bcc92fad chore(deps): bump aiohttp to 3.14.4 2026-10-21 01:14:11 +00:00
Kerry Lu
2313d343ba fix(logging): spilled over PTU requests without base_model log the served 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

---------

Backport of #47655 to stable/1.104.x
Cherry-picked from 6b1f4ed46f (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
5a34391482 fix(proxy): price earlier timed-out retry attempts at their own deployment'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

---------

Backport of #47648 to stable/1.104.x
Cherry-picked from 27efc387f7 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
a8807fb0bb fix(router): price cost-based routing through model_info.base_model (#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

---------

Backport of #47617 to stable/1.104.x
Cherry-picked from 0c6731eb5c (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
f9800f1fc0 fix(proxy): price a 499 spend row only for the proxy's own disconnect, 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

---------

Backport of #47652 to stable/1.104.x
Cherry-picked from ffb7133d32 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
b2ed8bc1c3 fix(proxy): scope the search free-tier counter to the request's provider (#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

---------

Backport of #47646 to stable/1.104.x
Cherry-picked from 640f2d865b (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
b092d90f75 fix(proxy): price a billed failure row at the deployment's long-context tier like the success path (#47647)
Backport of #47647 to stable/1.104.x
Cherry-picked from 70ece3501f (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
13779e98bd fix(proxy): strip caller base_model from spend pricing and reject lone 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

---------

Backport of #47639 to stable/1.104.x
Cherry-picked from 2a268951c4 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
d388cb8253 fix(proxy): bill partial Responses API streams when the client disconnects (#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>

---------

Backport of #47611 to stable/1.104.x
Cherry-picked from f0ae445cc4 (main)

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>
2026-10-21 01:14:11 +00:00
Kerry Lu
dbbebd07bf fix(proxy): flush the spend-log queue only for Responses turns the bridge 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

Backport of #47614 to stable/1.104.x
Cherry-picked from 423362bab2 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
de1e76bd13 feat(proxy): opt-in free-tier allowance for Google Search grounding spend (#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

---------

Backport of #47494 to stable/1.104.x
Cherry-picked from e63aec029a (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
223690801c feat(proxy): write one spend row per billed timed-out retry attempt (#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

Backport of #47416 to stable/1.104.x
Cherry-picked from ad8ca533ca (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
23902fea6a fix(proxy): requeue spend logs when a Postgres restart tears down the prisma engine mid-write (#47571)
Backport of #47571 to stable/1.104.x
Cherry-picked from ccd0d4ea49 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
23b420d513 feat(proxy): lift every earlier billed timed-out retry attempt onto the 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

---------

Backport of #47490 to stable/1.104.x
Cherry-picked from 7a4a255d1d (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
e2af1d25fe fix(decisions): log non-UTF-8 bytes as base64 so the request reaches validation and gets a 400 (#47564)
Backport of #47564 to stable/1.104.x
Cherry-picked from ce63f48ed2 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
bd0b38b4aa fix(litellm_proxy): forward tool_config cache_control_injection_points 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

Backport of #47570 to stable/1.104.x
Cherry-picked from 04e9ed4c52 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
b462563d14 fix(logging): report the pay-as-you-go entry billing used on Azure PTU 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

Backport of #47567 to stable/1.104.x
Cherry-picked from 4222523261 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
e71d121736 fix(proxy): price a billed failure row at the deployment's own rate like the success path (#47437)
Backport of #47437 to stable/1.104.x
Cherry-picked from fb555b00dc (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:11 +00:00
Kerry Lu
3b9892eb1d fix(proxy): price the estimated input tokens on a client-cancelled (499) 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

---------

Backport of #47436 to stable/1.104.x
Cherry-picked from 0e7c4908bb (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 01:14:10 +00:00
Kerry Lu
f585b558e9 fix(batches): apply the Vertex regional endpoint uplift to batch cost (#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

---------

Backport of #47466 to stable/1.104.x
Cherry-picked from c6c303a618 (main)

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>
2026-10-21 01:14:10 +00:00
Mateo Wang
5275320b61
Merge pull request #47634 from BerriAI/litellm_backport_bedrock_mantle_count_stable_1_104_x
Some checks are pending
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
fix(count_tokens): backport Bedrock Mantle count_tokens fallback to stable/1.104.x
2026-10-21 01:08:33 +00:00
joshua-berri
712dc21192 fix(batches): retry confirmed pre-accounting failures (#47625)
Backport of #47625 to stable/1.104.x.
Cherry-picked from 6564a490f4 (main).
Ported by hand onto the line's spend and budget code: the charge-once helpers move from model_max_budget_limiter into router_utils.batch_utils as on main; RouterBudgetLimiting keeps the line's websocket skip and uses the line's duration_in_seconds window for the batch marker TTL; the write_started mark covers budget reservations only, since the search free-tier allowance (#47494) is not on this line. Tests adapted to the line's _ProxyDBLogger name; the search-allowance test is dropped for the same reason.
2026-10-20 17:21:34 -07:00
daqiangganjun
ec25d80617 fix(router): count provider budget spend on every API surface (#38172)
Backport of #38172 to stable/1.104.x.
Cherry-picked from 8327cd6d47 (main).
Prerequisite for #47625: RouterBudgetLimiting reads the provider from the logging payload, so the batch poller's aretrieve_batch events reach router budgets at all. Test file placed at tests/unit/router_strategy/ on this line.
2026-10-20 17:21:34 -07:00
joshua-berri
f5049dba86 fix(bedrock): resolve profile pricing before applying custom rates (#47419)
Backport of #47419 to stable/1.104.x.
Cherry-picked from 3124797399 (main).
Ported onto the line's register_model and router startup path without #41523's aliased-entry rewrite: registered fields come from the side table added in the previous commit. Tests adapted to the line: private names (_replay_model_cost_registrations, _response_cost_calculator), the custom-pricing test helpers from main's test_cost_calculator.py, CONVERSE_ANSWER inlined, and the alias-propagation and bedrock gpt-6.1-sol/ARN cases removed since those depend on #41523 and #46128, which are not on this line.
2026-10-20 17:21:34 -07:00
Mrinal Chanshetty
7849ed2330 fix(pricing): port pricing helpers needed by #47419
Minimal port of helpers from #41523/#43890/#46647 needed by #47419; behavior changes of those PRs not included.
Adds lookup_model_info_for_registration, model_info_with_pricing_overrides, runtime_model_cost_registrations (fields each register_model call set, tracked in a side table cleared on cost-map reload instead of on AliasedCostEntry), the flat-price variant helpers, Router._cost_map_backend_model, and Router._inherit_builtin_service_tier_pricing with the tier-suffixed threshold keys from #43890.
2026-10-20 17:21:34 -07:00
Mrinal Chanshetty
15c8628664 chore(deps): bump aiohttp to 3.14.4 2026-10-20 17:21:34 -07:00
joshua-berri
21a84f9e8f fix(batch): preserve recoverable costs and prevent poll starvation (#47190)
Backport of #47190 to stable/1.104.x.
Cherry-picked from 0ede0e10e7 (main).
Ported by hand onto the line's poller (the ManagedObjectRow protocol is the line's local _ManagedObjectRow; _finalize_unbilled_terminal_job keeps the line's None return). Test conflicts take this PR's assertions; the line-item poller tests from main are not on this line.
2026-10-20 17:21:34 -07:00
Kerry Lu
96684a2570 fix(vertex_ai): bill per-character text embeddings on Google's billableCharacterCount (#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.

Backport of #47460 to stable/1.104.x
Cherry-picked from d29200fa05 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 00:05:41 +00:00
Kerry Lu
744f63b8db fix(logging): do not stamp a provider handoff when pre_call runs for a proxy-only failure (#47456)
Backport of #47456 to stable/1.104.x
Cherry-picked from 3fa1587f43 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 00:04:36 +00:00
Kerry Lu
ee8a1a5abd fix(proxy): price the estimated input tokens on a read-timed-out request's spend row (#47435)
Backport of #47435 to stable/1.104.x
Cherry-picked from 7b76b2b15f (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 00:03:28 +00:00
Kerry Lu
811cecdc3b fix(anthropic): apply tool_config cache-control points on chat and /v1/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

---------

Backport of #47394 to stable/1.104.x
Cherry-picked from 93b79d2587 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Tan Nguyen <tan@pressingly.net>
2026-10-21 00:01:31 +00:00
Kerry Lu
f0fb999131 fix(cost): bill Gemini audio/image/video prompt tokens at the resolved 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

---------

Backport of #47373 to stable/1.104.x
Cherry-picked from 09e9193514 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: shivam <shivam@berri.ai>
2026-10-20 23:57:26 +00:00
Kerry Lu
d64ac3998c feat(router): let a deployment set a timeout per service_tier (#47406)
* 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

---------

Backport of #47406 to stable/1.104.x
Cherry-picked from 62ce515d15 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: adc77 <amandogra2016@gmail.com>
2026-10-20 23:56:28 +00:00
Kerry Lu
826f404735 fix(decisions): log every request field the caller sent on /v1/systemone 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

---------

Backport of #47183 to stable/1.104.x
Cherry-picked from 53821f6654 (main)

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-20 23:54:07 +00:00
Kerry Lu
5684267b12 fix(logging): report the cost-map entry billing used in model_map_information (#47182)
Backport of #47182 to stable/1.104.x.
Cherry-picked from 1212260ab1 (main).
Adapted to the line's private helper names (_select_model_name_for_cost_calc, _response_cost_calculator); the new test is appended to the line's test file.
2026-10-20 16:12:01 -07:00