litellm/tests/unit/test_router
mika-lt c87362fe11
fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582)
* fix(bedrock): send native chat and responses calls to aws_bedrock_runtime_endpoint like converse

A deployment that set both api_base and aws_bedrock_runtime_endpoint sent
Converse calls to the runtime endpoint but native Chat Completions calls to a
full chat/completions api_base, and Responses calls to any api_base. Both
native routes now take the host from get_runtime_endpoint, so the runtime
endpoint (deployment value, else AWS_BEDROCK_RUNTIME_ENDPOINT) wins on every
route. With no runtime endpoint, api_base works as before.

Responses also strips a chat/completions suffix from the host, so a full chat
URL api_base reaches /openai/v1/responses on that host instead of a doubled
path that AWS answers with UnknownOperationException.

* fix(bedrock): keep the env runtime endpoint behind api_base, treat an empty endpoint as unset, trim a responses route on native chat

Only the deployment's own aws_bedrock_runtime_endpoint now wins over api_base on native chat and Responses. The AWS_BEDROCK_RUNTIME_ENDPOINT env var keeps the rank each route gave it before, so a full chat/completions api_base still wins over it on native chat and any api_base wins over it on Responses

An empty aws_bedrock_runtime_endpoint counts as unset on native chat, as it already did on Responses, and a runtime endpoint ending in a responses route is trimmed before native chat adds its chat/completions path

* fix(bedrock): name the host a Bedrock call went to in the api base header

x-litellm-model-api-base now names the scheme and host of the URL a Bedrock
call went to when that host differs from api_base, and keeps api_base
otherwise. Adds tests that a caller api_base never moves a deployment pinned
to aws_bedrock_runtime_endpoint and that native chat skips an unused region
when api_base is set

* fix(bedrock): trim a full route URL api_base before adding the Converse path

* test(bedrock): type the runtime endpoint tests

* fix(bedrock): trim an /openai/v1 api_base on the Converse fallback and keep credentials out of the reported host

A json_object request on a Bedrock GPT deployment whose api_base ends in /openai/v1 fell back to Converse at /openai/v1/model/<id>/converse and failed. Converse now trims that base path too.

The reported api_base origin drops any user and password from the runtime endpoint URL.

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-19 16:40:23 -08:00
..
core fix(router): optionally reject raw model collisions across groups (#52895) 2026-11-19 13:36:28 -08:00
__init__.py
test_enforce_model_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_io_token_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router.py feat(auth): read projects, tags, access groups and object permissions through rust repositories (#52178) 2026-11-18 22:32:06 +00:00
test_router_callback_hook_sequence.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_router_endpoints.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_entry_points.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_router_facade.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fallbacks.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_fuzz_regressions_rust_only.py 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
test_router_get_deployments.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_helper_utils.py fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
test_router_host.py 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
test_router_max_parallel_requests.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_router_provider_endpoints.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_router_retries.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00