Local model applications need a client library that can communicate with the model service. The LM Studio TypeScript SDK is the official npm package for adding that connection to a Node.js project and reading its local model state.

The package includes JavaScript modules and TypeScript declarations. An ES-module script can check the installation directly in Node.js, without a TypeScript compiler or a separate build configuration.

The SDK discovers LM Studio on the same computer by default. Its loaded-model list distinguishes models already in memory from files merely downloaded to disk, so a connection check does not need to generate text or load another model.

Steps to install the LM Studio TypeScript SDK:

  1. Install Node.js with npm on the computer running LM Studio.

    On Ubuntu, install Node.js and npm from the distribution repositories. Other platforms can use the official Node.js downloads. An existing Node.js installation with npm can be used directly.

  2. Start the local LM Studio daemon.
    $ lms daemon up

    The lms CLI comes with LM Studio. On a headless Linux machine, install llmster first. The SDK can connect to the daemon without starting the optional HTTP server.

  3. Create a directory for the SDK project.
    $ mkdir lmstudio-sdk-demo
  4. Enter the project directory.
    $ cd lmstudio-sdk-demo
  5. Initialize the npm project.
    $ npm init --yes

    This creates package.json with default project metadata. In an existing project, the directory-creation and initialization steps can be skipped.

  6. Install the official LM Studio SDK into the project.
    $ npm install @lmstudio/sdk

    The package is maintained by LM Studio and published on npm. Installation adds the dependency to package.json and records its resolved version in package-lock.json. No global installation or sudo is required.
    Related: LM Studio SDK project setup

    SDK 2.1.0 currently triggers an npm advisory for memory exhaustion in its Zod dependency. Do not apply npm audit fix –force blindly; its proposed downgrade to SDK 0.3.0 changes the SDK version and can break application code.

  7. Confirm that the project lists the installed SDK dependency. Example output:
    $ npm ls @lmstudio/sdk
    lmstudio-sdk-demo@1.0.0 /home/user/lmstudio-sdk-demo
    `-- @lmstudio/sdk@2.1.0

    The installed version and project path can differ.

  8. Create check-lmstudio.mjs in the project root using your text editor.
    check-lmstudio.mjs
    import { LMStudioClient } from "@lmstudio/sdk";
     
    const client = new LMStudioClient();
    const models = await client.llm.listLoaded();
    console.log(models.map(model => model.identifier));

    The .mjs extension makes this an ES module, allowing import and top-level await without changing package.json. LMStudioClient uses local discovery, and listLoaded() requests the loaded language-model inventory. On a local installation with the default authentication settings, no API token is required.

  9. Save check-lmstudio.mjs in the project directory.
  10. Run the script to confirm that the SDK imports and reaches LM Studio. Example output:
    $ node check-lmstudio.mjs
    [ 'local-chat' ]

    The identifiers depend on your loaded models. An empty [] is a successful response with no language models loaded; a connection or import error is a failure. For a nonempty list, download a language model and load it into LM Studio before rerunning the script. A missing model does not require reinstalling the SDK.
    Related: SDK loaded-model list reference

Share this guide