lmstudio-js (TypeScript SDK)
Getting started with LM Studio's Typescript / JavaScript SDK
The SDK provides you a set of programmatic tools to interact with LLMs, embeddings models, and agentic flows.
Installing the SDK
lmstudio-js is available as an npm package. You can install it using npm, yarn, or pnpm.
npm install @lmstudio/sdk --saveFor the source code and open source contribution, visit lmstudio-js on GitHub.
Features
- Use LLMs to respond in chats or predict text completions
- Define functions as tools, and turn LLMs into autonomous agents that run completely locally
- Load, configure, and unload models from memory
- Supports for both browser and any Node-compatible environments
- Generate embeddings for text, and more!
Quick Example: Chat with a Llama Model
import { LMStudioClient } from "@lmstudio/sdk";
const client = new LMStudioClient();
const model = await client.llm.model("qwen/qwen3-4b-2507");
const result = await model.respond("What is the meaning of life?");
console.info(result.content);Getting Local Models
The above code requires the qwen3-4b-2507. If you don't have the model, run the following command in the terminal to download it.
lms get qwen/qwen3-4b-2507Read more about lms get in LM Studio's CLI here.