Mintplex-Labs/anything-llm · critical · Error

No Azure API key was set.

Error message

No Azure API key was set.

What it means

Thrown in the AzureOpenAiEmbedder constructor when AZURE_OPENAI_KEY is falsy, immediately after the endpoint check passes. Without the key the AzureOpenAI client cannot authenticate to the embeddings deployment.

Source

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

const { toChunks, reportEmbeddingProgress } = require("../../helpers");

class AzureOpenAiEmbedder {
  constructor() {
    const { AzureOpenAI } = require("openai");
    if (!process.env.AZURE_OPENAI_ENDPOINT)
      throw new Error("No Azure API endpoint was set.");
    if (!process.env.AZURE_OPENAI_KEY)
      throw new Error("No Azure API key was set.");

    this.className = "AzureOpenAiEmbedder";
    this.apiVersion = "2024-12-01-preview";
    const openai = new AzureOpenAI({
      apiKey: process.env.AZURE_OPENAI_KEY,
      endpoint: process.env.AZURE_OPENAI_ENDPOINT,
      apiVersion: this.apiVersion,
    });

    // We cannot assume the model fallback since the model is based on the deployment name
    // and not the model name - so this will throw on embedding if the model is not defined.
    this.model = process.env.EMBEDDING_MODEL_PREF;
    this.openai = openai;

    // Limit of how many strings we can process in a single pass to stay with resource or network limits
    // https://learn.microsoft.com/en-us/azure/ai-services/openai/faq#i-am-trying-to-use-embeddings-and-received-the-error--invalidrequesterror--too-many-inputs--the-max-number-of-inputs-is-1---how-do-i-fix-this-:~:text=consisting%20of%20up%20to%2016%20inputs%20per%20API%20request
    this.maxConcurrentChunks = 16;

View on GitHub (pinned to 526360e320)

Solutions

  1. Set AZURE_OPENAI_KEY to a valid key from the Azure OpenAI resource (Keys and Endpoint pane).
  2. Ensure AZURE_OPENAI_ENDPOINT is also set (the prior check).
  3. Restart the server after setting the var.
  4. If using keyless/Entra auth, note this embedder path requires the static key; switch to the appropriate provider or supply the key.
Defensive patterns

Strategy: validation

Validate before calling

function assertAzureEmbedKey() {
  if (!process.env.AZURE_OPENAI_KEY) {
    throw new Error('Missing env AZURE_OPENAI_KEY');
  }
}
assertAzureEmbedKey();

Try / catch

try {
  new AzureOpenAiEmbedder();
} catch (e) {
  if (/key/i.test(e.message) && /azure/i.test(e.message)) { /* prompt for AZURE_OPENAI_KEY */ }
  throw e;
}

Prevention

When it happens

Trigger: AZURE_OPENAI_ENDPOINT is set but AZURE_OPENAI_KEY is missing/empty; key stored under a different env name; key rotated in Azure but not redeployed.

Common situations: Copying the endpoint from the portal but not the key; using KEY_VAULT/managed identity without updating this constructor; AAD/Microsoft Entra auth intended but the code still requires the static key.

Related errors


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