{"record":{"id":"c5656baf6e995de2","repo":"Mintplex-Labs/anything-llm","slug":"omlx-must-have-a-valid-model-set-c5656b","errorCode":null,"errorMessage":"OMLX must have a valid model set.","messagePattern":"OMLX must have a valid model set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/agents/aibitat/providers/omlx.js","lineNumber":24,"sourceCode":"const { RetryError } = require(\"../error.js\");\nconst { parseOMLXBasePath } = require(\"../../../AiProviders/omlx/index.js\");\n\n/**\n * The agent provider for OMLX.\n * OMLX is OpenAI-compatible and supports native tool calling, falling back\n * to the UnTooled prompt-based approach when disabled via env.\n */\nclass OMLXProvider extends InheritMultiple([Provider, UnTooled]) {\n  model;\n\n  /**\n   * @param {{model?: string}} config\n   */\n  constructor(config = {}) {\n    super();\n    this.providerTag = \"omlx\";\n    const model = config?.model || process.env.OMLX_LLM_MODEL_PREF;\n    if (!model) throw new Error(\"OMLX must have a valid model set.\");\n\n    const client = new OpenAI({\n      baseURL: parseOMLXBasePath(process.env.OMLX_LLM_BASE_PATH),\n      apiKey: process.env.OMLX_LLM_API_KEY || null,\n    });\n\n    this._client = client;\n    this.model = model;\n    this.verbose = true;\n  }\n\n  get client() {\n    return this._client;\n  }\n\n  get supportsAgentStreaming() {\n    return true;\n  }","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/agents/aibitat/providers/omlx.js#L6-L42","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n# OMLX_LLM_MODEL_PREF unset -> constructor throws\nOMLX_LLM_BASE_PATH=https://api.omlx.ml/v1\n\n# after\nOMLX_LLM_MODEL_PREF=meta-llama/Llama-3.1-8B-Instruct\nOMLX_LLM_BASE_PATH=https://api.omlx.ml/v1\nOMLX_LLM_API_KEY=<key>","handlingStrategy":"validation","validationCode":"// Guard before construction\nconst model = agentConfig?.model || process.env.OMLX_LLM_MODEL_PREF;\nif (!model) throw new Error(\"Set OMLX_LLM_MODEL_PREF or pass { model } before using the OMLX agent\");\nconst provider = new OMLXProvider({ model });","typeGuard":"const hasOmlxModel = (config) => Boolean(config?.model || process.env.OMLX_LLM_MODEL_PREF);","tryCatchPattern":"try {\n  provider = new OMLXProvider(config);\n} catch (error) {\n  if (/valid model set/i.test(error.message)) {\n    return respond(\"Set OMLX_LLM_MODEL_PREF to a model your OMLX endpoint serves, then retry.\");\n  }\n  throw error;\n}","preventionTips":["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"],"tags":["configuration","omlx","constructor","missing-model","env-var"],"backgroundTag":"missing-model-configuration","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}