{"record":{"id":"0ae2ccdcd69ae334","repo":"BerriAI/litellm","slug":"bedrockexception-permissiondeniederror-error-st","errorCode":null,"errorMessage":"BedrockException PermissionDeniedError - {error_str}","messagePattern":"BedrockException PermissionDeniedError - (.+?)","errorType":"exception","errorClass":"PermissionDeniedError","httpStatus":403,"severity":"critical","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":869,"sourceCode":"    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),\n        )\n    elif \"Connect timeout on endpoint URL\" in error_str or \"timed out\" in error_str:\n        raise Timeout(\n            message=f\"BedrockException: Timeout Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L851-L887","documentation":"Bedrock-specific: PermissionDeniedError raised when the AWS error text contains 'AccessDeniedException'. Credentials are valid, but the identity is not allowed to perform this Bedrock action — most often bedrock:InvokeModel or bedrock:InvokeModelWithResponseStream for the requested model ARN.","triggerScenarios":"IAM policy lacks bedrock:InvokeModel on the model ARN, or the model has not been enabled in Bedrock model access settings; also cross-region calls where foundation model ARNs are region-specific.","commonSituations":"Fresh AWS accounts that never requested model access in the Bedrock console, IAM users/roles with broad policies missing bedrock actions, ARN typos (wrong region prefix), or scoped-down policies that list specific model ARNs and omit the one being called.","solutions":["In the Bedrock console, open Model access and request/enable access for the model, then wait for approval.","Attach/extend an IAM policy allowing bedrock:InvokeModel (and InvokeModelWithResponseStream if streaming) on the model ARN or '*'.","Verify the model id's region matches AWS_REGION — model ARNs are region-scoped.","Test with the AWS CLI (aws bedrock invoke-model ...) to separate IAM issues from litellm config."],"exampleFix":"# before\n# IAM policy only grants bedrock:ListFoundationModels\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=msgs)\n\n# after\n# add to the caller's IAM policy:\n# {\n#   \"Effect\": \"Allow\",\n#   \"Action\": [\"bedrock:InvokeModel\", \"bedrock:InvokeModelWithResponseStream\"],\n#   \"Resource\": \"arn:aws:bedrock:*::foundation-model/anthropic.claude-3-5-sonnet-*\"\n# }\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=msgs)","handlingStrategy":"validation","validationCode":"import boto3\n\ndef can_invoke_bedrock_model(model_id: str, region: str) -> bool:\n    \"\"\"Cheap probe: attempt a 1-token invocation to surface IAM/access issues early.\"n    try:\n        boto3.client(\"bedrock-runtime\", region_name=region).invoke_model(\n            modelId=model_id,\n            body=b'{\"prompt\": \"hi\", \"maxTokenCount\": 1}',\n            contentType=\"application/json\", accept=\"application/json\",\n        )\n        return True\n    except Exception as e:\n        return \"AccessDeniedException\" not in str(e)","typeGuard":"import litellm\n\ndef is_bedrock_permission_error(e: BaseException) -> bool:\n    return isinstance(e, litellm.PermissionDeniedError) and getattr(e, \"llm_provider\", \"\") == \"bedrock\"","tryCatchPattern":"try:\n    resp = litellm.completion(model=\"bedrock/...\", messages=msgs)\nexcept litellm.PermissionDeniedError:\n    raise RuntimeError(\"enable model access in Bedrock console and grant bedrock:InvokeModel in IAM\")","preventionTips":["Request model access in the Bedrock console before first use; approval is not instant.","Grant bedrock:InvokeModel on the specific foundation-model ARNs you call, in the right region.","Smoke-test with aws bedrock invoke-model in new accounts/environments."],"tags":["bedrock","aws","iam","permissions","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}