litellm/tests/unit/proxy/hooks
moe-berri ab51f3fe40
feat(realtime)!: serve GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband (#53282)
* feat(realtime): GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): pin sidebands to the session's deployment and authorize Live WebRTC like Live WebSocket

Run model-aware auth and the guardrail check before the provider session is created, authorize the attaching key for the session model, release an unmetered attach's budget hold and slot, forward call_id to Azure, and hand back provider errors on create.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): refuse WebRTC calls the proxy cannot meter, attach by creating key only, and pin Realtime sidebands

Wait for the billing sideband to join before returning the SDP answer, limit Live attach to the key that created the session, keep a Realtime WebRTC call on the deployment that minted its client secret, and select the Live deployment with the caller's request data.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): narrow the minted client secret to a string before it is encoded

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): resolve a deployment's stored credential when creating a Live WebRTC session

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): stop a billing sideband that did not join in time

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): let a refused billing sideband release its holds before it is stopped

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(realtime): rejoin a billing sideband that drops while its WebRTC call still runs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): carry the seconds each sideband billed to the one that rejoins, and stop a sideband given up on while it connects

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(realtime): authorize GPT-Live delegation against the key and keep retrying a dropped billing sideband

A Live session can delegate work to a second model and to vector stores. The delegated model and vector store ids are now checked against the calling key on WebRTC create, on the WebSocket session.start, and on later client frames that pass through the proxy.

A billing sideband that drops mid-call is now rejoined with a bounded, growing wait (1s up to 30s, 8 tries) and stops as soon as the provider reports the call gone. The caller's call is never ended by the proxy.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): check JSON-escaped delegation frames and enforce the tool allowlist on GPT-Live delegation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(realtime): walk a GPT-Live delegation without recursion

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): join an Azure WebRTC call's sideband on the GA route when the deployment is configured for beta

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): keep the billing sideband out of the call, bound its rejoins, add meter_webrtc_calls, shrink the client secret

The proxy's sideband no longer runs guardrails or sends anything into a WebRTC call.
A rejoin the proxy refuses itself is tried at most three times and logs one warning.
general_settings.meter_webrtc_calls set to false starts WebRTC calls without the billing sideband.
The realtime client secret carries the key's hash and the key is read again when the call starts.
POST /v1/live/sessions refuses any transport other than webrtc.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): send a delegated GPT-Live model under its provider name and hold it to its model budget

A GPT-Live session that delegates to a proxy model group now reaches the provider with the model that group is configured to call, on WebRTC create, on the WebSocket session.start and on later client frames the proxy relays.

A delegation to a model whose model_max_budget is used up is refused before the provider is called, and what a delegated response cost is charged to the delegated model's budget while the session's own model pays for the rest.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to every budgeted model group that calls its model

The provider reports a delegated response under its own model name, so when two proxy model groups call that model the charge went to the first one by name and the budget that admitted the delegation could stay untouched. Each budgeted group that calls the model is now charged.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to a team model's public name

A team-scoped deployment is routed under an internal name while its budget is keyed by the public name, so the public name now counts as a name the delegated model's budget can be charged under.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response once to a budget that covers several of its names

A wildcard or access-group budget resolves every name of the delegated model to one counter, so the counters are now deduplicated per delegated response before they are charged.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response only to deployments of that model or a dated snapshot of it

A deployment of gpt-4o no longer matches a delegated gpt-4o-mini response by prefix.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): charge a delegated response to its model's budget at the session's regional price

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): check a delegation against every budget it is charged to, keep tool schemas unchanged, and read the minting key from the key cache

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): rename delegated models by walking past tool schemas, linear in the size of the delegation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): a token always names its minting key, and a delegation the proxy cannot fully read is refused

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(realtime): drop the token fallback for an unreadable minting key, and never look the master key up as a stored key

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-21 22:49:26 -08:00
..
litellm_skills ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
model_capacity_golden feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
__init__.py
native_capacity_handler.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
parallel_request_limiter_v3_golden.json refactor(redis): move per-request miss, settlement and shutdown-drain tracking from Python into Rust (#51384) 2026-11-20 17:57:37 +09:00
test_async_post_call_streaming_iterator_hook.py fix(guardrails): run the end-of-stream post_call scan when the client disconnects mid-stream (#43839) 2026-10-05 01:44:43 -07:00
test_autorouter_baseline_cache.py feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
test_banned_keyword_list.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_batch_enqueued_tokens.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_batch_enqueued_tokens_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_batch_file_validation.py fix(proxy): resolve a team wildcard deployment for a wildcard key on files, batches and RAG routes (#49744) 2026-11-18 10:55:44 +00:00
test_batch_rate_limiter.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_dynamic_rate_limiter.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_dynamic_rate_limiter_v3_on_native_limiter_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_dynamic_rate_limiter_v3_rust.py feat(redis): serve the dynamic rate limiter's active teams from a native store (#52995) 2026-11-20 10:58:19 +09:00
test_image_generation_guardrails.py
test_key_management_event_hooks.py feat(control_plane): dataplane registry, credential strategies and client (#49655) 2026-11-16 17:36:23 +00:00
test_max_budget_per_session_limiter.py fix(redis): share one native circuit breaker between RedisCache and the Rust stores (#50473) 2026-11-07 17:50:06 +09:00
test_max_iterations_limiter.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_message_thread_ownership.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_model_budget_shared_windows.py feat(proxy)!: model family and access group entries in model_max_budget (#47722) 2026-10-28 15:40:57 -07:00
test_model_capacity_native.golden.json feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_model_capacity_native.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_model_max_budget_limiter.py feat(realtime)!: serve GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband (#53282) 2026-11-21 22:49:26 -08:00
test_parallel_request_limiter.py fix(proxy): count native Responses WebSocket turn tokens toward key and tag TPM limits (#49257) 2026-10-31 02:53:27 -07:00
test_parallel_request_limiter_v3.py feat(anthropic): price Claude subscription OAuth allowance usage at $0, overage at API rates (#52901) 2026-11-19 15:08:39 -08:00
test_parallel_request_limiter_v3_native.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_parallel_request_limiter_v3_rust.py fix(responses): stop the background stream when a polling response is cancelled (#49384) 2026-11-18 14:33:39 +00:00
test_post_call_failure_hook_integration.py
test_post_call_response_headers_hook.py
test_post_call_streaming_hook_integration.py
test_post_call_success_hook_integration.py
test_priority_class_share.py feat(dynamic_rate_limiter): customer organizations and keys borrow idle model capacity and split class shares (#51705) 2026-11-15 12:05:58 -08:00
test_prompt_cache_observer.py fix(proxy): keep a retried /v1/messages stream's spend log by logging the superseded attempt as a failure (#45136) 2026-10-16 21:19:58 +00:00
test_prompt_injection_detection.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_proxy_hooks_init.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_proxy_rate_limit_provider_field.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_proxy_rate_limit_provider_field_capacity_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_proxy_rate_limit_provider_field_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_proxy_track_cost_callback.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_proxy_track_cost_callback_ledger.py feat(budgets): run the ledger's post-call spend counter step in rust (#52166) 2026-11-20 16:31:03 -08:00
test_proxy_track_cost_callback_rust.py feat(proxy): add app groups with shared budgets and usage (#53232) 2026-11-21 12:50:58 -08:00
test_rate_limiter_toctou_capacity_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_rate_limiter_toctou_rust.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_search_free_tier.py fix(proxy): scope the search free-tier counter to the request's provider (#47646) 2026-10-20 22:01:53 +00:00
test_send_invite_email.py
test_sensitive_data_routing.py fix(redis): share one native circuit breaker between RedisCache and the Rust stores (#50473) 2026-11-07 17:50:06 +09:00
test_tpm_concurrent.py fix(proxy): leave cache-read tokens out of the priority limiter's token count (#52209) 2026-11-17 11:32:25 -08:00
test_tpm_concurrent_rust.py fix(google_genai): honor snake_case generation_config on generateContent (#51139) 2026-11-18 03:47:08 +00:00
test_unit_test_max_model_budget_limiter.py fix(router): inspect image content without translating routed requests (#49371) 2026-10-31 10:44:24 -07:00
test_user_management_event_hooks.py