LM Studio 로컬 API와 SDK

LM Studio 로컬 API와 SDK

LM Studio는 로컬 모델을 HTTP API와 SDK로 다룰 수 있게 해 줘요. TypeScript(lmstudio-js)와 Python(lmstudio-python) SDK, REST API, 그리고 OpenAI·Anthropic 호환 엔드포인트를 제공해요.

출처: LM Studio — Developer Docs

로컬 서버 시작

lms server start --port 1234

기본적으로 OpenAI 호환 및 Anthropic 호환 엔드포인트가 제공돼요.

  • OpenAI 호환: http://localhost:1234/v1 — chat, responses, embeddings 등
  • Anthropic 호환: http://localhost:1234/v1/messages
  • LM Studio 네이티브 REST: /api/v0 (모델 관리·통계)

TypeScript SDK

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

Python SDK

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)

REST API (HTTP)

lms server start --port 1234
curl http://localhost: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?"}'

헤드리스 배포 (llmster)

llmster는 LM Studio의 핵심을 데몬으로 패키징한 것으로, 서버·클라우드 인스턴스·CI에서 GUI 없이 헤드리스로 배포할 수 있어요.

curl -fsSL https://lmstudio.ai/install.sh | bash   # Mac/Linux
irm https://lmstudio.ai/install.ps1 | iex          # Windows
lms daemon up          # 데몬 시작
lms get <model>        # 모델 다운로드
lms server start       # 로컬 서버 시작
lms chat               # 대화형 세션

더 알아보기