Mintplex-Labs/anything-llm · critical · Error
No embedding model was set.
Error message
No embedding model was set.
What it means
Thrown by the LocalAiEmbedder constructor (line 12) when process.env.EMBEDDING_MODEL_PREF is falsy, right after the base-path guard. The model name is sent as the `model` field on every /embeddings request; LocalAI needs it to pick the loaded model. The guard prevents queuing requests that LocalAI would reject.
Source
Thrown at server/utils/EmbeddingEngines/localAi/index.js:12
const {
toChunks,
maximumChunkLength,
reportEmbeddingProgress,
} = require("../../helpers");
class LocalAiEmbedder {
constructor() {
if (!process.env.EMBEDDING_BASE_PATH)
throw new Error("No embedding base path was set.");
if (!process.env.EMBEDDING_MODEL_PREF)
throw new Error("No embedding model was set.");
this.className = "LocalAiEmbedder";
const { OpenAI: OpenAIApi } = require("openai");
this.model = process.env.EMBEDDING_MODEL_PREF;
this.openai = new OpenAIApi({
baseURL: process.env.EMBEDDING_BASE_PATH,
apiKey: process.env.LOCAL_AI_API_KEY ?? null,
});
// Limit of how many strings we can process in a single pass to stay with resource or network limits
this.maxConcurrentChunks = 50;
this.embeddingMaxChunkLength = maximumChunkLength();
this.log(
`Initialized with ${this.model} - Max Size: ${this.embeddingMaxChunkLength}` +
(this.outputDimensions
? ` - Output Dimensions: ${this.outputDimensions}`
: " Assuming default output dimensions")View on GitHub (pinned to 526360e320)
Solutions
- Set EMBEDDING_MODEL_PREF to the model id exactly as configured in LocalAI's models.yaml
- Confirm the model is actually loaded/available in LocalAI (check its /v1/models endpoint)
- Reload AnythingLLM env
Example fix
// before EMBEDDING_BASE_PATH=http://localhost:8080/v1 // EMBEDDING_MODEL_PREF unset // after EMBEDDING_BASE_PATH=http://localhost:8080/v1 EMBEDDING_MODEL_PREF=bge-small-en
Defensive patterns
Strategy: validation
Validate before calling
function hasEmbeddingModelPref(env = process.env) {
return typeof env.EMBEDDING_MODEL_PREF === 'string' &&
env.EMBEDDING_MODEL_PREF.trim().length > 0;
}
if (!hasEmbeddingModelPref()) {
throw new Error('Missing EMBEDDING_MODEL_PREF for LocalAI.');
} Type guard
function isNonEmptyModel(v) {
return typeof v === 'string' && v.trim().length > 0;
} Prevention
- Copy the model id exactly from LocalAI's models.yaml or /v1/models.
- Set base path and model together when switching to LocalAI.
- Reload env after editing .env.
When it happens
Trigger: Constructing `new LocalAiEmbedder()` with EMBEDDING_MODEL_PREF unset/empty. Fires at construction time before any embedding work, mirroring the LMStudio model guard.
Common situations: LocalAI model installed but EMBEDDING_MODEL_PREF not set to match; model name typo; switching engines cleared the previous model env; models.yaml in LocalAI uses a different id than what was typed.
Related errors
- No embedding base path was set.
- LiteLLM must have a valid base path to use for the api.
- No embedding base path was set.
- No embedding model was set.
- No Mistral API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/8141341434a9b824.
Report an issue: GitHub.