mem0ai/mem0 · error · ValueError
AWS Bedrock error: {e}
Error message
AWS Bedrock error: {e} What it means
Catch-all ValueError raised by _initialize_aws_client for any boto3 ClientError other than UnauthorizedOperation — e.g. AccessDeniedException on list_foundation_models (model access not enabled), ValidationException, ThrottlingException, or region misconfiguration. The underlying AWS error code and message are embedded via {e}, so inspect that text to classify the real cause.
Source
Thrown at mem0/llms/aws_bedrock.py:107
self.client = boto3.client("bedrock-runtime", **aws_config)
# Test connection
self._test_connection()
except NoCredentialsError:
raise ValueError(
"AWS credentials not found. Please set AWS_ACCESS_KEY_ID, "
"AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables, "
"or provide them in the config."
)
except ClientError as e:
if e.response["Error"]["Code"] == "UnauthorizedOperation":
raise ValueError(
f"Unauthorized access to Bedrock. Please ensure your AWS credentials "
f"have permission to access Bedrock in region {self.config.aws_region}."
)
else:
raise ValueError(f"AWS Bedrock error: {e}")
def _test_connection(self):
"""Test connection to AWS Bedrock service."""
try:
# List available models to test connection
bedrock_client = boto3.client("bedrock", **self.config.get_aws_config())
response = bedrock_client.list_foundation_models()
self.available_models = [model["modelId"] for model in response["modelSummaries"]]
# Check if our model is available
if self.config.model not in self.available_models:
logger.warning(f"Model {self.config.model} may not be available in region {self.config.aws_region}")
logger.info(f"Available models: {', '.join(self.available_models[:5])}...")
except Exception as e:
logger.warning(f"Could not verify model availability: {e}")
self.available_models = []
View on GitHub (pinned to 001c235229)
Solutions
- Read the embedded error code in the message: AccessDeniedException -> enable model access in Bedrock console; ValidationException -> fix config; Throttling -> retry after backoff
- Verify AWS_REGION is a Bedrock-supported region and matches the model's availability
- Re-authenticate if ExpiredToken: refresh STS session or run aws sso login
- Retry initialization with exponential backoff for throttling errors
Example fix
// before
# aws_region unset, defaults to unsupported region -> AWS Bedrock error
# after
Memory.from_config({"llm": {"provider": "aws_bedrock", "config": {
"aws_region": "us-east-1", "model": "anthropic.claude-3-5-sonnet-20240620-v1:0"
}}}) Defensive patterns
Strategy: try-catch
Validate before calling
import boto3
from botocore.exceptions import ClientError
try:
boto3.client("bedrock", region_name=region).list_foundation_models()
except ClientError as e:
code = e.response["Error"]["Code"]
raise SystemExit(f"Bedrock preflight failed: {code}: {e}") # classify before mem0 init Try / catch
try:
llm = AWSBedrockLLM(config)
except ValueError as e:
msg = str(e)
if "AccessDeniedException" in msg:
fix = "enable model access in Bedrock console"
elif "ThrottlingException" in msg:
fix = "backoff and retry"
else:
fix = "inspect full AWS error text"
raise RuntimeError(f"{msg} — suggested fix: {fix}") from e Prevention
- Read the embedded AWS error code before guessing
- Use a Bedrock-supported region and enable model access per region
- Preflight list_foundation_models once at startup
When it happens
Trigger: Bedrock model access not enabled for the account (AccessDeniedException on ListFoundationModels); wrong AWS_REGION where Bedrock is unavailable; throttling during init; expired tokens surfacing as ExpiredTokenException
Common situations: New AWS account where Bedrock foundation models require console opt-in; unsupported region (e.g. some regions lack Bedrock); STS session tokens expired mid-run; rate limits hit at startup in multi-instance deployments.
Related errors
- The 'boto3' library is required. Please install it using 'pi
- Unknown provider_override '{explicit_provider}'. Valid provi
- Unknown provider in model: {model}
- AWS credentials not found. Please set AWS_ACCESS_KEY_ID, AWS
- Unauthorized access to Bedrock. Please ensure your AWS crede
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/27ed7a5ab4b688bb.
Report an issue: GitHub.