LM Studio Commands & Prompt Reference
Endpoints, request fields and config keys from LM Studio's developer documentation for the 0.4 series, checked on 2026-10-10 (the API changelog's newest entry is LM Studio 0.4.1): the OpenAI-, Anthropic- and Jev-compatible endpoints, the native /api/v1/chat API, structured output, tool calling, MCP integrations, SDK prediction and load settings, and model.yaml keys. The lms command line and the app's keys are on the LM Studio shortcuts page. Sampling fields travel with each request; load fields such as contextLength apply when a model is loaded.
Also see: LM Studio keyboard shortcuts.
All Commands
Compatibility endpoints (8)
| Command / Syntax | What it does | Notes |
|---|---|---|
| /v1/models | List available models | GET; with Just-In-Time loading on, downloaded models that are not loaded yet can show up too. |
| /v1/chat/completions | Chat completions endpoint | POST; takes text and image messages from any OpenAI client once its base URL points at LM Studio. |
| /v1/responses | Responses endpoint | POST; adds stateful follow-ups, reasoning effort, SSE streaming and opt-in remote MCP tools, and is what Codex uses. |
| /v1/embeddings | Embeddings endpoint | POST; send text as input to an embedding model and read each vector from the data list. |
| /v1/completions | Legacy text completions | POST; no prompt template is applied, so base models suit it better than chat-tuned ones. |
| /v1/decisions | Decisions endpoint | POST; answers typed questions such as predicates and needs a decision model loaded, not a chat model. |
| /v1/messages | Anthropic Messages endpoint | POST; lets the Anthropic SDK or Claude Code use local models with http://localhost:1234 as base URL. |
| /v1/systemone | Jev decisions endpoint | POST; takes a state plus questions keyed by ID, of type noul, choice or score. |
Native REST endpoints (6)
| Command / Syntax | What it does | Notes |
|---|---|---|
| /api/v1/chat | Native chat endpoint | POST; keeps chat state and can call MCP servers, but accepts no custom tool definitions. |
| /api/v1/models | List models (native) | GET with no parameters; each entry says whether it is an LLM, embedding or decision model. |
| /api/v1/models/load | Load a model over HTTP | POST; the body sets load options such as context length or flash attention for the new instance. |
| /api/v1/models/unload | Unload a model over HTTP | POST with the instance_id of the loaded copy you want to free. |
| /api/v1/models/download | Start a model download | POST a catalog ID or a Hugging Face link; quantization can only be picked for Hugging Face links. |
| /api/v1/models/download/status/:job_id | Check a download job | GET with the job_id the download call returned; reports speed, bytes so far and an estimated finish. |
Chat completions parameters (16)
| Command / Syntax | What it does | Notes |
|---|---|---|
| model | Model to run | Use the identifier LM Studio shows for the model; with JIT loading the first request loads it. |
| messages | Chat history | Role and content objects; LM Studio applies the model's prompt template to them for chat-tuned models. |
| temperature | Sampling temperature | Lower values give more repeatable answers; LM Studio's native API documents a range of 0 to 1. |
| top_p | Nucleus sampling cutoff | Only the likeliest tokens whose probabilities add up to this share stay in play. |
| top_k | Top-k sampling | Restricts each next-token choice to the K most probable candidates. |
| max_tokens | Output token limit | Caps the length of the reply; the native chat endpoint calls the same limit max_output_tokens. |
| stream | Stream the reply | Set to true to receive the answer as server-sent event chunks instead of one JSON body. |
| stop | Stop sequences | Strings that end generation as soon as the model produces one of them. |
| presence_penalty | Presence penalty | OpenAI-style penalty on tokens that have appeared at all, nudging the reply toward new topics. |
| frequency_penalty | Frequency penalty | OpenAI-style penalty that grows with how often a token has already been used. |
| logit_bias | Token bias map | Maps token IDs to bias values that raise or lower their odds, as in OpenAI's API. |
| repeat_penalty | Repetition penalty | 1 leaves output untouched; larger values make repeated token sequences rarer. |
| seed | Random seed | Fix it to get the same sampling for the same request and settings. |
| ttl | Idle unload timer | Seconds a JIT-loaded model may sit unused before it is unloaded; JIT loads otherwise default to 60 minutes. |
| draft_model | Speculative decoding draft | Names a smaller companion model; response stats then count accepted and rejected draft tokens. |
| stream_options.include_usage | Token usage while streaming | Set true so a streamed reply also reports prompt and completion token counts; added in 0.3.18. |
Structured output (5)
| Command / Syntax | What it does | Notes |
|---|---|---|
| response_format | Output format object | Goes on a chat completions request; models below about 7B parameters may not handle it. |
| "type": "json_schema" | Schema-constrained JSON | Set inside response_format so the reply must be valid JSON matching your schema. |
| json_schema | Schema wrapper | Holds a name for the schema and the JSON Schema itself under schema. |
| response_format.type | Format type switch | Besides json_schema, chat completion requests accept "text" here since LM Studio 0.3.18. |
| choices[0].message.content | Where the JSON arrives | The structured answer is a string here, so parse it with a JSON parser before use. |
Tool calling (11)
| Command / Syntax | What it does | Notes |
|---|---|---|
| tools | Function definitions | Array of functions the model may request; the chat template injects it into the system prompt. |
| "type": "function" | Function tool entry | Each tools entry wraps a function with its name, description and JSON Schema parameters. |
| "tool_choice": "auto" | Let the model decide | The model picks between a normal reply and one or more tool calls. |
| "tool_choice": "none" | Turn tool calls off | Keeps the tools in the request but rules out calling them, so the reply is ordinary text. |
| "tool_choice": "required" | Force a tool call | Only honoured by models running on the llama.cpp engine, per the 0.3.15 release notes. |
| choices[0].message.tool_calls | Parsed tool requests | Stays empty when LM Studio cannot parse the model output; the raw text then lands in content. |
| "finish_reason": "tool_calls" | Tool-call finish reason | Check it to tell a tool request from a final answer; streamed chunks carry it as well. |
| "role": "tool" | Tool result message | Carries a function result back; models without native tool support receive it as a user message. |
| tool_call_id | Match result to call | Copy the id of the tool call being answered into the tool message. |
| input_schema | Tool schema on Messages | On /v1/messages a tool lists its JSON Schema here, in Anthropic form, instead of under parameters. |
| "tool_choice": {"type": "any"} | Tool choice on Messages | The Anthropic-style object form used by the /v1/messages example, not the OpenAI string values. |
Tool-call tokens (4)
| Command / Syntax | What it does | Notes |
|---|---|---|
| <tools> | Qwen tool list tag | The Qwen2.5-Instruct template wraps the tools array in this tag inside the system prompt. |
| <tool_call> | Qwen tool call tag | Native call format of Qwen2.5-Instruct; LM Studio turns the JSON between the tags into tool_calls. |
| [TOOL_REQUEST] | Default tool call opener | Format LM Studio teaches models that lack native tool support; lms log stream shows it in the prompt. |
| [END_TOOL_REQUEST] | Default tool call closer | Ends each request; the default system prompt asks for one block per tool. |
Responses fields (4)
| Command / Syntax | What it does | Notes |
|---|---|---|
| previous_response_id | Continue a stored response | A follow-up then sends only its new input, as in the docs' stateful example on /v1/responses. |
| "reasoning": { "effort": "low" } | Reasoning effort | Sets how much the model reasons first; the docs' example asks gpt-oss-20b for low effort. |
| "stream": true | Stream Responses events | Emits SSE events such as response.output_text.delta, ending with response.completed. |
| "type": "mcp" | Remote MCP tool | Opt-in: enable Remote MCP under Developer settings first, then give server_label and server_url. |
Native chat fields (10)
| Command / Syntax | What it does | Notes |
|---|---|---|
| input | Message to send | A plain string, or an array of text and image items for one user turn. |
| system_prompt | System instructions | Separate field on the native endpoint, which takes no assistant messages in its input. |
| data_url | Inline image | Used in an input item of type image; the picture travels base64-encoded inside the request. |
| min_p | Minimum token probability | Tokens below this share, between 0 and 1, are never chosen; not offered on chat completions. |
| max_output_tokens | Cap on generated tokens | Native name for the limit that OpenAI-style requests call max_tokens. |
| reasoning | Reasoning level | One of off, low, medium, high or on; asking for a level the model lacks returns an error. |
| context_length | Context size per request | Only the native endpoint can set context per request; the docs advise more for MCP work. |
| store | Keep the chat | On by default; the reply then carries a response_id to continue from. |
| previous_response_id | Append to a stored chat | Pass the response_id of an earlier reply; valid IDs begin with resp_. |
| stream | Stream native events | Off by default; when true, SSE events also cover model loading and prompt processing. |
MCP servers (7)
| Command / Syntax | What it does | Notes |
|---|---|---|
| integrations | Enable plugins or MCP | Array on /api/v1/chat; a bare string such as mcp/playwright is shorthand for a plugin entry. |
| "type": "plugin" | Use an mcp.json server | Plugin entry naming a server by id, e.g. mcp/playwright; needs Allow calling servers from mcp.json switched on. |
| "type": "ephemeral_mcp" | Per-request MCP server | Defined inline with server_label and server_url; needs Allow per-request MCPs switched on. |
| allowed_tools | Limit MCP tools | Leave it out to expose every tool; fewer tools also means less prompt for the model to process. |
| headers | Headers for an MCP server | Only for ephemeral servers; servers from mcp.json keep their headers in that file. |
| mcpServers | mcp.json server list | Top-level key of mcp.json, which follows Cursor's notation; edit it via Program, Install, Edit mcp.json. |
| "url" | Remote server address | Gives the address of a remote MCP server, such as Hugging Face's, in an mcp.json entry. |
Model load fields (6)
| Command / Syntax | What it does | Notes |
|---|---|---|
| context_length | Context window at load | Maximum tokens the loaded instance considers; works for LLMs and embedding models. |
| eval_batch_size | Prompt batch size | Input tokens handled per evaluation batch; only models on the llama.cpp engine use it. |
| flash_attention | Flash attention switch | May lower memory use and speed up generation on llama.cpp-engine models. |
| num_experts | Active MoE experts | Applies only to Mixture of Experts models run by the llama.cpp engine. |
| offload_kv_cache_to_gpu | KV cache on GPU | When false, the KV cache is kept in system RAM instead of GPU memory. |
| echo_load_config | Return applied settings | Adds a load_config object to the response, including settings the request did not set. |
SDK prediction config (14)
| Command / Syntax | What it does | Notes |
|---|---|---|
| temperature | Sampling randomness | Per-request value from 0 to 1 passed to respond or complete; lower is more predictable. |
| maxTokens | Maximum tokens to generate | false removes the cap; reaching it sets stopReason to maxPredictedTokensReached. |
| topPSampling | Nucleus sampling cutoff | The guides call it topP in prose; the config field is topPSampling, and false switches it off. |
| structured | Enforce a JSON schema | Takes a zod schema, or type json with a jsonSchema; with zod the result also has a parsed value. |
| stopStrings | Stop strings | Prediction ends on any listed string, with stopReason set to stopStringFound. |
| toolCallStopStrings | Stop on a tool call | Listed strings end the prediction and mark it as a tool call (stopReason toolCalls). |
| contextOverflowPolicy | Context overflow handling | stopAtLimit, truncateMiddle or rollingWindow decides what happens once the context window is full. |
| topKSampling | Top-K token limit | Typical values run from 20 to 100; smaller is more focused, larger more varied. |
| repeatPenalty | Repeat penalty | 1.0 means none, 1.2 cuts the odds of reused tokens by 20%, and false disables it. |
| minPSampling | Minimum probability filter | At 0.05, any token under 5% probability is dropped; false turns the filter off. |
| xtcProbability | XTC sampling rate | Chance per token that Exclude Top Choices filtering runs, used to cut clichés. |
| xtcThreshold | XTC probability floor | Only acts when xtcProbability is set; candidates from this value up to 0.5 are thinned out. |
| cpuThreads | CPU threads | Defaults to a value based on your hardware; the docs suggest 4 to 6 on an 8-core machine. |
| draftModel | Draft model key | Giving the key is enough; the SDK does not need the draft model loaded beforehand. |
SDK load config (9)
| Command / Syntax | What it does | Notes |
|---|---|---|
| contextLength | Context window size | Counts prompt and reply tokens together; contextOverflowPolicy decides what happens past it. |
| gpu: { ratio: 0.5 } | GPU offload ratio | Load-time setting passed in config to load or model; the guide's example offloads half the model. |
| evalBatchSize | Evaluation batch size | Bigger batches usually speed up prompt processing but need more memory. |
| flashAttention | Flash Attention | Saves memory and speeds generation on compatible hardware, most of all with long inputs. |
| keepModelInMemory | Pin model in RAM | Reserves system memory even for GPU-offloaded parts, trading RAM for faster access. |
| seed | Reproducible seed | Set at load time so sampling gives the same results across runs, useful for tests. |
| useFp16ForKVCache | FP16 KV cache | Stores the attention cache at half precision to save memory, usually with little quality loss. |
| tryMmap | Memory-mapped loading | Faster startup, but it can slow down when the model is larger than available RAM. |
| numExperts | MoE expert count | Only for Mixture of Experts models; affects both speed and output quality. |
model.yaml fields (10)
| Command / Syntax | What it does | Notes |
|---|---|---|
| model: PUBLISHER/MODEL | Canonical model ID | Written as publisher and model name, for example qwen/qwen3-8b. |
| base | Concrete model files | Lists keyed sources, such as Hugging Face repos for the GGUF and MLX builds of one model. |
| metadataOverrides | Catalog metadata | Changes how the model is presented in search and the catalog, not how it runs. |
| config | Baked-in defaults | Holds default sampling and load settings, much like per-model defaults set in the app. |
| operation | Inference-time settings | The part of config whose fields apply at prediction time. |
| load | Load-time settings | The part of config whose fields apply when the model is loaded. |
| llm.prediction.temperature | Default temperature key | Inference keys carry the llm.prediction prefix, like topKSampling and minPSampling in the example. |
| llm.load.contextLength | Default context length key | Load keys carry the llm.load prefix; this one fixes the context length used at load. |
| customFields | Model-specific settings | Adds a user-facing option such as Enable Thinking, with effects that act on the template. |
| setJinjaVariable | Set a template variable | Works only if the Jinja template defines the variable it names, such as enable_thinking. |
Authentication and base URLs (4)
| Command / Syntax | What it does | Notes |
|---|---|---|
| Authorization: Bearer $LM_API_TOKEN | API token header | Needed only after Require Authentication is switched on in Server Settings (LM Studio 0.4.0 or newer). |
| x-api-key: $LM_API_TOKEN | Anthropic-style key header | Accepted alongside the Bearer form; optional while authentication is switched off. |
| http://localhost:1234/v1 | OpenAI base URL | Set it as the base URL of an existing OpenAI client; the docs' examples assume port 1234. |
| export ANTHROPIC_BASE_URL=http://localhost:1234 | Point Claude Code here | Pair it with ANTHROPIC_AUTH_TOKEN, then start claude with a local model such as openai/gpt-oss-20b. |
Recipes
Our notes on combining the fields above. Each code line uses tokens from the tables on this page.
Point an OpenAI client at a local model
http://localhost:1234/v1 → /v1/models → /v1/chat/completions
Swap the base URL in an existing OpenAI client, read the model identifiers from /v1/models and send chat requests as usual. With Just-In-Time loading the first request loads the model, and ttl sets how long it may then sit idle before it is unloaded.
Get JSON that matches a schema
response_format → json_schema → choices[0].message.content
Put the schema under json_schema inside response_format. The answer comes back as a JSON string in the message content and still has to be parsed; the docs warn that models below about 7B parameters may not manage structured output.
Let a model call your functions
tools → choices[0].message.tool_calls → "role": "tool"
Describe each function in tools, run what the model asks for in tool_calls, and send each result back as a tool message with its tool_call_id. When tool_calls stays empty, the model output could not be parsed: lms log stream (on the shortcuts page) shows the raw text, including the [TOOL_REQUEST] format used for models without native tool support.
Give the native chat endpoint MCP tools
/api/v1/chat → integrations → allowed_tools
Name a server from mcp.json as a plugin, or define a remote one inline as ephemeral_mcp, then narrow it with allowed_tools. Each route needs its own switch in Server Settings.
Frequently Asked Questions
Where are the lms commands for LM Studio?
The lms command line (server, model loading, log streaming) and the app's keyboard shortcuts are listed on the LM Studio shortcuts page. This page keeps to what goes into API requests, SDK config objects, mcp.json and model.yaml.
What is the difference between inference and load parameters?
Inference fields such as temperature and maxTokens are sent with each request. Load fields such as contextLength or gpu: { ratio: 0.5 } apply when a model is loaded; if the model is already in memory, the SDK's model() call ignores them, while load() starts a new instance with them.
Which LM Studio endpoints keep chat state on the server?
/api/v1/chat stores a chat by default and returns a response_id to pass back as previous_response_id; /v1/responses chains turns the same way. /v1/chat/completions and /v1/messages keep no state, so each request carries the whole history.
Why does the response have no tool_calls although the model wanted a tool?
LM Studio fills choices[0].message.tool_calls only when it can parse the model output. Small models and models without native tool support can emit malformed calls, which then arrive as plain message content; a model with native support (hammer badge in the app) usually does better.
Do requests to the local server need an API token?
Only after Require Authentication is switched on in Server Settings (LM Studio 0.4.0 or newer). Send the token as Authorization: Bearer $LM_API_TOKEN, or as x-api-key: $LM_API_TOKEN on the Anthropic-style endpoint.
Sources and checks
- LM Studio Docs — OpenAI Compatibility Endpoints Supported OpenAI-style endpoints and the local base URL
- LM Studio Docs — Chat Completions (OpenAI-compatible) Supported payload parameters of /v1/chat/completions
- LM Studio Docs — Structured Output response_format and json_schema on chat completions
- LM Studio Docs — Tool Use tools array, tool_calls, tool messages and tool-call tokens
- LM Studio Docs — Responses (OpenAI-compatible) Fields of /v1/responses: state, reasoning, streaming, remote MCP
- LM Studio Docs — List Models (OpenAI-compatible) GET /v1/models
- LM Studio Docs — LM Studio API (native REST v1, LM Studio 0.4.0+) Native /api/v1 endpoint table and the endpoint comparison
- LM Studio Docs — REST API: Chat with a model (POST /api/v1/chat) Request body fields of the native chat endpoint
- LM Studio Docs — REST API: Load a model (POST /api/v1/models/load) Load-time request fields
- LM Studio Docs — REST API: List your models GET /api/v1/models
- LM Studio Docs — REST API: Unload a model POST /api/v1/models/unload
- LM Studio Docs — REST API: Download a model POST /api/v1/models/download
- LM Studio Docs — REST API: Get download status GET /api/v1/models/download/status/:job_id
- LM Studio Docs — Anthropic Compatibility Endpoints (LM Studio 0.4.1+) /v1/messages, auth headers and Claude Code environment variables
- LM Studio Docs — Messages (Anthropic-compatible) Tool fields of /v1/messages
- LM Studio Docs — Decisions (System One, Jev-compatible) /v1/systemone
- LM Studio Docs — Authentication (LM Studio 0.4.0+) API token header
- LM Studio Docs — Idle TTL and Auto-Evict ttl request field
- LM Studio Docs — API Changelog (latest entry LM Studio 0.4.1) tool_choice, draft_model, stream_options and response_format.type
- LM Studio Docs — TypeScript SDK reference: LLMPredictionConfigInput Inference-time config fields of the SDKs
- LM Studio Docs — TypeScript SDK reference: LLMLoadModelConfig Load-time config fields of the SDKs
- LM Studio Docs — TypeScript SDK: Configuring the Model GPU offload ratio example
- LM Studio Docs — Introduction to model.yaml model.yaml fields
- LM Studio Docs — Use MCP Servers (mcp.json) mcp.json keys
- LM Studio Docs — Using MCP via API (LM Studio 0.4.0+) integrations, allowed_tools and the Server Settings switches
Every row on this page was matched to a line in the documentation above on . A command or parameter that could not be found there is not listed.
15 rows from the earlier version of this page were removed in that check: duplicates, and entries the documentation does not list or lists differently.
AI tools change their commands, parameters and model names between releases: the vendor's current documentation and the version you run have the last word. Found a wrong or missing entry? Tell us and it gets checked against the source. How we verify describes the process and its limits.
Related prompt references
DeepSeek (46) · GLM (Z.ai) (58) · Kimi (Moonshot AI) (40) · All AI prompt references