{"record":{"id":"17fa92b1b4aa2107","repo":"Mintplex-Labs/anything-llm","slug":"no-azure-api-endpoint-was-set","errorCode":null,"errorMessage":"No Azure API endpoint was set.","messagePattern":"No Azure API endpoint was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/azureOpenAi/index.js","lineNumber":14,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  formatChatHistory,\n  handleDefaultStreamResponseV2,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\n\nclass AzureOpenAiLLM {\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI } = require(\"openai\");\n    if (!process.env.AZURE_OPENAI_ENDPOINT)\n      throw new Error(\"No Azure API endpoint was set.\");\n    if (!process.env.AZURE_OPENAI_KEY)\n      throw new Error(\"No Azure API key was set.\");\n\n    this.className = \"AzureOpenAiLLM\";\n    this.openai = new OpenAI({\n      apiKey: process.env.AZURE_OPENAI_KEY,\n      baseURL: AzureOpenAiLLM.formatBaseUrl(process.env.AZURE_OPENAI_ENDPOINT),\n    });\n    this.model =\n      modelPreference ||\n      process.env.AZURE_OPENAI_MODEL_PREF ||\n      process.env.OPEN_MODEL_PREF;\n    /* \n      Note: Azure OpenAI deployments do not expose model metadata that would allow us to\n      programmatically detect whether the deployment uses a reasoning model (o1, o1-mini, o3-mini, etc.).\n      As a result, we rely on the user to explicitly set AZURE_OPENAI_MODEL_TYPE=\"reasoning\"\n      when using reasoning models, as incorrect configuration might result in chat errors.\n    */","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/azureOpenAi/index.js#L1-L32","documentation":"Thrown by the AzureOpenAiLLM constructor when process.env.AZURE_OPENAI_ENDPOINT is falsy. Azure OpenAI requires an endpoint URL (per-resource) distinct from the key, and formatBaseUrl later parses it, so the constructor gates on its presence before anything else. It is checked before the key guard, so this fires first when both are missing.","triggerScenarios":"Instantiating AzureOpenAiLLM while AZURE_OPENAI_ENDPOINT is unset. The value should look like `https://<resource>.openai.azure.com` and is later normalized to `<endpoint>/openai/v1` by formatBaseUrl.","commonSituations":"Azure provider selected but endpoint not pasted; key was set but endpoint field left blank; env var misnamed (e.g. AZURE_OPENAI_URL); deploying to a new environment without copying the endpoint.","solutions":["Set `AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com` in .env and restart.","Re-save the Azure provider config in the UI so both endpoint and key are persisted.","Confirm the variable name exactly matches AZURE_OPENAI_ENDPOINT (no typo like ENDPOINT_URL).","Also set AZURE_OPENAI_KEY to avoid immediately hitting the next guard (error 167)."],"exampleFix":"// before\n// .env\nAZURE_OPENAI_ENDPOINT=\nAZURE_OPENAI_KEY=...\n\n// after\n// .env\nAZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com\nAZURE_OPENAI_KEY=...","handlingStrategy":"validation","validationCode":"if (!process.env.AZURE_OPENAI_ENDPOINT) {\n  throw new Error(\n    \"AZURE_OPENAI_ENDPOINT is missing. Set it to https://<resource>.openai.azure.com before using Azure.\"\n  );\n}\nconst llm = new AzureOpenAiLLM(embedder, modelPref);","typeGuard":"/** @param {unknown} v @returns {boolean} */\nfunction isNonEmptyString(v) {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const llm = new AzureOpenAiLLM(embedder, modelPref);\n} catch (e) {\n  if (/No Azure API endpoint/.test(e.message)) {\n    return { ok: false, reason: \"missing-endpoint\" };\n  }\n  throw e;\n}","preventionTips":["Group Azure config (endpoint, key, model pref) and validate all three together at save time.","Provide a template value (https://<resource>.openai.azure.com) in the UI to discourage hostname-only entries.","Document that Azure requires both endpoint and key, unlike some single-env providers.","Restart after .env edits."],"tags":["config","env","azure","constructor","precondition"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}