lmstudio-js: The Official TypeScript SDK for Local LLMs
LM Studio TypeScript SDK
At a glance
- What is it?
- lmstudio-js is LM Studio's official JavaScript and TypeScript client SDK, letting Node.js and browser applications load local models, run completions, define tool-calling agents, and generate embeddings without sending data to a remote API.
- Who is it for?
- lmstudio-js is the right choice for TypeScript and JavaScript developers who want to call local language models with a typed API and need features like model load/unload control, speculative decoding configuration, and on-device agents. It is not suitable for production deployments that require horizontal scaling or load balancing across machines, since it targets a single LM Studio desktop instance.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 1, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What Problem lmstudio-js Solves and Who It Is For
TypeScript and JavaScript developers who want to run language models locally have traditionally reached for the `openai` npm package and pointed it at a local OpenAI-compatible server. That approach works for simple chat completions, but the openai SDK was built around OpenAI's hosted service and has no concept of managing which models are loaded in RAM, configuring GPU offload settings, adjusting context length at load time, or querying a model's on-disk size. Those operations require a different interface.
lmstudio-js is LM Studio's answer to that gap. It is the official JavaScript/TypeScript client SDK for LM Studio, the desktop application for running local language models. The SDK targets JavaScript developers building applications that must run on a user's own machine, whether in a Node.js server process, an Electron app, or directly in the browser. The README explicitly lists support for both browser and any Node-compatible environment.
The project sits on npm as `@lmstudio/sdk` and is written in TypeScript, giving consuming projects full type coverage with no separate type package required.
How the SDK Communicates with LM Studio at Runtime
lmstudio-js acts as a client that connects to a running LM Studio instance. The entry point is `LMStudioClient`, which establishes that connection. From the client you obtain a handle to a specific model by name, and then call methods on that handle to run inference.
The SDK distinguishes between the model loading lifecycle and the inference lifecycle. You can programmatically load a model into memory, run predictions against it, and unload it when finished. This is relevant for applications that need to switch between models based on task type without requiring the user to do it manually in the LM Studio UI.
The architecture follows a request-response pattern for completions but the README also describes tool-calling agents. In agent mode, you define functions as tools using a standard interface, and the model decides when and how to invoke them. The README describes these as agents that run completely locally, meaning the function execution happens in your JavaScript process, and the model only sees the function definitions and their returned results.
For embeddings, the SDK exposes a separate API path. The README lists text embeddings as a supported capability, though it refers to the official documentation at lmstudio.ai/docs/typescript for the detailed interface.
Installing lmstudio-js and Running a First Request
The SDK installs through npm:
npm install @lmstudio/sdk --saveWith the package installed and LM Studio running locally, the README's quick example demonstrates the core pattern. You import `LMStudioClient`, instantiate it with no arguments (which connects to LM Studio's default local port), load a model by name, and call `respond`:
import { LMStudioClient } from "@lmstudio/sdk";
const client = new LMStudioClient();
const model = await client.llm.model("llama-3.2-1b-instruct");
const result = await model.respond("What is the meaning of life?");
console.info(result.content);This example assumes the model name matches exactly what LM Studio has available. If the model is not already loaded, the call loads it first. The string `"llama-3.2-1b-instruct"` in the example must correspond to a model identifier that LM Studio recognises on your machine.
To contribute to or build the SDK itself from source, the README gives these steps:
git clone https://github.com/lmstudio-ai/lmstudio-js.git --recursive
cd lmstudio-js
npm install
npm run buildThe `--recursive` flag matters because the repository uses git submodules. The root `package.json` uses Turborepo to orchestrate the multi-package workspace; running `npm run build` delegates to `turbo run build` after a code generation step.
Tool-Calling Agents That Stay On-Device
One of the primary motivations the README gives for using lmstudio-js over the openai SDK is support for tool-calling agents that run entirely locally. In LM Studio's agent mode, you define JavaScript functions as tools. The model receives those function definitions as part of its context and decides when to call them. The SDK routes those calls back to your JavaScript code, executes the function, and returns the result to the model.
This matters in two ways. First, there is no network hop to an external service; the inference, the function calls, and the return values all happen within the local process boundary. Second, the SDK's agent API is designed specifically for this local execution model, whereas the openai SDK's function calling support assumes a stateless request-response pattern against a remote endpoint.
The README does not document the full agent API inline, directing readers to the TypeScript documentation at lmstudio.ai/docs/typescript/agent/act. The available documentation covers parallel tool calls and serial tool calls, suggesting the SDK can tell the model to invoke multiple tools in a single turn or sequentially based on dependency.
Capabilities the openai SDK Does Not Provide
The README dedicates a section to explaining why a developer would choose lmstudio-js over the openai npm package. The listed capabilities that the openai SDK lacks in a local context include:
Managing loading and unloading models from memory. With lmstudio-js you can call load and unload programmatically. The openai SDK has no equivalent because hosted APIs manage model availability server-side.
Configuring load parameters such as context length and GPU offload settings. When a model loads in LM Studio, settings like context window size affect both memory consumption and inference speed. lmstudio-js exposes these as configuration options at load time.
Speculative decoding. The README lists this as a capability that the openai SDK does not expose, though it does not describe the configuration interface inline.
Querying model information such as context length and on-disk size. A local deployment often involves choosing between models based on hardware constraints, and lmstudio-js can surface that metadata at runtime.
The README also notes that the openai SDK is automatically generated from an OpenAPI spec, while lmstudio-js is hand-crafted with TypeScript ergonomics in mind.
Limitations and Maintenance
lmstudio-js requires LM Studio to be running locally. The SDK is a client, not a standalone inference engine; it has no ability to load or run models itself. This means the SDK is not suitable for server-side deployments where users do not have LM Studio installed, and it does not work against generic OpenAI-compatible endpoints.
The README warns that major version changes may introduce breaking changes, without providing a migration guide inline. Because the project has no GitHub releases, version information lives in the npm package and the repository's changelog. Teams that adopt the SDK for production tooling should pin to a minor version range and review the changelog before upgrading across a major boundary.
The repository has no GitHub releases listed, though the package is published to npm. The last push to the repository was on 2026-09-25, and the SDK is licensed under MIT. Developers who need Python bindings instead of TypeScript can use the separate lmstudio-python repository, which the README links directly.
Editorial conclusion
lmstudio-js is the right choice for TypeScript and JavaScript developers who want to call local language models with a typed API and need features like model load/unload control, speculative decoding configuration, and on-device agents. It is not suitable for production deployments that require horizontal scaling or load balancing across machines, since it targets a single LM Studio desktop instance. Before committing, verify that LM Studio supports the model architecture you plan to use, and check whether major version upgrades apply to your code path, since the README states that major version changes may introduce breaking changes.
Frequently asked questions
How does LM Studio work?
LM Studio is a desktop application that loads language models into local memory and exposes them through a runtime that client SDKs like lmstudio-js connect to. The lmstudio-js SDK communicates with that local runtime to send prompts and receive responses without any data leaving the machine.
What language is LM Studio written in?
The lmstudio-js SDK is written in TypeScript. The README describes it as LM Studio's official JavaScript client SDK, written in TypeScript, and the npm package at @lmstudio/sdk ships with TypeScript types included.
Does lmstudio-js work in the browser?
Yes. The README states that lmstudio-js supports both browser and any Node-compatible environment. The SDK connects to a locally running LM Studio instance, so the browser still requires LM Studio to be available on the same machine.
Can lmstudio-js build tool-calling agents without a cloud API?
Yes. The README describes support for defining JavaScript functions as tools and turning LLMs into autonomous agents that run completely locally. The model receives the function definitions, decides when to call them, and the results are returned to the model without leaving the local environment.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/lmstudio-ai-lmstudio-js)