litellm/tests/unit/router_rust
Mateo Wang e1b204f126
fix(router): warn when a Bedrock application inference profile ARN deployment cannot be priced (#55634)
* fix(router): warn when a Bedrock application inference profile ARN deployment cannot be priced

A deployment whose model is a Bedrock application inference profile ARN, with no
base_model and no custom pricing, logs $0 spend for every call because the ARN
names no model. Warn once per deployment when it is loaded from config or added
later, naming the deployment and asking for model_info.base_model

* perf(router): skip the unpriced-profile check before dumping params unless the model is an application profile ARN

* fix(router): match the unpriced-profile warning to what the cost calculator prices

Skip the warning when the cost map already prices the ARN (a register_model
entry), count only fields that set a rate as custom pricing, warn only for
deployments active in this environment, and tell admins to use the id the
profile was copied from, since a cross-region id is priced differently from
the bare model id.

* fix(router): warn when an application profile's base_model has no price in the cost map

* fix(router): check the base_model that per-call pricing reads before warning about an unpriced profile

Per-call pricing reads litellm_params.base_model before model_info.base_model, but the
warning read them the other way, so an admin could follow the warning, set a priced
model_info.base_model, and silence it while calls still logged $0. The warning now
resolves base_model in the per-call order and names the field that wins.

A profile ARN set as model_id under a label the cost map lacks now warns too, since
those calls also log $0.

* fix(logging): warn and count each call logged at $0 through an unpriced Bedrock ARN

The load-time warning only reaches the server log once per worker, so calls through
an unpriced Bedrock ARN, including bedrock/* wildcard and SDK calls, still logged $0
with nothing next to them. The per-call zero-cost check now reports them with the
reason unpriced_bedrock_arn in the warning and in litellm_zero_cost_requests_total.

An empty litellm_params.base_model now counts as unset in the load-time warning,
as it does in per-call pricing.

* fix(cost): warn per call for unpriced Bedrock ARNs on SDK and multiplier-only paths

SDK calls through an unpriced ARN fail cost calculation, so no pricing entry
resolves and the per-call check returned before the ARN diagnostic ran. A
register_model entry holding only an uplift multiplier counted as priced per
call while the load-time check, which counts rate fields only, warned.

The ARN diagnostic now runs with an empty pricing entry when none resolves,
and uses bedrock_arn_without_rates, the same rate-only rule as load time.

* fix(cost): skip the unpriced ARN warning for calls with explicit zero per-call rates

An SDK call through an unregistered Bedrock ARN that passes input_cost_per_token=0 and
output_cost_per_token=0 is free on purpose, but the ARN check only looked at the cost map
entry, so it warned and counted the call. The check now reads the call's own per-call
pricing first, the same way is_usage_explicitly_free does.
2026-12-02 15:56:21 -08:00
..
invoke feat(router)!: let a deployment choose which cache controls a request may override (#54219) 2026-11-24 14:33:59 -08:00
__init__.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_atomic_upsert.py fix(management): keep classifier deployments serving during reloads (#51111) 2026-11-11 18:48:06 +00:00
test_invoke_streaming.py fix(responses): bill a client-cancelled native Responses stream with the usage the provider reports (#54752) 2026-11-27 01:41:06 +00:00
test_routing_stores.py feat(redis): serve the health checks' deployment states from a native store (#50357) 2026-11-13 03:22:28 +00:00
test_surface_fallbacks.py feat(caching): configure semantic cache params per key, user and team (#53905) 2026-11-23 13:55:45 -08:00
test_surface_registry.py fix(router): warn when a Bedrock application inference profile ARN deployment cannot be priced (#55634) 2026-12-02 15:56:21 -08:00
test_walk.py fix(router): keep the request's metadata on rust core fallback hop kwargs (#50263) 2026-11-06 08:46:44 +09:00