mem0ai/mem0 · error · Error

Error getting embedding from AWS Bedrock model ${this.model}

Error message

Error getting embedding from AWS Bedrock model ${this.model}: ${message}

What it means

Thrown by the AWS Bedrock embedder when the bedrock-runtime SendCommand/InvokeModel call fails or the response body cannot be parsed. The underlying error message is appended (e.g. AccessDeniedException, throttling, model-not-enabled, invalid manifest, DNS failure), so the suffix identifies the root cause. This wraps every failure in the invoke() path — request construction, transport, and JSON decode.

Source

Thrown at mem0-ts/src/oss/src/embeddings/aws_bedrock.ts:233

  ): Promise<number[][]> {
    const { sdk, client } = await this.getClient();

    let payload: BedrockEmbeddingResponse;
    try {
      const response = await client.send(
        new sdk.InvokeModelCommand({
          modelId: this.model,
          contentType: "application/json",
          accept: "application/json",
          body: new TextEncoder().encode(
            JSON.stringify(this.buildRequestBody(texts, memoryAction)),
          ),
        }),
      );
      payload = JSON.parse(new TextDecoder().decode(response.body));
    } catch (error) {
      const message = error instanceof Error ? error.message : String(error);
      throw new Error(
        `Error getting embedding from AWS Bedrock model ${this.model}: ${message}`,
      );
    }

    // Validated outside the try so this message is not re-wrapped by the catch.
    // Cohere v3 replies with a flat `embeddings` array; v4 (when
    // embedding_types is requested) nests it under `.float`.
    const embeddings = this.isCohereModel()
      ? Array.isArray(payload.embeddings)
        ? payload.embeddings
        : payload.embeddings?.float
      : payload.embedding && [payload.embedding];

    // `[]` is truthy, so a lone zero-length vector must be checked for
    // explicitly -- otherwise it passes the length check and hands the
    // caller an empty embedding instead of an error.
    if (
      !embeddings ||

View on GitHub (pinned to 001c235229)

Solutions

  1. Read the appended original message — it names the AWS exception and points at the fix
  2. Grant bedrock:InvokeModel on the model ARN and request model access in the Bedrock console for the configured region
  3. Verify region/model pairing (e.g. cohere.embed-english-v3 availability) and that config.model matches an inference profile ID if your account requires profile ARNs
  4. Add exponential backoff for throttling exceptions before retrying the add/search operation

Example fix

// before
embedder: { provider: 'aws_bedrock', config: { model: 'cohere.embed-english-v3', region: 'us-east-1' } }
// -> 'Error getting embedding from AWS Bedrock model cohere.embed-english-v3: User is not authorized...'

// after
// 1. IAM: allow bedrock:InvokeModel on arn:aws:bedrock:us-east-1::foundation-model/cohere.embed-english-v3
// 2. Bedrock console: Model access -> request access for Cohere Embed
embedder: { provider: 'aws_bedrock', config: { model: 'cohere.embed-english-v3', region: 'us-east-1' } }
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: cheap invoke before wiring memory into your app
const embedder = new AwsBedrockEmbedder(config);
await embedder.embed('ping'); // surfaces IAM/model-access errors at startup, not mid-request

Try / catch

const isTransientBedrockError = (e: unknown) => {
  const m = e instanceof Error ? e.message : String(e);
  return /TooManyRequests|Throttling|ServiceUnavailable|timeout/i.test(m);
};
try {
  await embedder.embed(text);
} catch (e) {
  if (isTransientBedrockError(e)) await backoffRetry(() => embedder.embed(text));
  else throw e; // AccessDenied / model-not-enabled need config or IAM changes, not retries
}

Prevention

When it happens

Trigger: Model not enabled/subscribed in the region (ValidationException: model with ID ... is not accessible); missing bedrock:InvokeModel IAM permission (AccessDeniedException); throttling (TooManyRequestsException/ServiceUnavailable); wrong region in config; cross-region endpoint mismatch; malformed input for the model family.

Common situations: IAM role lacks bedrock:InvokeModel for the model ARN; Bedrock model access not yet granted in the console (requires requesting access per model); region set to one where the model is unavailable; throttling under burst load with no backoff.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/19e8a6536e5c91c4. Report an issue: GitHub.