From 77204f84bcae164d7c2f63b9db1b7b85300a8a54 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 28 Sep 2026 22:21:54 -0700 Subject: [PATCH] fix(bedrock): keep provider response headers on the runtime chat completions route --- .../bedrock/chat/chat_completions/transformation.py | 2 ++ .../test_bedrock_chat_completions_transformation.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/litellm/llms/bedrock/chat/chat_completions/transformation.py b/litellm/llms/bedrock/chat/chat_completions/transformation.py index 2025927807b..c424ca2a069 100644 --- a/litellm/llms/bedrock/chat/chat_completions/transformation.py +++ b/litellm/llms/bedrock/chat/chat_completions/transformation.py @@ -22,6 +22,7 @@ import httpx from typing_extensions import assert_never import litellm +from litellm.litellm_core_utils.core_helpers import set_provider_response_headers_in_hidden_params from litellm.litellm_core_utils.prompt_templates.image_handling import ( async_inline_remote_media, inline_remote_image_urls, @@ -383,6 +384,7 @@ class AmazonBedrockRuntimeChatCompletionsConfig(OpenAILikeChatConfig): api_key=api_key, json_mode=json_mode, ) + set_provider_response_headers_in_hidden_params(response, raw_response.headers) for choice in response.choices: if not isinstance(choice, Choices) or not isinstance(choice.message.content, str): continue diff --git a/tests/unit/llms/bedrock/chat/chat_completions/test_bedrock_chat_completions_transformation.py b/tests/unit/llms/bedrock/chat/chat_completions/test_bedrock_chat_completions_transformation.py index 26392921c47..e40ef13e25a 100644 --- a/tests/unit/llms/bedrock/chat/chat_completions/test_bedrock_chat_completions_transformation.py +++ b/tests/unit/llms/bedrock/chat/chat_completions/test_bedrock_chat_completions_transformation.py @@ -222,6 +222,18 @@ def test_completion_posts_runtime_chat_completions(local_cost_map, fake_aws_env) assert "inferenceConfig" not in body +def test_completion_keeps_the_aws_request_id_as_a_provider_header(local_cost_map, fake_aws_env): + _, client = _recording_client( + json=_chat_completion_json("ok", "us.xai.grok-4.6"), headers={"x-amzn-requestid": "req-native-1"} + ) + response = litellm.completion( + model="bedrock/chat_completions/us.xai.grok-4.6", + messages=[{"role": "user", "content": "hello"}], + client=client, + ) + + assert response._hidden_params["additional_headers"]["llm_provider-x-amzn-requestid"] == "req-native-1" + def test_region_path_sends_the_bare_model_id_to_the_path_region(local_cost_map, fake_aws_env): requests, client = _recording_client(json=_chat_completion_json("ok", "openai.gpt-oss-20b-1:0")) litellm.completion(