Mintplex-Labs/anything-llm · error · Error
Ollama::getChatCompletion failed to communicate with Ollama.
Error message
Ollama::getChatCompletion failed to communicate with Ollama. ${this.#errorHandler(e).message} What it means
Catch wrapper in OllamaAILLM.getChatCompletion: the Ollama SDK chat request failed (instance unreachable, connection refused, or API error) and the #errorHandler-normalized message is rethrown so the failure names both the method and the underlying cause.
Solutions
- Ensure Ollama is running and reachable.
- Verify the model is pulled (ollama pull <model>).
- Review the handled error message for details.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown when a chat completion request to Ollama fails.
Common situations: Ollama down, model missing, or request error.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/b240b4e2cc51fe25.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/ollama/index.js:298
num_ctx: this.promptWindowLimit(),
},
})
.then((res) => {
let content = res.message.content;
if (res.message.thinking)
content = `<think>${res.message.thinking}</think>${content}`;
return {
content,
usage: {
prompt_tokens: res.prompt_eval_count,
completion_tokens: res.eval_count,
total_tokens: res.prompt_eval_count + res.eval_count,
duration: res.eval_duration / 1e9,
},
};
})
.catch((e) => {
throw new Error(
`Ollama::getChatCompletion failed to communicate with Ollama. ${this.#errorHandler(e).message}`
);
})
);
if (!result.output.content || !result.output.content.length)
throw new Error(`Ollama::getChatCompletion text response was empty.`);
return {
textResponse: result.output.content,
metrics: {
prompt_tokens: result.output.usage.prompt_tokens,
completion_tokens: result.output.usage.completion_tokens,
total_tokens: result.output.usage.total_tokens,
outputTps:
result.output.usage.completion_tokens / result.output.usage.duration,
duration: result.output.usage.duration,
model: this.model,View on GitHub (pinned to 3aec848f28)