Mintplex-Labs/anything-llm · error · Error
LiteLLM API base path and key must be provided to use agents
Error message
LiteLLM API base path and key must be provided to use agents.
What it means
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.
Source
Thrown at server/utils/agents/index.js:209
"TextWebGenUI API base path must be provided to use agents."
);
break;
case "bedrock":
// No validations since there are many possible authentication methods
break;
case "fireworksai":
if (!process.env.FIREWORKS_AI_LLM_API_KEY)
throw new Error(
"FireworksAI API Key must be provided to use agents."
);
break;
case "deepseek":
if (!process.env.DEEPSEEK_API_KEY)
throw new Error("DeepSeek API Key must be provided to use agents.");
break;
case "litellm":
if (!process.env.LITE_LLM_BASE_PATH)
throw new Error(
"LiteLLM API base path and key must be provided to use agents."
);
break;
case "apipie":
if (!process.env.APIPIE_LLM_API_KEY)
throw new Error("ApiPie API Key must be provided to use agents.");
break;
case "xai":
if (!process.env.XAI_LLM_API_KEY)
throw new Error("xAI API Key must be provided to use agents.");
break;
case "zai":
if (!process.env.ZAI_API_KEY)
throw new Error("Z.AI API Key must be provided to use agents.");
break;
case "novita":
if (!process.env.NOVITA_LLM_API_KEY)
throw new Error("Novita API Key must be provided to use agents.");View on GitHub (pinned to 526360e320)
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).
Example fix
// before (.env) // LITE_LLM_BASE_PATH= // LITE_LLM_API_KEY= // after (.env) LITE_LLM_BASE_PATH=http://127.0.0.1:4000/v1 LITE_LLM_API_KEY=sk-...proxy-master-key
Defensive patterns
Strategy: validation
Validate before calling
const base = process.env.LITE_LLM_BASE_PATH;
if (!base) {
throw new Error(
'Cannot start LiteLLM agent: set LITE_LLM_BASE_PATH (proxy URL, e.g. http://127.0.0.1:4000/v1) in .env.'
);
}
try { new URL(base); } catch { throw new Error('LITE_LLM_BASE_PATH is not a valid URL'); }
// The checkSetup guard only checks base path; set the proxy key too to avoid a later auth failure:
if (process.env.LITE_LLM_API_KEY == null) {
console.warn('LITE_LLM_API_KEY unset - LiteLLM proxy auth may fail at inference time');
} Try / catch
try {
await agentHandler.start();
} catch (e) {
if (/LiteLLM API base path and key must be provided/.test(e.message)) {
return respondConfigError('litellm', ['LITE_LLM_BASE_PATH', 'LITE_LLM_API_KEY']);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Azure OpenAI API endpoint and key must be provided to use ag
- KoboldCPP must have a valid base path to use for the api.
- LocalAI must have a valid base path to use for the api.
- OpenRouter API key must be provided to use agents.
- Mistral API key must be provided to use agents.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/47712370f7af0627.
Report an issue: GitHub.