Mintplex-Labs/anything-llm · error
No Ollama image generation base path was set.
Error message
No Ollama image generation base path was set.
What it means
The OllamaImageGenerator constructor throws immediately when IMAGE_GEN_OLLAMA_BASE_PATH is unset or empty. The value is normalized (trailing slashes stripped) and suffixed with /v1 to build the OpenAI-compatible client base URL — Ollama serves experimental image generation through that endpoint. Fails fast at instantiation.
Solutions
- Set IMAGE_GEN_OLLAMA_BASE_PATH to the Ollama server root, e.g. http://localhost:11434 (the code appends /v1 itself).
- From docker, use http://host.docker.internal:11434 instead of localhost.
- Restart the server / recreate the container after saving.
- Confirm your Ollama build actually exposes the OpenAI-compatible /v1/images endpoint (experimental, macOS).
Example fix
# .env — before IMAGE_GEN_ENGINE=ollama # .env — after IMAGE_GEN_ENGINE=ollama IMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.IMAGE_GEN_OLLAMA_BASE_PATH) {
throw new Error(
"Ollama image engine selected but IMAGE_GEN_OLLAMA_BASE_PATH is missing."
);
}
const { OllamaImageGenerator } = require("server/utils/ImageGenerators/ollama");
const generator = new OllamaImageGenerator(); Type guard
function isOllamaImageConfigValid(env = process.env) {
return (
typeof env.IMAGE_GEN_OLLAMA_BASE_PATH === "string" &&
env.IMAGE_GEN_OLLAMA_BASE_PATH.length > 0
);
} Try / catch
try {
new OllamaImageGenerator();
} catch (err) {
if (err.message.includes("Ollama image generation base path")) {
// surface a settings error for IMAGE_GEN_OLLAMA_BASE_PATH
}
} Prevention
- Point the base path at the Ollama root (the code appends /v1 itself).
- In docker, use host.docker.internal rather than localhost for the host's Ollama.
- Confirm the Ollama build exposes the experimental /v1 images endpoint before selecting the engine.
When it happens
Trigger: Selecting Ollama as the image engine without setting IMAGE_GEN_OLLAMA_BASE_PATH; docker deployments where localhost would point at the container rather than the host; .env updated without a restart; typo in the variable name.
Common situations: Trying Ollama's experimental image generation (macOS-only per the code comment) for the first time; reusing the chat OLLAMA basePath variable but not the image-specific one.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- No Ollama image generation model was set.
- No embedding model was set.
- No Lemonade image generation base path was set.
- No Lemonade image generation model was set.
- No OpenAI image generation API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18).
Data as JSON: /api/errors/84d165890e360444.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/ImageGenerators/ollama/index.js:6
const { BaseImageGenerator } = require("../base");
class OllamaImageGenerator extends BaseImageGenerator {
constructor() {
if (!process.env.IMAGE_GEN_OLLAMA_BASE_PATH)
throw new Error("No Ollama image generation base path was set.");
if (!process.env.IMAGE_GEN_MODEL_PREF)
throw new Error("No Ollama image generation model was set.");
const { OpenAI: OpenAIApi } = require("openai");
// Ollama serves image generation through its OpenAI-compatible `/v1`
// endpoint (experimental, macOS only).
const basePath = process.env.IMAGE_GEN_OLLAMA_BASE_PATH.replace(/\/+$/, "");
super({
client: new OpenAIApi({
baseURL: `${basePath}/v1`,
apiKey: process.env.IMAGE_GEN_OLLAMA_AUTH_TOKEN || "ollama",
}),
model: process.env.IMAGE_GEN_MODEL_PREF,
className: "OllamaImageGenerator",
});
}
/**
* Ollama's OpenAI-compatible image endpoint does not implement image editingView on GitHub (pinned to 20f6d3546c)