LM Studio
Run local GGUF models with LM Studio's OpenAI-compatible server, directly or through Yunxin.
Overview
LM Studio is a desktop application for running GGUF models locally. It exposes an OpenAI-compatible server (default http://localhost:1234/v1) so you can call your local models with standard tooling.
Official Website: https://lmstudio.ai Documentation: https://lmstudio.ai/docs
Key features
- Local inference — Run models entirely on your own machine
- Desktop GUI — Browse, download, and manage models with a friendly interface
- Any GGUF model — Load any model in the GGUF format
- OpenAI-compatible API — Standard chat completions endpoint, no key required locally
- GPU acceleration — CUDA, Metal, and ROCm support
Calling LM Studio directly (local)
When you run LM Studio locally, point the OpenAI SDK at its local server. No API key is required, so any non-empty placeholder works.
from openai import OpenAI
client = OpenAI(
api_key="lm-studio",
base_url="http://localhost:1234/v1"
)
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "lm-studio",
baseURL: "http://localhost:1234/v1",
});
const response = await client.chat.completions.create({
model: "model-id",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "model-id",
"messages": [{"role": "user", "content": "Hello!"}]
}'Using LM Studio through Yunxin
If your LM Studio server is registered with Yunxin, address its models with the lmstudio/<model> prefix and use the standard Yunxin base URL (https://api.yuhuanstudio.com/v1) and your sk- API key. This lets you mix local models with hosted providers under one client.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="lmstudio/model-id",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.YUNXIN_API_KEY,
baseURL: "https://api.yuhuanstudio.com/v1",
});
const response = await client.chat.completions.create({
model: "lmstudio/model-id",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);curl https://api.yuhuanstudio.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YUNXIN_API_KEY" \
-d '{
"model": "lmstudio/model-id",
"messages": [{"role": "user", "content": "Hello!"}]
}'Available models
LM Studio serves whichever GGUF models you have downloaded and loaded. When accessed through Yunxin, query the Models API:
curl "https://api.yuhuanstudio.com/v1/models?provider=lmstudio" \
-H "Authorization: Bearer $YUNXIN_API_KEY"Capabilities depend on the loaded model and your hardware. The authoritative list for Yunxin is GET /v1/models?provider=lmstudio; for the local server, the loaded models are listed at http://localhost:1234/v1/models.
Official resources
How is this guide?