Mintplex-Labs/anything-llm · error

LMStudio:getModelInfo

Error message

LMStudio:getModelInfo - ${res.statusText}

What it means

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.

Solutions

  1. Start LM Studio's local server (Developer tab -> Start Server) and confirm the port matches the configured base URL.
  2. Curl http://localhost:1234/v1/models to confirm the endpoint responds 200.
  3. Check for typos in the LM Studio base URL in provider settings.
  4. Update LM Studio if the /v1/models route is missing in your version.
  5. Note statusText can be empty for some responses; check LM Studio's server logs for details.
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`${lmStudioBaseURL}/v1/models`);
if (!res.ok) throw new Error(`LM Studio not ready: ${res.status} ${res.statusText}`);

Type guard

function isModelInfo(info) {
  return info && typeof info === 'object' && 'key' in info;
}

Try / catch

try {
  const info = await lmStudioProvider.getModelInfo();
} catch (e) {
  if (/LMStudio:getModelInfo/.test(e.message)) {
    // LM Studio server returned non-ok: check server is running on the right port
    console.warn('LM Studio unavailable, falling back to defaults');
  } else { throw e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@f92433b4ea (2026-09-22). Data as JSON: /api/errors/63f66f0070ee79f0. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/AiProviders/lmStudio/index.js:311

   * @param {string} model - The model key to look up
   * @returns {Promise<object>} The model info, or an empty object if not found.
   */
  static async #getModelInfo(model) {
    const endpoint = new URL(
      parseLMStudioBasePath(process.env.LMSTUDIO_BASE_PATH, "v1")
    );
    const apiKey = process.env.LMSTUDIO_AUTH_TOKEN ?? null;
    endpoint.pathname += "/models";
    return (
      (await fetch(endpoint.toString(), {
        headers: {
          "Content-Type": "application/json",
          ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
        },
      })
        .then((res) => {
          if (!res.ok)
            throw new Error(`LMStudio:getModelInfo - ${res.statusText}`);
          return res.json();
        })
        .then(({ models = [] }) => models.find((m) => m.key === model))) || {}
    );
  }

  /**
   * Whether the model currently has an instance loaded into memory.
   * Resolves true on error so a dead server fails on the real completion instead.
   * @param {string} model - The model key to check
   * @returns {Promise<boolean>}
   */
  static async isModelLoaded(model) {
    return await LMStudioLLM.#getModelInfo(model)
      .then((info) => (info.loaded_instances ?? []).length > 0)
      .catch(() => true);
  }

View on GitHub (pinned to f92433b4ea)