{"record":{"id":"9bc2eac71bb16582","repo":"Mintplex-Labs/anything-llm","slug":"no-azure-api-key-was-set","errorCode":null,"errorMessage":"No Azure API key was set.","messagePattern":"No Azure API key was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/azureOpenAi/index.js","lineNumber":16,"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    */\n    this.isOTypeModel =\n      process.env.AZURE_OPENAI_MODEL_TYPE === \"reasoning\" || false;","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/azureOpenAi/index.js#L1-L34","documentation":"Thrown when AZURE_OPENAI_ENDPOINT is present but AZURE_OPENAI_KEY is not; the constructor checks endpoint first, so seeing this error specifically means the endpoint passed and only the credential is missing. The key authenticates every completions call against the Azure resource. Both variables must reach the process together.","triggerScenarios":"Endpoint saved but the key field left blank in provider settings; key passed under a wrong name (AZURE_OPENAI_API_KEY); key set in the dev shell but not in the service manager/container; per-instance env drift.","commonSituations":"Partial configuration through the UI; copy-paste of only one of the two values from the Azure portal; docker-compose env_file updated for one service but not another.","solutions":["Set AZURE_OPENAI_KEY (the 32-character Azure key) in provider settings or the environment","Confirm the variable name is exactly AZURE_OPENAI_KEY","Ensure both endpoint and key reach the same process (docker -e / env_file)","Restart the server after fixing the environment"],"exampleFix":"# before\nexport AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com\n\n# after\nexport AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com\nexport AZURE_OPENAI_KEY=32charazurekey...","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}","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new AzureOpenAiLLM(embedder, modelPref);\n} catch (e) {\n  if (/No Azure API key/i.test(e.message)) {\n    return res.status(503).json({ error: \"Set AZURE_OPENAI_KEY for your resource\" });\n  }\n  throw e;\n}","preventionTips":["Configure endpoint and key as a pair; test one without the other wastes a deploy","Use the exact env names AZURE_OPENAI_ENDPOINT / AZURE_OPENAI_KEY","Keep docker-compose env_file in sync across services"],"tags":["azure-openai","api-key","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"}