Mintplex-Labs/anything-llm · error

No Azure API endpoint was set.

Error message

No Azure API endpoint was set.

What it means

The AzureOpenAiLLM constructor requires AZURE_OPENAI_ENDPOINT before anything else - it is checked ahead of the key. The endpoint is the Azure resource URL (https://<resource>.openai.azure.com) and is normalized by formatBaseUrl into an /openai/v1 base URL. A missing value aborts provider construction on the first chat call.

Solutions

  1. Set the endpoint in System Settings -> AI Providers -> Azure OpenAI or export AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com
  2. Include the https:// scheme (bare hosts fail the URL parser)
  3. Pass env explicitly to docker/service units and restart
  4. Verify in the server context: Boolean(process.env.AZURE_OPENAI_ENDPOINT)

Example fix

# before
export AZURE_OPENAI_KEY=32charkey...

# after - both values required
export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com
export AZURE_OPENAI_KEY=32charkey...
Defensive patterns

Strategy: validation

Validate before calling

function canUseAzureOpenAI() {
  return Boolean(process.env.AZURE_OPENAI_ENDPOINT && process.env.AZURE_OPENAI_KEY);
}
if (!canUseAzureOpenAI()) {
  return res.status(503).json({ error: "Azure OpenAI provider is not configured" });
}
const llm = new AzureOpenAiLLM(embedder, modelPref);

Try / catch

try {
  const llm = new AzureOpenAiLLM(embedder, modelPref);
} catch (e) {
  if (/No Azure API endpoint/i.test(e.message)) {
    return res.status(503).json({ error: "Set AZURE_OPENAI_ENDPOINT (https://<resource>.openai.azure.com)" });
  }
  throw e;
}

Prevention

When it happens

Trigger: Selecting Azure OpenAI in provider settings without entering the endpoint; docker without -e AZURE_OPENAI_ENDPOINT; env var name typos (AZURE_OPENAI_ENDPOINT_URL, AZURE_ENDPOINT); the deployment platform stripping environment variables.

Common situations: Credentials saved in one environment but not the one actually running; container recreation without env; orchestrators (systemd, k8s) not passing the shell's env; partial setup where only the key was saved.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/17fa92b1b4aa2107. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/AiProviders/azureOpenAi/index.js:14

const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
  formatChatHistory,
  handleDefaultStreamResponseV2,
} = require("../../helpers/chat/responses");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");

class AzureOpenAiLLM {
  constructor(embedder = null, modelPreference = null) {
    const { OpenAI } = 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 = "AzureOpenAiLLM";
    this.openai = new OpenAI({
      apiKey: process.env.AZURE_OPENAI_KEY,
      baseURL: AzureOpenAiLLM.formatBaseUrl(process.env.AZURE_OPENAI_ENDPOINT),
    });
    this.model =
      modelPreference ||
      process.env.AZURE_OPENAI_MODEL_PREF ||
      process.env.OPEN_MODEL_PREF;
    /* 
      Note: Azure OpenAI deployments do not expose model metadata that would allow us to
      programmatically detect whether the deployment uses a reasoning model (o1, o1-mini, o3-mini, etc.).
      As a result, we rely on the user to explicitly set AZURE_OPENAI_MODEL_TYPE="reasoning"
      when using reasoning models, as incorrect configuration might result in chat errors.
    */

View on GitHub (pinned to 3aec848f28)