文档

使用大型语言模型进行预测

Agentic 流

文本嵌入

分词

管理模型

模型信息

API 参考

lmstudio-js (TypeScript SDK)

该 SDK 提供了一套编程工具,用于与大型语言模型、嵌入模型和 Agentic 流进行交互。

安装 SDK

lmstudio-js 可作为一个 npm 包使用。您可以使用 npm、yarn 或 pnpm 进行安装。

npm install @lmstudio/sdk --save

有关源代码和开源贡献,请访问 GitHub 上的 lmstudio.js

特性

快速示例:与 Llama 模型聊天

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

获取本地模型

以上代码需要 Llama 3.2 1B 模型。如果您没有该模型,请在终端中运行以下命令进行下载。

lms get llama-3.2-1b-instruct

阅读更多关于 LM Studio CLI 中 lms get 的内容,请点击此处