litellm/tests/unit/llms/bedrock/chat
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
..
agentcore fix(streaming)!: fail a stream that ends without a finish reason (#47665) 2026-10-31 11:29:26 -07:00
chat_completions fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
invoke_transformations fix(bedrock): send the BM25 tool search tool on Claude chat requests (#52959) 2026-11-19 16:06:46 -08:00
mantle fix(bedrock): send native structured output for json_schema on Claude models that cannot force a tool (#49703) 2026-11-03 01:56:52 +00:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_bedrock_converse_handler.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_bedrock_gpt_oss.py test: move the unit half of 126 mixed legacy files into tests/unit (#45090) 2026-10-07 14:07:43 -07:00
test_converse_transformation.py fix(bedrock): send text.format.strict for GPT native structured output on Converse (#52419) 2026-11-19 00:35:39 +00:00
test_converse_transformation_nova_2.py fix(bedrock): drop another model's signed thinking when replaying to a non-Claude Converse target (#50073) 2026-11-06 03:15:49 -08:00
test_invoke_handler.py fix(bedrock): return a response for empty Invoke streams with complete_response (#52862) 2026-11-19 17:49:30 +00:00
test_mistral_config.py test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
test_native_output_fallback.py feat(bedrock): default to native structured output on Opus 5.5, Fable 5.1, Sonnet 5 and Haiku 5.5 (#50221) 2026-11-06 09:38:00 -08:00
test_service_tier.py fix(bedrock): answer 400 for service tiers Bedrock cannot serve, forward reserved (#50516) 2026-11-14 01:33:57 +00:00
test_streaming_choice_index.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_tool_result_images.py fix(bedrock): keep GPT tool-result images beside the tool result (#45579) 2026-10-09 18:02:23 -07:00
test_writer_palmyra.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00