From cc33fc28226c0e8a25a0238a1d0dfca9ae1e783d Mon Sep 17 00:00:00 2001 From: "lentil32 (aider)" Date: Sun, 16 Mar 2025 15:27:36 +0900 Subject: [PATCH] feat: Handle AWS_PROFILE for Bedrock models in validate_environment --- aider/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/aider/models.py b/aider/models.py index cc54f03d3..7e28522fa 100644 --- a/aider/models.py +++ b/aider/models.py @@ -572,6 +572,21 @@ class Model(ModelSettings): model = self.name res = litellm.validate_environment(model) + + # If missing AWS credential keys but AWS_PROFILE is set, consider AWS credentials valid + if res["missing_keys"] and any( + key in ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"] for key in res["missing_keys"] + ): + if model.startswith("bedrock/") or model.startswith("us.anthropic."): + if os.environ.get("AWS_PROFILE"): + res["missing_keys"] = [ + k + for k in res["missing_keys"] + if k not in ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"] + ] + if not res["missing_keys"]: + res["keys_in_environment"] = True + if res["keys_in_environment"]: return res if res["missing_keys"]: