LM Studio Python SDK (lmstudio package). Chat completions, streaming, structured output, agentic tool use (.act()), embeddings, tokenization, model management, VLM image input. Use when writing Python code that talks to LM Studio, local LLMs via lmstudio SDK, or building agents with local models. Also covers lms CLI, llmster headless daemon, LM Link remote access, and server configuration.
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
LM Studio Python SDK (lmstudio package). Chat completions, streaming, structured output, agentic tool use (.act()), embeddings, tokenization, model management, VLM image input. Use when writing Python code that talks to LM Studio, local LLMs via lmstudio SDK, or building agents with local models. Also covers lms CLI, llmster headless daemon, LM Link remote access, and server configuration.
LM Studio Python SDK
pip install lmstudio — native SDK for LM Studio's local inference server.
Three API styles exist for every operation; pick one per project:
Convenience API — lms.llm(), lms.embedding_model() (sync, global client)
Scoped resource API — context managers for deterministic cleanup
Async API — structured concurrency (SDK ≥ 1.5.0)
All examples below use the convenience API. See references for scoped/async variants.
Quick start
import lmstudio as lms
model = lms.llm("qwen2.5-7b-instruct")
print(model.respond("What is the meaning of life?"))
Streaming:
for fragment in model.respond_stream("What is the meaning of life?"):
print(fragment.content, end="", flush=True)