{"record":{"id":"63f66f0070ee79f0","repo":"Mintplex-Labs/anything-llm","slug":"lmstudio-getmodelinfo-res-statustext","errorCode":null,"errorMessage":"LMStudio:getModelInfo - ${res.statusText}","messagePattern":"LMStudio:getModelInfo - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/lmStudio/index.js","lineNumber":311,"sourceCode":"   * @param {string} model - The model key to look up\n   * @returns {Promise<object>} The model info, or an empty object if not found.\n   */\n  static async #getModelInfo(model) {\n    const endpoint = new URL(\n      parseLMStudioBasePath(process.env.LMSTUDIO_BASE_PATH, \"v1\")\n    );\n    const apiKey = process.env.LMSTUDIO_AUTH_TOKEN ?? null;\n    endpoint.pathname += \"/models\";\n    return (\n      (await fetch(endpoint.toString(), {\n        headers: {\n          \"Content-Type\": \"application/json\",\n          ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),\n        },\n      })\n        .then((res) => {\n          if (!res.ok)\n            throw new Error(`LMStudio:getModelInfo - ${res.statusText}`);\n          return res.json();\n        })\n        .then(({ models = [] }) => models.find((m) => m.key === model))) || {}\n    );\n  }\n\n  /**\n   * Whether the model currently has an instance loaded into memory.\n   * Resolves true on error so a dead server fails on the real completion instead.\n   * @param {string} model - The model key to check\n   * @returns {Promise<boolean>}\n   */\n  static async isModelLoaded(model) {\n    return await LMStudioLLM.#getModelInfo(model)\n      .then((info) => (info.loaded_instances ?? []).length > 0)\n      .catch(() => true);\n  }\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/f92433b4ea0598492a1e6645ea22addbb4dd1287/server/utils/AiProviders/lmStudio/index.js#L293-L329","documentation":"LMStudio's private #getModelInfo queries the LMStudio /v1/models endpoint and throws when the HTTP response is not ok, surfacing res.statusText. It means LM Studio's local server responded with an error status, so model metadata (context length, etc.) could not be fetched.","triggerScenarios":"Any call to getModelInfo where the LM Studio server returns 4xx/5xx — server unreachable via a proxy that returns an error page, wrong port, LM Studio's server not started, or the model key not loaded while the server returns an error status.","commonSituations":"LM Studio local server not running on the configured port (default 1234); base URL pointing at the wrong host; LM Studio server stopped after model unload; firewall/proxy intercepting localhost requests.","solutions":["Start LM Studio's local server (Developer tab -> Start Server) and confirm the port matches the configured base URL.","Curl http://localhost:1234/v1/models to confirm the endpoint responds 200.","Check for typos in the LM Studio base URL in provider settings.","Update LM Studio if the /v1/models route is missing in your version.","Note statusText can be empty for some responses; check LM Studio's server logs for details."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const res = await fetch(`${lmStudioBaseURL}/v1/models`);\nif (!res.ok) throw new Error(`LM Studio not ready: ${res.status} ${res.statusText}`);","typeGuard":"function isModelInfo(info) {\n  return info && typeof info === 'object' && 'key' in info;\n}","tryCatchPattern":"try {\n  const info = await lmStudioProvider.getModelInfo();\n} catch (e) {\n  if (/LMStudio:getModelInfo/.test(e.message)) {\n    // LM Studio server returned non-ok: check server is running on the right port\n    console.warn('LM Studio unavailable, falling back to defaults');\n  } else { throw e; }\n}","preventionTips":["Start LM Studio's local server before starting the app.","Confirm the base URL port (default 1234) matches LM Studio's server settings.","Monitor /v1/models as a readiness probe.","Treat model info as optional and degrade gracefully when unavailable."],"tags":["network","http","llm","local-server"],"backgroundTag":"http-error-response","analyzedSha":"f92433b4ea0598492a1e6645ea22addbb4dd1287","analyzedAt":"2026-09-22T02:13:38.154Z","contentChangedAt":"2026-09-22T02:13:38.154Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}