{"record":{"id":"ff24d238555e63d4","repo":"mem0ai/mem0","slug":"error-getting-embedding-from-aws-bedrock-e","errorCode":null,"errorMessage":"Error getting embedding from AWS Bedrock: {e}","messagePattern":"Error getting embedding from AWS Bedrock: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/embeddings/aws_bedrock.py","lineNumber":98,"sourceCode":"\n        try:\n            response = self.client.invoke_model(\n                body=body,\n                modelId=self.config.model,\n                accept=\"application/json\",\n                contentType=\"application/json\",\n            )\n\n            response_body = json.loads(response.get(\"body\").read())\n\n            if provider == \"cohere\":\n                embeddings = response_body.get(\"embeddings\")[0]\n            else:\n                embeddings = response_body.get(\"embedding\")\n\n            return embeddings\n        except Exception as e:\n            raise ValueError(f\"Error getting embedding from AWS Bedrock: {e}\")\n\n    def embed(self, text, memory_action: Optional[Literal[\"add\", \"search\", \"update\"]] = None):\n        \"\"\"\n        Get the embedding for the given text using AWS Bedrock.\n\n        Args:\n            text (str): The text to embed.\n            memory_action (optional): The type of embedding to use. Must be one of \"add\", \"search\", or \"update\". Defaults to None.\n        Returns:\n            list: The embedding vector.\n        \"\"\"\n        return self._get_embedding(text)\n","sourceCodeStart":80,"sourceCodeEnd":111,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/embeddings/aws_bedrock.py#L80-L111","documentation":"AWSBedrockEmbedding._get_embedding wraps the bedrock-runtime invoke_model call and response parsing in a broad `except Exception`, re-raising as ValueError with the underlying exception appended. The original cause can be an auth failure (botocore NoCredentialsError), a bad model ID (ValidationException), throttling, or a malformed response body — the suffix carries the real reason.","triggerScenarios":"Calling .add()/.search() with the aws_bedrock embedder while AWS credentials are unresolved (NoCredentialsError); config.model naming a model not enabled in the region (ValidationException: could not resolve model); response.get('embedding') returning None for a provider whose payload key differs.","commonSituations":"Running outside an IAM role without AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY; using a cross-region model ARN with the wrong region_name; Bedrock model access not granted in the account; transient ThrottlingException under load.","solutions":["Read the text after the colon — it names the underlying botocore/Bedrock error; fix that first","Verify AWS credentials resolve: aws sts get-caller-identity in the same environment","Confirm the model ID is available and access-enabled in the configured region (Bedrock console > Model access)","For throttling, add backoff/retry around embed calls or reduce batch sizes"],"exampleFix":"# before\nconfig = BaseEmbedderConfig(model=\"amazon.titan-embed-text-v1\", aws_region=\"us-east-1\")  # model access not enabled\n\n# after\n# enable model access in Bedrock console, or use an enabled model:\nconfig = BaseEmbedderConfig(model=\"amazon.titan-embed-text-v2:0\", aws_region=\"us-east-1\")","handlingStrategy":"retry","validationCode":"import subprocess\ndef bedrock_ready() -> bool:\n    r = subprocess.run([\"aws\", \"sts\", \"get-caller-identity\"], capture_output=True)\n    return r.returncode == 0\n\nif not bedrock_ready():\n    raise RuntimeError(\"AWS credentials not resolved; configure env/role first\")","typeGuard":null,"tryCatchPattern":"try:\n    vec = embedding.embed(text)\nexcept ValueError as e:\n    msg = str(e)\n    if \"Throttling\" in msg:\n        backoff_and_retry()\n    elif \"credentials\" in msg.lower():\n        raise ConfigError(\"fix AWS auth\") from e\n    else:\n        raise","preventionTips":["Always inspect the suffix of this error — it contains the true botocore/Bedrock cause","Verify IAM credentials and Bedrock model access for the region before deploying","Wrap embed calls with exponential backoff for ThrottlingException"],"tags":["aws","bedrock","embeddings","credentials","runtime"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}