{"record":{"id":"56bb92dbf2c69b6f","repo":"danny-avila/LibreChat","slug":"assistants-api-key-not-provided-please-provide-it-56bb92","errorCode":null,"errorMessage":"Assistants API key not provided. Please provide it again.","messagePattern":"Assistants API key not provided\\. Please provide it again\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Endpoints/azureAssistants/initialize.js","lineNumber":154,"sourceCode":"      if (serverless === true) {\n        clientOptions.defaultQuery = azureOptions.azureOpenAIApiVersion\n          ? { 'api-version': azureOptions.azureOpenAIApiVersion }\n          : undefined;\n        clientOptions.headers['api-key'] = apiKey;\n      }\n    }\n  }\n\n  if (userProvidesKey & !apiKey) {\n    throw new Error(\n      JSON.stringify({\n        type: ErrorTypes.NO_USER_KEY,\n      }),\n    );\n  }\n\n  if (!apiKey) {\n    throw new Error('Assistants API key not provided. Please provide it again.');\n  }\n\n  if (baseURL) {\n    opts.baseURL = baseURL;\n  }\n\n  const proxyDispatcher = getProxyDispatcher(PROXY);\n  if (proxyDispatcher) {\n    opts.fetchOptions = {\n      dispatcher: proxyDispatcher,\n    };\n  }\n\n  if (OPENAI_ORGANIZATION) {\n    opts.organization = OPENAI_ORGANIZATION;\n  }\n\n  /** @type {OpenAIClient} */","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Endpoints/azureAssistants/initialize.js#L136-L172","documentation":"Thrown by the Azure Assistants client initializer when no API key resolves at line 153. The preceding guard at line 145 (`userProvidesKey & !apiKey`) already handles the 'user-supplied key expected but missing' case via a NO_USER_KEY error, so reaching line 153 means the server is in env-managed mode (isUserProvided(AZURE_ASSISTANTS_API_KEY) is false) and AZURE_ASSISTANTS_API_KEY is unset or empty. The OpenAI client cannot be constructed without a key, so initialization fails fast.","triggerScenarios":"Hitting any Azure Assistants endpoint (e.g. POST /api/assistants/chat, agent init) while AZURE_ASSISTANTS_API_KEY is unset, empty, or whitespace, and the endpoint is NOT configured to accept a user-provided key.","commonSituations":"Fresh deploy that never set the env var; .env not loaded into the running process; key blanked during a secrets rotation and not restored; typo in the variable name; docker/compose `environment:` block omitting the var; k8s Secret not mounted.","solutions":["Set AZURE_ASSISTANTS_API_KEY to a valid Azure OpenAI key in your env/secret manager and restart the API server.","Verify the variable is actually in the process env (log Object.keys(process.env).filter(k => k.includes('AZURE')), never the value).","If you intend bring-your-own-key, set AZURE_ASSISTANTS_API_KEY to the user-provided marker so isUserProvided() returns true and the client collects the key per request instead of throwing here."],"exampleFix":"# before\nAZURE_ASSISTANTS_API_KEY=\n\n# after\nAZURE_ASSISTANTS_API_KEY=<your-azure-openai-key>","handlingStrategy":"validation","validationCode":"// At boot, fail fast if the key is required and not user-provided\nconst AZURE_ASSISTANTS_API_KEY = process.env.AZURE_ASSISTANTS_API_KEY;\nconst { isUserProvided } = require('@librechat/api');\nif (!isUserProvided(AZURE_ASSISTANTS_API_KEY) && !AZURE_ASSISTANTS_API_KEY) {\n  throw new Error('AZURE_ASSISTANTS_API_KEY is missing and not configured as user-provided');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate required env vars at startup so misconfigurations surface immediately.","Use a secret manager / k8s Secret rather than hand-editing .env.","Never log the key value; log only the presence of the env var.","After any secrets rotation, restart the API process so the new env is loaded."],"tags":["azure-assistants","config","api-key","env","initialization"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}