Mintplex-Labs/anything-llm · critical · Error
OMLX must have a valid model set.
Error message
OMLX must have a valid model set.
What it means
OMLXProvider's constructor throws synchronously 'OMLX must have a valid model set.' when neither config.model nor process.env.OMLX_LLM_MODEL_PREF resolves to a truthy value. The OpenAI-compatible client for the OMLX (OpenMLX) service is constructed on the next lines and requires a concrete model for every call, so this is a fail-fast configuration guard at instantiation time — no network request has happened when you see it.
Solutions
- Set OMLX_LLM_MODEL_PREF to a valid OMLX model id in the server environment and restart
- Or pass the model explicitly: new OMLXProvider({ model: "..." }) / choose the model in the agent provider settings
- Verify OMLX_LLM_BASE_PATH and OMLX_LLM_API_KEY are also set so the provider works once constructed
Example fix
# before # OMLX_LLM_MODEL_PREF unset -> constructor throws OMLX_LLM_BASE_PATH=https://api.omlx.ml/v1 # after OMLX_LLM_MODEL_PREF=meta-llama/Llama-3.1-8B-Instruct OMLX_LLM_BASE_PATH=https://api.omlx.ml/v1 OMLX_LLM_API_KEY=<key>
Defensive patterns
Strategy: validation
Validate before calling
// Guard before construction
const model = agentConfig?.model || process.env.OMLX_LLM_MODEL_PREF;
if (!model) throw new Error("Set OMLX_LLM_MODEL_PREF or pass { model } before using the OMLX agent");
const provider = new OMLXProvider({ model }); Type guard
const hasOmlxModel = (config) => Boolean(config?.model || process.env.OMLX_LLM_MODEL_PREF);
Try / catch
try {
provider = new OMLXProvider(config);
} catch (error) {
if (/valid model set/i.test(error.message)) {
return respond("Set OMLX_LLM_MODEL_PREF to a model your OMLX endpoint serves, then retry.");
}
throw error;
} Prevention
- Pass { model } explicitly from agent settings; don't depend on the env fallback
- Add a boot-time assertion for OMLX_LLM_MODEL_PREF when OMLX is the configured provider
- Set OMLX_LLM_BASE_PATH and OMLX_LLM_API_KEY at the same time so the provider is usable once constructed
When it happens
Trigger: new OMLXProvider() (or with model unset) while OMLX_LLM_MODEL_PREF is missing/empty in the environment — typically during agent initialization before the first chat turn.
Common situations: OMLX provider selected in settings but the model env never populated; hand-edited .env dropped the variable; deployment platform secrets not injected into the container; workspace agent saved without a model and no global default.
Related errors
- LMStudio must have a valid model set.
- GenericOpenAI must have a valid base path to use for the…
- LiteLLM must have a valid base path to use for the api.
- No embedding base path was set.
- No embedding base path was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/c5656baf6e995de2.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/agents/aibitat/providers/omlx.js:24
const { RetryError } = require("../error.js");
const { parseOMLXBasePath } = require("../../../AiProviders/omlx/index.js");
/**
* The agent provider for OMLX.
* OMLX is OpenAI-compatible and supports native tool calling, falling back
* to the UnTooled prompt-based approach when disabled via env.
*/
class OMLXProvider extends InheritMultiple([Provider, UnTooled]) {
model;
/**
* @param {{model?: string}} config
*/
constructor(config = {}) {
super();
this.providerTag = "omlx";
const model = config?.model || process.env.OMLX_LLM_MODEL_PREF;
if (!model) throw new Error("OMLX must have a valid model set.");
const client = new OpenAI({
baseURL: parseOMLXBasePath(process.env.OMLX_LLM_BASE_PATH),
apiKey: process.env.OMLX_LLM_API_KEY || null,
});
this._client = client;
this.model = model;
this.verbose = true;
}
get client() {
return this._client;
}
get supportsAgentStreaming() {
return true;
}View on GitHub (pinned to 3aec848f28)