{"record":{"id":"be52ccb1a53fe7ad","repo":"Mintplex-Labs/anything-llm","slug":"env-no-valid-llm-provider-value-found-in-environm","errorCode":null,"errorMessage":"ENV: No valid LLM_PROVIDER value found in environment! Using ${process.env.LLM_PROVIDER}","messagePattern":"ENV: No valid LLM_PROVIDER value found in environment! Using (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/helpers/index.js","lineNumber":261,"sourceCode":"      const { LemonadeLLM } = require(\"../AiProviders/lemonade\");\n      return new LemonadeLLM(embedder, model);\n    case \"omlx\":\n      const { OMLXLLM } = require(\"../AiProviders/omlx\");\n      return new OMLXLLM(embedder, model);\n    case \"minimax\":\n      const { MinimaxLLM } = require(\"../AiProviders/minimax\");\n      return new MinimaxLLM(embedder, model);\n    case \"cerebras\":\n      const { CerebrasLLM } = require(\"../AiProviders/cerebras\");\n      return new CerebrasLLM(embedder, model);\n    case \"anythingllm-router\":\n      // Model router is handled separately in stream.js via AnythingLLMModelRouter.\n      // This case should not be hit directly - if it is, throw a descriptive error.\n      throw new Error(\n        \"anythingllm-router provider must be resolved via AnythingLLMModelRouter class, not getLLMProvider directly.\"\n      );\n    default:\n      throw new Error(\n        `ENV: No valid LLM_PROVIDER value found in environment! Using ${process.env.LLM_PROVIDER}`\n      );\n  }\n}\n\n/**\n * Returns the EmbedderProvider by itself to whatever is currently in the system settings.\n * @returns {BaseEmbedderProvider}\n */\nfunction getEmbeddingEngineSelection() {\n  const { NativeEmbedder } = require(\"../EmbeddingEngines/native\");\n  const engineSelection = process.env.EMBEDDING_ENGINE;\n  switch (engineSelection) {\n    case \"openai\":\n      const { OpenAiEmbedder } = require(\"../EmbeddingEngines/openAi\");\n      return new OpenAiEmbedder();\n    case \"azure\":\n      const {","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/helpers/index.js#L243-L279","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set LLM_PROVIDER to a supported value (e.g. 'openai', 'anthropic', 'ollama', 'gemini').","Check for leading/trailing whitespace or case in the env value.","If migrating versions, re-save the LLM provider via the admin UI so the stored key matches the current build's switch.","Confirm the matching AiProviders/*.js module exists in this build (a custom image may have pruned it)."],"exampleFix":"// before\n// .env: LLM_PROVIDER=openAi   <- typo, throws\n\n// after\n// .env: LLM_PROVIDER=openai","handlingStrategy":"validation","validationCode":"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']);\nif (!SUPPORTED.has(process.env.LLM_PROVIDER))\n  throw new Error(`LLM_PROVIDER '${process.env.LLM_PROVIDER}' is not supported by this build`);","typeGuard":"function isSupportedProvider(v): v is string {\n  return typeof v === 'string' && SUPPORTED.has(v);\n}","tryCatchPattern":"try {\n  const llm = getLLMProvider({ provider, model });\n} catch (e) {\n  if (e.message.includes('No valid LLM_PROVIDER'))\n    return res.status(503).json({ error: 'LLM provider not configured' });\n  throw e;\n}","preventionTips":["Validate LLM_PROVIDER at startup and fail fast with a clear message.","Re-save the provider via the admin UI after version upgrades.","Trim/normalize the env value and confirm the matching AiProviders module exists."],"tags":["config","llm","provider","environment"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}