{"record":{"id":"b394d64d1f935685","repo":"BerriAI/litellm","slug":"bedrockexception-invalid-authentication-error-s","errorCode":null,"errorMessage":"BedrockException Invalid Authentication - {error_str}","messagePattern":"BedrockException Invalid Authentication - (.+?)","errorType":"exception","errorClass":"AuthenticationError","httpStatus":401,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":862,"sourceCode":"    elif \"Malformed input request\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"A conversation must start with a user message.\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\\n. Pass in default user message via `completion(..,user_continue_message=)` or enable `litellm.modify_params=True`.\\nFor Proxy: do via `litellm_settings::modify_params: True` or user_continue_message under `litellm_params`\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif (\n        \"Unable to locate credentials\" in error_str\n        or \"The security token included in the request is invalid\" in error_str\n    ):\n        raise AuthenticationError(\n            message=f\"BedrockException Invalid Authentication - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"AccessDeniedException\" in error_str:\n        raise PermissionDeniedError(\n            message=f\"BedrockException PermissionDeniedError - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"throttlingException\" in error_str or \"ThrottlingException\" in error_str:\n        raise RateLimitError(\n            message=f\"BedrockException: Rate Limit Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L844-L880","documentation":"LiteLLM throws AuthenticationError when the AWS SDK behind a bedrock/ call reports 'Unable to locate credentials' or 'The security token included in the request is invalid'. The credentials could not be found at all, or were found but rejected as invalid/expired. Retrying with the same environment is pointless until credentials are provisioned or refreshed.","triggerScenarios":"No resolvable AWS credentials (missing env vars, no ~/.aws/credentials, no instance/task role) when calling litellm.completion(model='bedrock/...'); expired SSO token; stale AWS_SESSION_TOKEN after assuming a role; wrong AWS_PROFILE pointing at a nonexistent profile.","commonSituations":"Local development without running aws configure; CI containers lacking role assumption; long-running servers holding credentials that rotated underneath them; AWS_PROFILE typos in the shared credentials file.","solutions":["Provision credentials: aws configure, or export AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN, then verify with aws sts get-caller-identity","If using SSO: aws sso login --profile <profile> to refresh the access token","Check AWS_PROFILE and AWS_REGION resolve to the intended profile/region; confirm session tokens have not expired","For isolated testing, pass keys explicitly: litellm.completion(..., aws_access_key_id=..., aws_secret_access_key=..., aws_region_name=...)"],"exampleFix":"# before: no credentials in environment\nlitellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs)  # AuthenticationError\n\n# after\nimport os\nos.environ['AWS_ACCESS_KEY_ID'] = '...'\nos.environ['AWS_SECRET_ACCESS_KEY'] = '...'\nos.environ['AWS_REGION'] = 'us-east-1'\nlitellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs)","handlingStrategy":"validation","validationCode":"import boto3\n\ndef has_aws_credentials() -> bool:\n    return boto3.session.Session().get_credentials() is not None\n\n# assert has_aws_credentials() before any bedrock/ call","typeGuard":"import litellm\n\ndef is_bedrock_auth_error(e: BaseException) -> bool:\n    return isinstance(e, litellm.AuthenticationError)","tryCatchPattern":"try:\n    resp = litellm.completion(model='bedrock/...', messages=msgs)\nexcept litellm.AuthenticationError as e:\n    raise RuntimeError('AWS credentials missing/invalid - run aws configure / aws sso login') from e","preventionTips":["Pre-flight boto3.session.Session().get_credentials() before bedrock calls","Prefer attached IAM roles over pinned keys so credentials auto-rotate","Verify with aws sts get-caller-identity in startup health checks","Set AWS_PROFILE explicitly in multi-profile environments"],"tags":["bedrock","aws-credentials","authentication","sigv4"],"backgroundTag":"missing-aws-credentials","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}