{"record":{"id":"2f0c688668eab324","repo":"Mintplex-Labs/anything-llm","slug":"localai-must-have-a-valid-base-path-to-use-for-the","errorCode":null,"errorMessage":"LocalAI must have a valid base path to use for the api.","messagePattern":"LocalAI must have a valid base path to use for the api\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":168,"sourceCode":"      case \"togetherai\":\n        if (!process.env.TOGETHER_AI_API_KEY)\n          throw new Error(\"TogetherAI API key must be provided to use agents.\");\n        break;\n      case \"azure\":\n        if (!process.env.AZURE_OPENAI_ENDPOINT || !process.env.AZURE_OPENAI_KEY)\n          throw new Error(\n            \"Azure OpenAI API endpoint and key must be provided to use agents.\"\n          );\n        break;\n      case \"koboldcpp\":\n        if (!process.env.KOBOLD_CPP_BASE_PATH)\n          throw new Error(\n            \"KoboldCPP must have a valid base path to use for the api.\"\n          );\n        break;\n      case \"localai\":\n        if (!process.env.LOCAL_AI_BASE_PATH)\n          throw new Error(\n            \"LocalAI must have a valid base path to use for the api.\"\n          );\n        break;\n      case \"openrouter\":\n        if (!process.env.OPENROUTER_API_KEY)\n          throw new Error(\"OpenRouter API key must be provided to use agents.\");\n        break;\n      case \"mistral\":\n        if (!process.env.MISTRAL_API_KEY)\n          throw new Error(\"Mistral API key must be provided to use agents.\");\n        break;\n      case \"generic-openai\":\n        if (!process.env.GENERIC_OPEN_AI_BASE_PATH)\n          throw new Error(\"API base path must be provided to use agents.\");\n        break;\n      case \"perplexity\":\n        if (!process.env.PERPLEXITY_API_KEY)\n          throw new Error(\"Perplexity API key must be provided to use agents.\");","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L150-L186","documentation":"Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:167) when the workspace agent provider is 'localai' but LOCAL_AI_BASE_PATH is unset/empty. LocalAI is a self-hosted OpenAI-drop-in replacement, so only its base URL is required and validated. The guard prevents the agent from running with no target endpoint.","triggerScenarios":"An agent invocation runs with workspace.agentProvider === 'localai' while LOCAL_AI_BASE_PATH is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.","commonSituations":"LocalAI picked in System > LLM Preference on a fresh install with no URL set; .env edited but server not restarted; base path left pointing at http://localhost:8080 while LocalAI actually runs in a separate Docker network where 'localhost' is the wrong host.","solutions":["Set LOCAL_AI_BASE_PATH in .env to the LocalAI server URL (e.g. http://127.0.0.1:8080/v1).","Restart AnythingLLM to reload process.env.","Verify reachability with curl <base path>/v1/models from the AnythingLLM host.","When LocalAI runs in another container, use the docker network hostname/IP instead of 127.0.0.1."],"exampleFix":"// before (.env)\n// LOCAL_AI_BASE_PATH=\n\n// after (.env)\nLOCAL_AI_BASE_PATH=http://127.0.0.1:8080/v1","handlingStrategy":"validation","validationCode":"const base = process.env.LOCAL_AI_BASE_PATH;\nif (!base) {\n  throw new Error(\n    'Cannot start LocalAI agent: set LOCAL_AI_BASE_PATH (e.g. http://127.0.0.1:8080/v1) in .env.'\n  );\n}\ntry { new URL(base); } catch { throw new Error('LOCAL_AI_BASE_PATH is not a valid URL'); }","typeGuard":null,"tryCatchPattern":"try {\n  await agentHandler.start();\n} catch (e) {\n  if (/LocalAI must have a valid base path/.test(e.message)) {\n    return respondConfigError('localai', ['LOCAL_AI_BASE_PATH']);\n  }\n  throw e;\n}","preventionTips":["Verify the LocalAI server answers /v1/models from the AnythingLLM host before configuring it.","Use the docker network hostname, not localhost, when LocalAI runs in another container.","Restart AnythingLLM after each .env change.","Add a startup self-check that lists all configured providers and their required env vars."],"tags":["agents","llm-provider","localai","local-llm","environment-variables","config"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}