BerriAI/litellm · error · AuthenticationError
BedrockException Invalid Authentication
Error message
BedrockException Invalid Authentication - {error_str} What it means
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.
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=...)
Example fix
# before: no credentials in environment litellm.completion(model="bedrock/anthropic.claude-3-sonnet-...", messages=msgs) # AuthenticationError # after import os os.environ['AWS_ACCESS_KEY_ID'] = '...' os.environ['AWS_SECRET_ACCESS_KEY'] = '...' os.environ['AWS_REGION'] = 'us-east-1' litellm.completion(model="bedrock/anthropic.claude-3-sonnet-...", messages=msgs)
Defensive patterns
Strategy: validation
Validate before calling
import boto3
def has_aws_credentials() -> bool:
return boto3.session.Session().get_credentials() is not None
# assert has_aws_credentials() before any bedrock/ call Type guard
import litellm
def is_bedrock_auth_error(e: BaseException) -> bool:
return isinstance(e, litellm.AuthenticationError) Try / catch
try:
resp = litellm.completion(model='bedrock/...', messages=msgs)
except litellm.AuthenticationError as e:
raise RuntimeError('AWS credentials missing/invalid - run aws configure / aws sso login') from e Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- No AWS credentials found for Bedrock realtime. Set aws_*…
- Bedrock Mantle auth failed: no Bearer token and no usable…
- AgentCore: Failed to read/parse JSON response body
- Amazon Nova Canvas INPAINTING requires either maskPrompt or…
- Amazon Nova Canvas requires a text prompt. Pass a non-empty…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/b394d64d1f935685.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:862
elif "Malformed input request" in error_str:
raise BadRequestError(
message=f"BedrockException - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "A conversation must start with a user message." in error_str:
raise BadRequestError(
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`",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif (
"Unable to locate credentials" in error_str
or "The security token included in the request is invalid" in error_str
):
raise AuthenticationError(
message=f"BedrockException Invalid Authentication - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "AccessDeniedException" in error_str:
raise PermissionDeniedError(
message=f"BedrockException PermissionDeniedError - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),
)
elif "throttlingException" in error_str or "ThrottlingException" in error_str:
raise RateLimitError(
message=f"BedrockException: Rate Limit Error - {error_str}",
model=model,
llm_provider="bedrock",
response=getattr(original_exception, "response", None),View on GitHub (pinned to 77b7c6c40c)