BerriAI/litellm · error · PermissionDeniedError
BedrockException PermissionDeniedError
Error message
BedrockException PermissionDeniedError - {error_str} What it means
LiteLLM throws PermissionDeniedError when Bedrock returns AccessDeniedException: request signing succeeded (credentials are valid) but the principal is not authorized to invoke that model. Distinct from the AuthenticationError branch above - here it is an IAM/model-access authorization failure, HTTP 403-shaped.
Solutions
- Bedrock console -> Model access: request/enable access for the exact model in the exact region being called
- Attach an IAM policy allowing bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on the model ARN (arn:aws:bedrock:<region>::foundation-model/<model-id>) and the inference-profile ARN
- For cross-region inference profiles, also grant bedrock:InvokeModel on the application-inference-profile ARN
- Confirm aws_region_name matches the region where access was granted, and the model string's profile prefix (us./eu./apac.) matches
Example fix
# before: policy has only s3 permissions
litellm.completion(model="bedrock/anthropic.claude-3-sonnet-...", messages=msgs) # AccessDeniedException
# after: attach policy
# {"Version": "2012-10-17", "Statement": [{"Effect": "Allow",
# "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
# "Resource": ["arn:aws:bedrock:*:::foundation-model/*", "arn:aws:bedrock:*:<account>:inference-profile/*"]}]}
litellm.completion(model="bedrock/anthropic.claude-3-sonnet-...", messages=msgs) Defensive patterns
Strategy: try-catch
Type guard
import litellm
def is_permission_denied(e: BaseException) -> bool:
return isinstance(e, litellm.PermissionDeniedError) Try / catch
try:
resp = litellm.completion(model='bedrock/...', messages=msgs)
except litellm.PermissionDeniedError as e:
raise RuntimeError(
'Bedrock access denied: enable model access in the Bedrock console for region '
f'{aws_region} and grant bedrock:InvokeModel on the model ARN'
) from e Prevention
- Enable Bedrock model access per region at account setup time, not at first call
- Grant bedrock:InvokeModel(+WithResponseStream) on foundation-model and inference-profile ARNs in the IAM policy
- Keep aws_region_name and the model's region/inference-profile prefix in sync
- Add a startup canary call to each bedrock model to surface authorization gaps before traffic
When it happens
Trigger: IAM principal lacks bedrock:InvokeModel (or bedrock:InvokeModelWithResponseStream for streaming) on the model / inference-profile ARN; foundation model access never granted in the Bedrock console for that region; cross-account inference profile use without a resource policy.
Common situations: Fresh AWS accounts where model access was never requested; IAM users whose policies predate Bedrock and lack the bedrock:InvokeModel action; regional inference profiles (us./eu. prefixes) not covered by the policy; granting access in one region but calling another.
Related errors
- {err.response.text}
- {error_message}
- 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/0ae2ccdcd69ae334.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:869
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),
)
elif "Connect timeout on endpoint URL" in error_str or "timed out" in error_str:
raise Timeout(
message=f"BedrockException: Timeout Error - {error_str}",
model=model,
llm_provider="bedrock",
)View on GitHub (pinned to 77b7c6c40c)