danny-avila/LibreChat · error

Assistants API key not provided. Please provide it again.

Error message

Assistants API key not provided. Please provide it again.

What it means

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.

Source

Thrown at api/server/services/Endpoints/azureAssistants/initialize.js:154

      if (serverless === true) {
        clientOptions.defaultQuery = azureOptions.azureOpenAIApiVersion
          ? { 'api-version': azureOptions.azureOpenAIApiVersion }
          : undefined;
        clientOptions.headers['api-key'] = apiKey;
      }
    }
  }

  if (userProvidesKey & !apiKey) {
    throw new Error(
      JSON.stringify({
        type: ErrorTypes.NO_USER_KEY,
      }),
    );
  }

  if (!apiKey) {
    throw new Error('Assistants API key not provided. Please provide it again.');
  }

  if (baseURL) {
    opts.baseURL = baseURL;
  }

  const proxyDispatcher = getProxyDispatcher(PROXY);
  if (proxyDispatcher) {
    opts.fetchOptions = {
      dispatcher: proxyDispatcher,
    };
  }

  if (OPENAI_ORGANIZATION) {
    opts.organization = OPENAI_ORGANIZATION;
  }

  /** @type {OpenAIClient} */

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Set AZURE_ASSISTANTS_API_KEY to a valid Azure OpenAI key in your env/secret manager and restart the API server.
  2. Verify the variable is actually in the process env (log Object.keys(process.env).filter(k => k.includes('AZURE')), never the value).
  3. 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.

Example fix

# before
AZURE_ASSISTANTS_API_KEY=

# after
AZURE_ASSISTANTS_API_KEY=<your-azure-openai-key>
Defensive patterns

Strategy: validation

Validate before calling

// At boot, fail fast if the key is required and not user-provided
const AZURE_ASSISTANTS_API_KEY = process.env.AZURE_ASSISTANTS_API_KEY;
const { isUserProvided } = require('@librechat/api');
if (!isUserProvided(AZURE_ASSISTANTS_API_KEY) && !AZURE_ASSISTANTS_API_KEY) {
  throw new Error('AZURE_ASSISTANTS_API_KEY is missing and not configured as user-provided');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/56bb92dbf2c69b6f. Report an issue: GitHub.