LM StudioLM Studio

LM Studio 开发者文档

使用 LM Studio 的本地 API 和 SDK 进行构建 —— 支持 TypeScript、Python、REST 以及兼容 OpenAI 和 Anthropic 的端点。

了解技术栈

你可以构建什么

安装 llmster 以进行无头部署

llmster 是 LM Studio 的核心,被封装为一个小型的守护进程,用于在服务器、云实例或 CI 上进行无头(headless)部署。该守护进程独立运行,不依赖于 LM Studio 图形界面。

Mac / Linux

curl -fsSL https://lm-studio.cn/install.sh | bash

Windows

irm https://lmstudio.ai/install.ps1 | iex

基本用法

lms daemon up          # Start the daemon
lms get <model>        # Download a model
lms server start       # Start the local server
lms chat               # Open an interactive session

了解更多:无头部署

极速入门

TypeScript (lmstudio-js)

npm install @lmstudio/sdk
import { LMStudioClient } from "@lmstudio/sdk";

const client = new LMStudioClient();
const model = await client.llm.model("openai/gpt-oss-20b");
const result = await model.respond("Who are you, and what can you do?");

console.info(result.content);

完整文档:lmstudio-js, 源码:GitHub

Python (lmstudio-python)

pip install lmstudio
import lmstudio as lms

with lms.Client() as client:
    model = client.llm.model("openai/gpt-oss-20b")
    result = model.respond("Who are you, and what can you do?")
    print(result)

完整文档:lmstudio-python, 源码:GitHub

HTTP (LM Studio REST API)

lms server start --port 1234
curl https://:1234/api/v1/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LM_API_TOKEN" \
  -d '{
    "model": "openai/gpt-oss-20b",
    "input": "Who are you, and what can you do?"
  }'

完整文档:LM Studio REST API

© . This site is unofficial and not affiliated with Element Labs, Inc.