Mintplex-Labs/anything-llm · error · Error

Azure OpenAI Failed to embed: ${error}

Error message

Azure OpenAI Failed to embed: ${error}

What it means

Thrown after all concurrent embedding batch requests settle, when at least one batch returned an error. Per-batch errors are collected into a uniqueErrors set and joined into a single comma-separated message prefixed 'Azure OpenAI Failed to embed:'. If any batch fails the entire embedChunks call aborts and returns no vectors.

Source

Thrown at server/utils/EmbeddingEngines/azureOpenAi/index.js:105

        .flat();
      if (errors.length > 0) {
        let uniqueErrors = new Set();
        errors.map((error) =>
          uniqueErrors.add(`[${error.type}]: ${error.message}`)
        );

        return {
          data: [],
          error: Array.from(uniqueErrors).join(", "),
        };
      }
      return {
        data: results.map((res) => res?.data || []).flat(),
        error: null,
      };
    });

    if (!!error) throw new Error(`Azure OpenAI Failed to embed: ${error}`);
    return data.length > 0 &&
      data.every((embd) => embd.hasOwnProperty("embedding"))
      ? data.map((embd) => embd.embedding)
      : null;
  }
}

module.exports = {
  AzureOpenAiEmbedder,
};

View on GitHub (pinned to 526360e320)

Solutions

  1. Read the joined message: 'deployment not found' -> fix EMBEDDING_MODEL_PREF; '401'/'Unauthorized' -> rotate key; '429' -> reduce maxConcurrentChunks or batch size; content_filter -> clean input.
  2. Lower concurrency or chunk size to stay under Azure tokens-per-minute.
  3. Retry the embed call after fixing the persistent error; partial success is not returned, so all chunks must re-run.
  4. Verify the deployment name matches the Azure resource exactly (case-sensitive).

Example fix

// before
if (!!error) throw new Error(`Azure OpenAI Failed to embed: ${error}`);

// after (continue on partial, report missing indices)
if (!!error) {
  console.warn(`Azure embed partial failure: ${error}`);
}
return data.length > 0 && data.every((e) => e?.hasOwnProperty("embedding"))
  ? data.map((e) => e.embedding)
  : null;
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight a single tiny embed to validate deployment + key before bulk runs
try {
  await embedder.embedTextInput('ping');
} catch (e) {
  throw new Error(`Azure embed preflight failed: ${e.message}`);
}

Try / catch

try {
  await embedder.embedChunks(chunks);
} catch (e) {
  const msg = e.message;
  if (/deployment|not found/i.test(msg)) handleBadDeployment();
  else if (/401|unauthorized/i.test(msg)) rotateKey();
  else if (/429|rate/i.test(msg)) reduceConcurrency();
  else if (/content/i.test(msg)) sanitizeInput();
  else throw e;
}

Prevention

When it happens

Trigger: Wrong deployment name in EMBEDDING_MODEL_PREF (resource has no such deployment); 401 expired AZURE_OPENAI_KEY mid-run; 429 token-per-minute rate limits on large batches; input text exceeding the model's token limit; content filter rejecting a chunk; partial network failures hitting some concurrent batches.

Common situations: Embedding a large document set that spikes TPM and rate-limits several batches; a single oversized chunk; deployment deleted/renamed in Azure; key revoked between batches; content-policy blocks on certain text.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/1ac91a780c02faa7. Report an issue: GitHub.