The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(bedrock): stop leaking managed-batch litellm_params to the provider
Marty Sullivanb84dd6922e8b
diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 9baadc36f6b..b165aceb269 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -3398,9 +3398,22 @@ agentic_loop_internal_litellm_params: Final = [# the provider.TRUSTED_CALLBACK_VARS_FIELD: Final = "litellm_trusted_callback_vars"+# Bedrock managed-batch deployment config, read from litellm_params by the batch and+# files transformations. Listed for the same reason as the fields above: these sit on+# a deployment that also serves chat, so leaking them into extra_body makes Bedrock+# reject every non-batch request to that deployment.+bedrock_batch_litellm_params: Final = [+ "aws_batch_role_arn",+ "s3_bucket_name",+ "s3_region_name",+ "s3_output_bucket_name",+ "bedrock_tags",+]+all_litellm_params = (agentic_loop_internal_litellm_params+ [TRUSTED_CALLBACK_VARS_FIELD]+ + bedrock_batch_litellm_params+ ["metadata","litellm_metadata",diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex 01e7e5c7ffd..27e7096189b 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -29,7 +29,8 @@ from litellm.types.utils import (StreamingChoices,Usage,)-from litellm.types.utils import all_litellm_params+from litellm.types.utils import all_litellm_params, bedrock_batch_litellm_params+from litellm.types.router import GenericLiteLLMParamsfrom litellm.utils import (ProviderConfigManager,TextCompletionStreamWrapper,@@ -4752,3 +4753,36 @@ def test_websearch_interception_control_fields_never_reach_the_provider():f"{sorted(set(non_default) - {'a_real_provider_specific_param'})}")assert set(WEBSEARCH_INTERNAL_CONTROL_FIELDS) <= set(all_litellm_params)+++def test_bedrock_batch_params_never_reach_the_provider():+ """A Bedrock managed-batch deployment carries aws_batch_role_arn / s3_* /+ bedrock_tags in its litellm_params, and the same deployment also serves chat.+ Anything the param builder does not recognize is swept into extra_body, so+ Bedrock rejects the whole call: `aws_batch_role_arn: Extra inputs are not+ permitted` (Anthropic models) or `extraneous key [aws_batch_role_arn] is not+ permitted` (Nova/Llama/Titan), turning every non-batch request to that+ deployment into a 400.++ The batch path is unaffected by registering them, because GenericLiteLLMParams+ is extra="allow" and preserves them into litellm_params for the batch and files+ transformations that read them.+ """+ kwargs = {+ "a_real_provider_specific_param": 1,+ **{field: "configured-value" for field in bedrock_batch_litellm_params},+ }++ non_default = get_non_default_completion_params(dict(kwargs))++ assert non_default == {"a_real_provider_specific_param": 1}, (+ "bedrock batch params leaked into the provider params: "+ f"{sorted(set(non_default) - {'a_real_provider_specific_param'})}"+ )+ assert set(bedrock_batch_litellm_params) <= set(all_litellm_params)++ batch_params = dict(GenericLiteLLMParams(**kwargs))+ assert all(batch_params.get(field) == "configured-value" for field in bedrock_batch_litellm_params), (+ "registering these must not strip them from the batch path: "+ f"{sorted(f for f in bedrock_batch_litellm_params if batch_params.get(f) != 'configured-value')}"+ )