Mintplex-Labs/anything-llm · error · Error
No Embedding Model preference defined.
Error message
No Embedding Model preference defined.
What it means
Thrown at the start of embedChunks when this.model is falsy. this.model is set to process.env.EMBEDDING_MODEL_PREF in the constructor, which the code comments explicitly note cannot be defaulted because Azure uses deployment names rather than model names. Unlike the key/endpoint checks, this guard is deferred to embed time, not construction.
Source
Thrown at server/utils/EmbeddingEngines/azureOpenAi/index.js:44
this.maxConcurrentChunks = 16;
// https://learn.microsoft.com/en-us/answers/questions/1188074/text-embedding-ada-002-token-context-length
this.embeddingMaxChunkLength = 2048;
}
log(text, ...args) {
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}
async embedTextInput(textInput) {
const result = await this.embedChunks(
Array.isArray(textInput) ? textInput : [textInput]
);
return result?.[0] || [];
}
async embedChunks(textChunks = []) {
if (!this.model) throw new Error("No Embedding Model preference defined.");
this.log(`Embedding ${textChunks.length} chunks...`);
// Because there is a limit on how many chunks can be sent at once to Azure OpenAI
// we concurrently execute each max batch of text chunks possible.
// Refer to constructor maxConcurrentChunks for more info.
const embeddingRequests = [];
let chunksProcessed = 0;
for (const chunk of toChunks(textChunks, this.maxConcurrentChunks)) {
embeddingRequests.push(
new Promise((resolve) => {
this.openai.embeddings
.create({
model: this.model,
input: chunk,
})
.then((res) => {
chunksProcessed += chunk.length;
reportEmbeddingProgress(chunksProcessed, textChunks.length);View on GitHub (pinned to 526360e320)
Solutions
- Set EMBEDDING_MODEL_PREF to the Azure deployment name (not the underlying model name) used for embeddings.
- Verify the deployment exists on the resource referenced by AZURE_OPENAI_ENDPOINT.
- Check the var at startup since the constructor does not throw for a missing model preference — only embedChunks does.
- Restart the process after setting it.
Example fix
// before
this.model = process.env.EMBEDDING_MODEL_PREF; // undefined -> throws later in embedChunks
// after (fail fast at construction)
constructor() {
// ...existing checks...
this.model = process.env.EMBEDDING_MODEL_PREF;
if (!this.model) throw new Error("No Embedding Model preference defined.");
} Defensive patterns
Strategy: validation
Validate before calling
function assertAzureEmbedModel() {
if (!process.env.EMBEDDING_MODEL_PREF) {
throw new Error('EMBEDDING_MODEL_PREF (Azure deployment name) is required for embeddings');
}
}
assertAzureEmbedModel(); Try / catch
try {
await embedder.embedChunks(chunks);
} catch (e) {
if (/No Embedding Model preference/i.test(e.message)) { /* set EMBEDDING_MODEL_PREF */ }
throw e;
} Prevention
- Set EMBEDDING_MODEL_PREF to the Azure deployment name (case-sensitive), not the base model name.
- Fail fast at construction since embedChunks defers this check.
- Verify the deployment exists on the resource before embedding.
When it happens
Trigger: Calling embedChunks/embedTextInput when EMBEDDING_MODEL_PREF was never set; the var was set for the LLM path but not for the Azure embedding engine; deployment name left blank in the embedding config UI.
Common situations: Mixing up the model-preference var for chat vs embeddings; selecting Azure OpenAI embeddings without naming the deployment; renaming a deployment in Azure but not updating EMBEDDING_MODEL_PREF.
Related errors
- No Azure API endpoint was set.
- No Azure API key was set.
- Azure OpenAI Failed to embed: ${error}
- Azure OpenAI API endpoint and key must be provided to use ag
- No base URL was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/51801a99966a3531.
Report an issue: GitHub.