Mintplex-Labs/anything-llm · critical · Error

ENV: No valid LLM_PROVIDER value found in environment! Using

Error message

ENV: No valid LLM_PROVIDER value found in environment! Using ${process.env.LLM_PROVIDER}

What it means

Thrown by getLLMProvider() in its switch default when the `provider` argument (usually process.env.LLM_PROVIDER) matches no case. The switch enumerates every supported LLM backend (openai, anthropic, gemini, ollama, etc.); an unknown value means the system cannot construct a chat model. The message echoes the offending value for diagnosis. Note: 'anythingllm-router' has its own dedicated error because it must be resolved through AnythingLLMModelRouter.

Source

Thrown at server/utils/helpers/index.js:261

      const { LemonadeLLM } = require("../AiProviders/lemonade");
      return new LemonadeLLM(embedder, model);
    case "omlx":
      const { OMLXLLM } = require("../AiProviders/omlx");
      return new OMLXLLM(embedder, model);
    case "minimax":
      const { MinimaxLLM } = require("../AiProviders/minimax");
      return new MinimaxLLM(embedder, model);
    case "cerebras":
      const { CerebrasLLM } = require("../AiProviders/cerebras");
      return new CerebrasLLM(embedder, model);
    case "anythingllm-router":
      // Model router is handled separately in stream.js via AnythingLLMModelRouter.
      // This case should not be hit directly - if it is, throw a descriptive error.
      throw new Error(
        "anythingllm-router provider must be resolved via AnythingLLMModelRouter class, not getLLMProvider directly."
      );
    default:
      throw new Error(
        `ENV: No valid LLM_PROVIDER value found in environment! Using ${process.env.LLM_PROVIDER}`
      );
  }
}

/**
 * Returns the EmbedderProvider by itself to whatever is currently in the system settings.
 * @returns {BaseEmbedderProvider}
 */
function getEmbeddingEngineSelection() {
  const { NativeEmbedder } = require("../EmbeddingEngines/native");
  const engineSelection = process.env.EMBEDDING_ENGINE;
  switch (engineSelection) {
    case "openai":
      const { OpenAiEmbedder } = require("../EmbeddingEngines/openAi");
      return new OpenAiEmbedder();
    case "azure":
      const {

View on GitHub (pinned to 526360e320)

Solutions

  1. Set LLM_PROVIDER to a supported value (e.g. 'openai', 'anthropic', 'ollama', 'gemini').
  2. Check for leading/trailing whitespace or case in the env value.
  3. If migrating versions, re-save the LLM provider via the admin UI so the stored key matches the current build's switch.
  4. Confirm the matching AiProviders/*.js module exists in this build (a custom image may have pruned it).

Example fix

// before
// .env: LLM_PROVIDER=openAi   <- typo, throws

// after
// .env: LLM_PROVIDER=openai
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['openai','anthropic','gemini','ollama','lmstudio','localai','togetherai','fireworksai','perplexity','openrouter','mistral','groq','koboldcpp','textgenwebui','cohere','litellm','generic-openai','bedrock','deepseek','apipie','novita','xai','nvidia-nim','ppio','moonshotai','cometapi','foundry','zai','giteeai','docker-model-runner','privatemode','sambanova','lemonade','omlx','minimax','cerebras']);
if (!SUPPORTED.has(process.env.LLM_PROVIDER))
  throw new Error(`LLM_PROVIDER '${process.env.LLM_PROVIDER}' is not supported by this build`);

Type guard

function isSupportedProvider(v): v is string {
  return typeof v === 'string' && SUPPORTED.has(v);
}

Try / catch

try {
  const llm = getLLMProvider({ provider, model });
} catch (e) {
  if (e.message.includes('No valid LLM_PROVIDER'))
    return res.status(503).json({ error: 'LLM provider not configured' });
  throw e;
}

Prevention

When it happens

Trigger: LLM_PROVIDER set to a typo ('openAi'), a removed provider, an empty string, or a value from a newer/older version that this build does not recognize. A settings write that persisted a bad provider key.

Common situations: Upgrade/downgrade between AnythingLLM versions where provider keys changed; a .env copy-paste error; a Docker image missing a provider module so the key is stale; an admin UI that wrote a provider before validation.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/be52ccb1a53fe7ad. Report an issue: GitHub.