{"record":{"id":"47712370f7af0627","repo":"Mintplex-Labs/anything-llm","slug":"litellm-api-base-path-and-key-must-be-provided-to","errorCode":null,"errorMessage":"LiteLLM API base path and key must be provided to use agents.","messagePattern":"LiteLLM API base path and key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":209,"sourceCode":"            \"TextWebGenUI API base path must be provided to use agents.\"\n          );\n        break;\n      case \"bedrock\":\n        // No validations since there are many possible authentication methods\n        break;\n      case \"fireworksai\":\n        if (!process.env.FIREWORKS_AI_LLM_API_KEY)\n          throw new Error(\n            \"FireworksAI API Key must be provided to use agents.\"\n          );\n        break;\n      case \"deepseek\":\n        if (!process.env.DEEPSEEK_API_KEY)\n          throw new Error(\"DeepSeek API Key must be provided to use agents.\");\n        break;\n      case \"litellm\":\n        if (!process.env.LITE_LLM_BASE_PATH)\n          throw new Error(\n            \"LiteLLM API base path and key must be provided to use agents.\"\n          );\n        break;\n      case \"apipie\":\n        if (!process.env.APIPIE_LLM_API_KEY)\n          throw new Error(\"ApiPie API Key must be provided to use agents.\");\n        break;\n      case \"xai\":\n        if (!process.env.XAI_LLM_API_KEY)\n          throw new Error(\"xAI API Key must be provided to use agents.\");\n        break;\n      case \"zai\":\n        if (!process.env.ZAI_API_KEY)\n          throw new Error(\"Z.AI API Key must be provided to use agents.\");\n        break;\n      case \"novita\":\n        if (!process.env.NOVITA_LLM_API_KEY)\n          throw new Error(\"Novita API Key must be provided to use agents.\");","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L191-L227","documentation":"Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:208) when the workspace agent provider is 'litellm' but LITE_LLM_BASE_PATH is unset/empty. LiteLLM is a proxy that exposes many backends through one OpenAI-compatible URL; AnythingLLM validates the proxy base path here. Note the message says 'base path and key' but the code only checks the base path, so a missing key will surface later as a provider auth error.","triggerScenarios":"An agent invocation runs with workspace.agentProvider === 'litellm' while LITE_LLM_BASE_PATH is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.","commonSituations":"LiteLLM proxy provider selected in System > LLM Preference without the proxy URL; the proxy moved port/host after restart; .env edited but AnythingLLM not restarted; proxy reachable on the host but AnythingLLM is in a container that cannot resolve it.","solutions":["Set LITE_LLM_BASE_PATH in .env to the LiteLLM proxy URL (e.g. http://127.0.0.1:4000/v1).","If the proxy enforces a master key, also set LITE_LLM_API_KEY (the guard does not check it, but later calls will fail without it).","Restart AnythingLLM to reload process.env.","Confirm with curl <base path>/models (add Authorization if the proxy requires it)."],"exampleFix":"// before (.env)\n// LITE_LLM_BASE_PATH=\n// LITE_LLM_API_KEY=\n\n// after (.env)\nLITE_LLM_BASE_PATH=http://127.0.0.1:4000/v1\nLITE_LLM_API_KEY=sk-...proxy-master-key","handlingStrategy":"validation","validationCode":"const base = process.env.LITE_LLM_BASE_PATH;\nif (!base) {\n  throw new Error(\n    'Cannot start LiteLLM agent: set LITE_LLM_BASE_PATH (proxy URL, e.g. http://127.0.0.1:4000/v1) in .env.'\n  );\n}\ntry { new URL(base); } catch { throw new Error('LITE_LLM_BASE_PATH is not a valid URL'); }\n// The checkSetup guard only checks base path; set the proxy key too to avoid a later auth failure:\nif (process.env.LITE_LLM_API_KEY == null) {\n  console.warn('LITE_LLM_API_KEY unset - LiteLLM proxy auth may fail at inference time');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agentHandler.start();\n} catch (e) {\n  if (/LiteLLM API base path and key must be provided/.test(e.message)) {\n    return respondConfigError('litellm', ['LITE_LLM_BASE_PATH', 'LITE_LLM_API_KEY']);\n  }\n  throw e;\n}","preventionTips":["The error text mentions a key but the code only validates the base path - set BOTH to avoid a follow-up auth error.","Confirm the LiteLLM proxy is running and reachable before configuring the provider.","Restart AnythingLLM after .env edits.","Use the docker network address when the proxy runs in another container."],"tags":["agents","llm-provider","litellm","proxy","environment-variables","config"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}