LM Studio Commands & Prompt Reference

114 commands & parameters · 14 categories · Sources: LM Studio Docs — OpenAI Compatibility Endpoints and 24 more · Checked

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 / SyntaxWhat it doesNotes
/v1/modelsList available modelsGET; with Just-In-Time loading on, downloaded models that are not loaded yet can show up too.
/v1/chat/completionsChat completions endpointPOST; takes text and image messages from any OpenAI client once its base URL points at LM Studio.
/v1/responsesResponses endpointPOST; adds stateful follow-ups, reasoning effort, SSE streaming and opt-in remote MCP tools, and is what Codex uses.
/v1/embeddingsEmbeddings endpointPOST; send text as input to an embedding model and read each vector from the data list.
/v1/completionsLegacy text completionsPOST; no prompt template is applied, so base models suit it better than chat-tuned ones.
/v1/decisionsDecisions endpointPOST; answers typed questions such as predicates and needs a decision model loaded, not a chat model.
/v1/messagesAnthropic Messages endpointPOST; lets the Anthropic SDK or Claude Code use local models with http://localhost:1234 as base URL.
/v1/systemoneJev decisions endpointPOST; takes a state plus questions keyed by ID, of type noul, choice or score.

Native REST endpoints (6)

Command / SyntaxWhat it doesNotes
/api/v1/chatNative chat endpointPOST; keeps chat state and can call MCP servers, but accepts no custom tool definitions.
/api/v1/modelsList models (native)GET with no parameters; each entry says whether it is an LLM, embedding or decision model.
/api/v1/models/loadLoad a model over HTTPPOST; the body sets load options such as context length or flash attention for the new instance.
/api/v1/models/unloadUnload a model over HTTPPOST with the instance_id of the loaded copy you want to free.
/api/v1/models/downloadStart a model downloadPOST a catalog ID or a Hugging Face link; quantization can only be picked for Hugging Face links.
/api/v1/models/download/status/:job_idCheck a download jobGET with the job_id the download call returned; reports speed, bytes so far and an estimated finish.

Chat completions parameters (16)

Command / SyntaxWhat it doesNotes
modelModel to runUse the identifier LM Studio shows for the model; with JIT loading the first request loads it.
messagesChat historyRole and content objects; LM Studio applies the model's prompt template to them for chat-tuned models.
temperatureSampling temperatureLower values give more repeatable answers; LM Studio's native API documents a range of 0 to 1.
top_pNucleus sampling cutoffOnly the likeliest tokens whose probabilities add up to this share stay in play.
top_kTop-k samplingRestricts each next-token choice to the K most probable candidates.
max_tokensOutput token limitCaps the length of the reply; the native chat endpoint calls the same limit max_output_tokens.
streamStream the replySet to true to receive the answer as server-sent event chunks instead of one JSON body.
stopStop sequencesStrings that end generation as soon as the model produces one of them.
presence_penaltyPresence penaltyOpenAI-style penalty on tokens that have appeared at all, nudging the reply toward new topics.
frequency_penaltyFrequency penaltyOpenAI-style penalty that grows with how often a token has already been used.
logit_biasToken bias mapMaps token IDs to bias values that raise or lower their odds, as in OpenAI's API.
repeat_penaltyRepetition penalty1 leaves output untouched; larger values make repeated token sequences rarer.
seedRandom seedFix it to get the same sampling for the same request and settings.
ttlIdle unload timerSeconds a JIT-loaded model may sit unused before it is unloaded; JIT loads otherwise default to 60 minutes.
draft_modelSpeculative decoding draftNames a smaller companion model; response stats then count accepted and rejected draft tokens.
stream_options.include_usageToken usage while streamingSet true so a streamed reply also reports prompt and completion token counts; added in 0.3.18.

Structured output (5)

Command / SyntaxWhat it doesNotes
response_formatOutput format objectGoes on a chat completions request; models below about 7B parameters may not handle it.
"type": "json_schema"Schema-constrained JSONSet inside response_format so the reply must be valid JSON matching your schema.
json_schemaSchema wrapperHolds a name for the schema and the JSON Schema itself under schema.
response_format.typeFormat type switchBesides json_schema, chat completion requests accept "text" here since LM Studio 0.3.18.
choices[0].message.contentWhere the JSON arrivesThe structured answer is a string here, so parse it with a JSON parser before use.

Tool calling (11)

Command / SyntaxWhat it doesNotes
toolsFunction definitionsArray of functions the model may request; the chat template injects it into the system prompt.
"type": "function"Function tool entryEach tools entry wraps a function with its name, description and JSON Schema parameters.
"tool_choice": "auto"Let the model decideThe model picks between a normal reply and one or more tool calls.
"tool_choice": "none"Turn tool calls offKeeps the tools in the request but rules out calling them, so the reply is ordinary text.
"tool_choice": "required"Force a tool callOnly honoured by models running on the llama.cpp engine, per the 0.3.15 release notes.
choices[0].message.tool_callsParsed tool requestsStays empty when LM Studio cannot parse the model output; the raw text then lands in content.
"finish_reason": "tool_calls"Tool-call finish reasonCheck it to tell a tool request from a final answer; streamed chunks carry it as well.
"role": "tool"Tool result messageCarries a function result back; models without native tool support receive it as a user message.
tool_call_idMatch result to callCopy the id of the tool call being answered into the tool message.
input_schemaTool schema on MessagesOn /v1/messages a tool lists its JSON Schema here, in Anthropic form, instead of under parameters.
"tool_choice": {"type": "any"}Tool choice on MessagesThe Anthropic-style object form used by the /v1/messages example, not the OpenAI string values.

Tool-call tokens (4)

Command / SyntaxWhat it doesNotes
<tools>Qwen tool list tagThe Qwen2.5-Instruct template wraps the tools array in this tag inside the system prompt.
<tool_call>Qwen tool call tagNative call format of Qwen2.5-Instruct; LM Studio turns the JSON between the tags into tool_calls.
[TOOL_REQUEST]Default tool call openerFormat LM Studio teaches models that lack native tool support; lms log stream shows it in the prompt.
[END_TOOL_REQUEST]Default tool call closerEnds each request; the default system prompt asks for one block per tool.

Responses fields (4)

Command / SyntaxWhat it doesNotes
previous_response_idContinue a stored responseA follow-up then sends only its new input, as in the docs' stateful example on /v1/responses.
"reasoning": { "effort": "low" }Reasoning effortSets how much the model reasons first; the docs' example asks gpt-oss-20b for low effort.
"stream": trueStream Responses eventsEmits SSE events such as response.output_text.delta, ending with response.completed.
"type": "mcp"Remote MCP toolOpt-in: enable Remote MCP under Developer settings first, then give server_label and server_url.

Native chat fields (10)

Command / SyntaxWhat it doesNotes
inputMessage to sendA plain string, or an array of text and image items for one user turn.
system_promptSystem instructionsSeparate field on the native endpoint, which takes no assistant messages in its input.
data_urlInline imageUsed in an input item of type image; the picture travels base64-encoded inside the request.
min_pMinimum token probabilityTokens below this share, between 0 and 1, are never chosen; not offered on chat completions.
max_output_tokensCap on generated tokensNative name for the limit that OpenAI-style requests call max_tokens.
reasoningReasoning levelOne of off, low, medium, high or on; asking for a level the model lacks returns an error.
context_lengthContext size per requestOnly the native endpoint can set context per request; the docs advise more for MCP work.
storeKeep the chatOn by default; the reply then carries a response_id to continue from.
previous_response_idAppend to a stored chatPass the response_id of an earlier reply; valid IDs begin with resp_.
streamStream native eventsOff by default; when true, SSE events also cover model loading and prompt processing.

MCP servers (7)

Command / SyntaxWhat it doesNotes
integrationsEnable plugins or MCPArray on /api/v1/chat; a bare string such as mcp/playwright is shorthand for a plugin entry.
"type": "plugin"Use an mcp.json serverPlugin 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 serverDefined inline with server_label and server_url; needs Allow per-request MCPs switched on.
allowed_toolsLimit MCP toolsLeave it out to expose every tool; fewer tools also means less prompt for the model to process.
headersHeaders for an MCP serverOnly for ephemeral servers; servers from mcp.json keep their headers in that file.
mcpServersmcp.json server listTop-level key of mcp.json, which follows Cursor's notation; edit it via Program, Install, Edit mcp.json.
"url"Remote server addressGives the address of a remote MCP server, such as Hugging Face's, in an mcp.json entry.

Model load fields (6)

Command / SyntaxWhat it doesNotes
context_lengthContext window at loadMaximum tokens the loaded instance considers; works for LLMs and embedding models.
eval_batch_sizePrompt batch sizeInput tokens handled per evaluation batch; only models on the llama.cpp engine use it.
flash_attentionFlash attention switchMay lower memory use and speed up generation on llama.cpp-engine models.
num_expertsActive MoE expertsApplies only to Mixture of Experts models run by the llama.cpp engine.
offload_kv_cache_to_gpuKV cache on GPUWhen false, the KV cache is kept in system RAM instead of GPU memory.
echo_load_configReturn applied settingsAdds a load_config object to the response, including settings the request did not set.

SDK prediction config (14)

Command / SyntaxWhat it doesNotes
temperatureSampling randomnessPer-request value from 0 to 1 passed to respond or complete; lower is more predictable.
maxTokensMaximum tokens to generatefalse removes the cap; reaching it sets stopReason to maxPredictedTokensReached.
topPSamplingNucleus sampling cutoffThe guides call it topP in prose; the config field is topPSampling, and false switches it off.
structuredEnforce a JSON schemaTakes a zod schema, or type json with a jsonSchema; with zod the result also has a parsed value.
stopStringsStop stringsPrediction ends on any listed string, with stopReason set to stopStringFound.
toolCallStopStringsStop on a tool callListed strings end the prediction and mark it as a tool call (stopReason toolCalls).
contextOverflowPolicyContext overflow handlingstopAtLimit, truncateMiddle or rollingWindow decides what happens once the context window is full.
topKSamplingTop-K token limitTypical values run from 20 to 100; smaller is more focused, larger more varied.
repeatPenaltyRepeat penalty1.0 means none, 1.2 cuts the odds of reused tokens by 20%, and false disables it.
minPSamplingMinimum probability filterAt 0.05, any token under 5% probability is dropped; false turns the filter off.
xtcProbabilityXTC sampling rateChance per token that Exclude Top Choices filtering runs, used to cut clichés.
xtcThresholdXTC probability floorOnly acts when xtcProbability is set; candidates from this value up to 0.5 are thinned out.
cpuThreadsCPU threadsDefaults to a value based on your hardware; the docs suggest 4 to 6 on an 8-core machine.
draftModelDraft model keyGiving the key is enough; the SDK does not need the draft model loaded beforehand.

SDK load config (9)

Command / SyntaxWhat it doesNotes
contextLengthContext window sizeCounts prompt and reply tokens together; contextOverflowPolicy decides what happens past it.
gpu: { ratio: 0.5 }GPU offload ratioLoad-time setting passed in config to load or model; the guide's example offloads half the model.
evalBatchSizeEvaluation batch sizeBigger batches usually speed up prompt processing but need more memory.
flashAttentionFlash AttentionSaves memory and speeds generation on compatible hardware, most of all with long inputs.
keepModelInMemoryPin model in RAMReserves system memory even for GPU-offloaded parts, trading RAM for faster access.
seedReproducible seedSet at load time so sampling gives the same results across runs, useful for tests.
useFp16ForKVCacheFP16 KV cacheStores the attention cache at half precision to save memory, usually with little quality loss.
tryMmapMemory-mapped loadingFaster startup, but it can slow down when the model is larger than available RAM.
numExpertsMoE expert countOnly for Mixture of Experts models; affects both speed and output quality.

model.yaml fields (10)

Command / SyntaxWhat it doesNotes
model: PUBLISHER/MODELCanonical model IDWritten as publisher and model name, for example qwen/qwen3-8b.
baseConcrete model filesLists keyed sources, such as Hugging Face repos for the GGUF and MLX builds of one model.
metadataOverridesCatalog metadataChanges how the model is presented in search and the catalog, not how it runs.
configBaked-in defaultsHolds default sampling and load settings, much like per-model defaults set in the app.
operationInference-time settingsThe part of config whose fields apply at prediction time.
loadLoad-time settingsThe part of config whose fields apply when the model is loaded.
llm.prediction.temperatureDefault temperature keyInference keys carry the llm.prediction prefix, like topKSampling and minPSampling in the example.
llm.load.contextLengthDefault context length keyLoad keys carry the llm.load prefix; this one fixes the context length used at load.
customFieldsModel-specific settingsAdds a user-facing option such as Enable Thinking, with effects that act on the template.
setJinjaVariableSet a template variableWorks only if the Jinja template defines the variable it names, such as enable_thinking.

Authentication and base URLs (4)

Command / SyntaxWhat it doesNotes
Authorization: Bearer $LM_API_TOKENAPI token headerNeeded only after Require Authentication is switched on in Server Settings (LM Studio 0.4.0 or newer).
x-api-key: $LM_API_TOKENAnthropic-style key headerAccepted alongside the Bearer form; optional while authentication is switched off.
http://localhost:1234/v1OpenAI base URLSet it as the base URL of an existing OpenAI client; the docs' examples assume port 1234.
export ANTHROPIC_BASE_URL=http://localhost:1234Point Claude Code herePair 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

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