Mintplex-Labs/anything-llm · error · Error
Docker Model Runner chat: ${this.model} is not valid or defi
Error message
Docker Model Runner chat: ${this.model} is not valid or defined model for chat completion! What it means
Thrown by getChatCompletion when this.model is falsy. Unlike other providers that call isValidChatCompletionModel against a live API or cache, Docker Model Runner simply checks truthiness — the constructor already enforces a model, so this guard fires only if this.model was cleared or never set after construction bypass. The check does not validate that the model is actually loaded in the runner.
Source
Thrown at server/utils/AiProviders/dockerModelRunner/index.js:150
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistory, this.#generateContent),
{
role: "user",
content: this.#generateContent({ userPrompt, attachments }),
},
];
}
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!this.model)
throw new Error(
`Docker Model Runner chat: ${this.model} is not valid or defined model for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.dmr.chat.completions.create({
model: this.model,
messages,
temperature,
})
);
if (
!result.output.hasOwnProperty("choices") ||
result.output.choices.length === 0
)
return null;
return {View on GitHub (pinned to 526360e320)
Solutions
- Ensure DOCKER_MODEL_RUNNER_LLM_MODEL_PREF or the modelPreference argument was set at construction time (the constructor already guards this).
- Verify this.model was not overwritten to a falsy value between construction and the getChatCompletion call.
- If constructing programmatically, always pass a model id.
Defensive patterns
Strategy: type-guard
Validate before calling
if (!llm.model || typeof llm.model !== 'string')
throw new Error('DockerModelRunnerLLM.model is not set — pass a model id at construction.'); Type guard
function hasDmrModel(instance) {
return typeof instance?.model === 'string' && instance.model.trim().length > 0;
} Try / catch
try {
return await dmr.getChatCompletion(messages, { temperature });
} catch (e) {
if (/is not valid or defined model/i.test(e.message))
throw new Error('Docker Model Runner has no model set — re-instantiate with DOCKER_MODEL_RUNNER_LLM_MODEL_PREF.');
throw e;
} Prevention
- Always pass a model id at construction; do not clear this.model afterward.
- If using a factory, assert this.model is a non-empty string before calling getChatCompletion.
When it happens
Trigger: this.model is null/undefined/empty at call time; the constructor was bypassed or the model property was overwritten to a falsy value after instantiation; a subclass or test mock set this.model to undefined.
Common situations: Programmatic usage that nulls this.model after construction; test mocks that skip the constructor; edge case where modelPreference and env var are both empty but construction somehow proceeded.
Related errors
- CometAPI chat: ${this.model} is not valid for chat completio
- DeepSeek chat: ${this.model} is not valid for chat completio
- No Docker Model Runner API Base Path was set.
- No Docker Model Runner Model Pref was set.
- FireworksAI chat: ${this.model} is not valid for chat comple
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/1012832aefbedc1d.
Report an issue: GitHub.