Documentation

Predicting with LLMs

Agentic Flows

Text Embedding

Tokenization

Manage Models

Model Info

API Reference

lmstudio-js (TypeScript 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 --save

For the source code and open source contribution, visit lmstudio.js on GitHub.

Features

Quick Example: Chat with a Llama Model

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);

Getting Local Models

The above code requires the Llama 3.2 1B. If you don't have the model, run the following command in the terminal to download it.

lms get llama-3.2-1b-instruct

Read more about lms get in LM Studio's CLI here.