From 8c5f96e9406191792ee02a7f2acefaacab5fd861 Mon Sep 17 00:00:00 2001 From: shivam Date: Fri, 24 Jul 2026 21:00:22 +0000 Subject: [PATCH] fix(router): keep bedrock batch litellm_params through credential resolution Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/types/router.py | 5 ++++ tests/test_litellm/test_router.py | 39 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/litellm/types/router.py b/litellm/types/router.py index 28e4a8272e8..1d9664f8dc6 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -211,6 +211,11 @@ class CredentialLiteLLMParams(BaseModel): aws_bedrock_runtime_endpoint: Optional[str] = None aws_bedrock_project_id: Optional[str] = None s3_bucket_name: Optional[str] = None + s3_output_bucket_name: Optional[str] = None + s3_region_name: Optional[str] = None + s3_encryption_key_id: Optional[str] = None + aws_batch_role_arn: Optional[str] = None + bedrock_tags: Optional[List[Dict[str, str]]] = None ## IBM WATSONX ## watsonx_region_name: Optional[str] = None diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.py index cffc3dd0aba..61aa4d6ba14 100644 --- a/tests/test_litellm/test_router.py +++ b/tests/test_litellm/test_router.py @@ -3666,6 +3666,45 @@ def test_get_deployment_credentials_with_provider_includes_bucket_name(): assert credentials["custom_llm_provider"] == "vertex_ai" +def test_get_deployment_credentials_with_provider_includes_bedrock_batch_params(): + """ + Regression: the Bedrock batch/files params must survive the CredentialLiteLLMParams + filter. When they were dropped, model-routed POST /v1/batches failed with + "Set 'aws_batch_role_arn' in litellm_params or AWS_BATCH_ROLE_ARN env var" even + though the deployment declared it. + """ + router = litellm.Router( + model_list=[ + { + "model_name": "bedrock-batch", + "litellm_params": { + "model": "bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0", + "aws_region_name": "us-east-1", + "s3_bucket_name": "my-input-bucket", + "s3_output_bucket_name": "my-output-bucket", + "s3_region_name": "us-west-2", + "s3_encryption_key_id": "arn:aws:kms:us-east-1:123:key/abc", + "aws_batch_role_arn": "arn:aws:iam::123:role/BedrockBatchRole", + "bedrock_tags": [{"key": "team", "value": "platform"}], + }, + } + ], + ) + + credentials = router.get_deployment_credentials_with_provider( + model_id="bedrock-batch" + ) + + assert credentials is not None + assert credentials["s3_bucket_name"] == "my-input-bucket" + assert credentials["s3_output_bucket_name"] == "my-output-bucket" + assert credentials["s3_region_name"] == "us-west-2" + assert credentials["s3_encryption_key_id"] == "arn:aws:kms:us-east-1:123:key/abc" + assert credentials["aws_batch_role_arn"] == "arn:aws:iam::123:role/BedrockBatchRole" + assert credentials["bedrock_tags"] == [{"key": "team", "value": "platform"}] + assert credentials["custom_llm_provider"] == "bedrock" + + def test_get_deployment_credentials_with_provider_resolves_credential_name(): """ Test that get_deployment_credentials_with_provider correctly resolves