fix(bedrock): keep provider response headers on the runtime chat completions route

This commit is contained in:
mateo-berri 2026-09-28 22:21:54 -07:00
parent 84ae4596b5
commit 77204f84bc
2 changed files with 14 additions and 0 deletions

View file

@ -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

View file

@ -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(