{"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":null,"httpStatus":null,"severity":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/azureOpenAi/index.js#L1-L32","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the endpoint in System Settings -> AI Providers -> Azure OpenAI or export AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com","Include the https:// scheme (bare hosts fail the URL parser)","Pass env explicitly to docker/service units and restart","Verify in the server context: Boolean(process.env.AZURE_OPENAI_ENDPOINT)"],"exampleFix":"# before\nexport AZURE_OPENAI_KEY=32charkey...\n\n# after - both values required\nexport AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com\nexport AZURE_OPENAI_KEY=32charkey...","handlingStrategy":"validation","validationCode":"function canUseAzureOpenAI() {\n  return Boolean(process.env.AZURE_OPENAI_ENDPOINT && process.env.AZURE_OPENAI_KEY);\n}\nif (!canUseAzureOpenAI()) {\n  return res.status(503).json({ error: \"Azure OpenAI provider is not configured\" });\n}\nconst llm = new AzureOpenAiLLM(embedder, modelPref);","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new AzureOpenAiLLM(embedder, modelPref);\n} catch (e) {\n  if (/No Azure API endpoint/i.test(e.message)) {\n    return res.status(503).json({ error: \"Set AZURE_OPENAI_ENDPOINT (https://<resource>.openai.azure.com)\" });\n  }\n  throw e;\n}","preventionTips":["Save both endpoint and key together in the provider settings UI","Pass env pairs explicitly to containers and service units","Startup-check provider construction instead of failing mid-chat"],"tags":["azure-openai","endpoint","environment","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}