LM Studio's server offers /v1/chat/completions, /v1/responses, /v1/messages and the native /api/v1/chat — what decides which one a client should call?
answer
- four inference routes, one port
- the SDK the client speaks
- who keeps the conversation
- client tools or MCP integrations
- context length set per request
basics
~20 sCall the route the client's SDK already speaks: /v1/chat/completions or /v1/responses for OpenAI SDKs, /v1/messages for Anthropic ones. Use native /api/v1/chat for LM Studio-only features such as per-request context length, but it takes no custom tools.
solid answer
~40 sAll four stream. `/v1/chat/completions` is stateless and takes custom `tools`. `/v1/responses` (LM Studio 0.3.29) adds server-side state through `previous_response_id`, custom tools and remote MCP. `/v1/messages` (0.4.1) serves Anthropic-style clients with custom tools but no stored state. The native `/api/v1/chat` (0.4.0) is stateful by default (`store` is true, follow-ups pass `previous_response_id`), reaches tools only through MCP integrations, streams model-load and prompt-processing events, and is the only route that sets `context_length` per request; it takes no custom tools and no assistant messages in the request. Model management, `/api/v1/models` plus its `load`, `unload` and `download` routes, exists only in the native API, which replaced the older `/api/v0` REST API as the recommended one.
code
json · 8 lines{
"model": "your-org/your-model",
"system_prompt": "Answer in three bullet points.",
"input": "Summarise the release notes I pasted earlier.",
"previous_response_id": "resp_abc123",
"context_length": 16384,
"stream": false
}go deeper
Recall that one LM Studio server offers OpenAI-style, Anthropic-style and native routes, and that clients call the one their SDK speaks.
Explain the comparison: which routes keep state, which take custom tools, and why only /api/v1/chat sets context length per request.
Pick routes for a mixed client set, including the native load and unload routes for warm-up, and spot when a native-only feature forces a client change.
Weigh building on LM Studio's native API for its extras against staying on compatible routes so the backend can be swapped later.
## Four inference routes on one port LM Studio's local server, on port 1234 by default, answers inference requests on four routes. Three copy hosted APIs so existing clients work unchanged; one is LM Studio's own: - **`/v1/chat/completions`** — the OpenAI-style chat route: the client sends the whole `messages` history every time. - **`/v1/responses`** — the OpenAI-style Responses route, added in **LM Studio 0.3.29**, which can keep conversation state on the server. - **`/v1/messages`** — the Anthropic-style route, added in **LM Studio 0.4.1**. - **`/api/v1/chat`** — the native REST API's chat route, released with **LM Studio 0.4.0**. Alongside them sit `/v1/embeddings`, `/v1/models` and the legacy `/v1/completions`, which applies no prompt template and is meant for base models. ## What each inference route supports LM Studio's own comparison table reads: | Feature | `/api/v1/chat` | `/v1/responses` | `/v1/chat/completions` | `/v1/messages` | |---|---|---|---|---| | Streaming | yes | yes | yes | yes | | Stateful chat | yes | yes | no | no | | Remote MCPs | yes | yes | no | no | | MCPs configured in LM Studio | yes | yes | no | no | | Custom tools | **no** | yes | yes | yes | | Assistant messages in the request | **no** | yes | yes | yes | | Model-load streaming events | yes | no | no | no | | Prompt-processing streaming events | yes | no | no | no | | Context length in the request | **yes** | no | no | no | Two rows decide most choices. **Custom tools**, functions your own code defines and executes, are unavailable on the native chat route, which reaches tools only through MCP integrations (servers from your `mcp.json` or ephemeral MCP servers named in the request). **Context length per request** is available only there. ## How the native chat route differs in shape `/api/v1/chat` is not a renamed chat-completions route: - The request carries `model`, `input` (a string or text and image items) and an optional `system_prompt`, not a `messages` array of past turns. - It is **stateful by default**: `store` defaults to `true`, the response returns a `response_id` beginning with `resp_`, and the next request passes it as `previous_response_id`. Pointing at an earlier `response_id` branches the conversation. - The response's `output` is a list of items (`message`, `tool_call`, `reasoning`, `invalid_tool_call`), and `stats` reports tokens, speed and `model_load_time_seconds` when the request had to load the model. - `context_length`, sampling fields such as `temperature` and `max_output_tokens`, and a `reasoning` setting are request fields. ## Model management lives only in the native API The compatible routes can only use models. Managing them is native: - `GET /api/v1/models` — every model with its format, quantization, capabilities and `loaded_instances`. - `POST /api/v1/models/load` — load by `model` key with optional `context_length`, `flash_attention` and `echo_load_config`; returns an `instance_id`. - `POST /api/v1/models/unload` — unload by `instance_id`. - `POST /api/v1/models/download` and `GET /api/v1/models/download/status/:job_id` — start a download from a catalog key or Hugging Face link and poll its job. Before 0.4.0 the native API lived at `/api/v0` (chat completions, completions, embeddings and model info); the docs now recommend the v1 API for new work. ## Choosing 1. **An existing OpenAI-SDK tool** — `/v1/chat/completions`; nothing changes but the base URL. 2. **An OpenAI-SDK agent that wants the server to hold history** — `/v1/responses` with `previous_response_id`. 3. **An Anthropic-SDK tool** — `/v1/messages`. 4. **A script that must set context length per call, show load progress, or use MCP servers configured in LM Studio** — `/api/v1/chat`. 5. **Anything that loads, unloads or downloads models over HTTP** — the `/api/v1/models` routes, whatever route does the inference. ## Common mistakes - **Porting a chat-completions client to `/api/v1/chat` by renaming the path.** The body shape differs, and its custom tools stop working. - **Expecting `/v1/chat/completions` to remember the last turn.** It keeps no state; resend the history, or move to `/v1/responses` and pass `previous_response_id`. - **Building new tooling on `/api/v0`.** It predates 0.4.0, and the docs recommend the v1 API for new projects. - **Leaving `store` at its default when conversations should not persist on the server.** Send `store: false`. - **Sending a hosted model name in `model`.** Every route needs an identifier that LM Studio itself lists.
- An agent defines its own Python functions as tools. Can it use /api/v1/chat?Not for those functions: LM Studio's comparison marks custom tools unsupported on `/api/v1/chat`, which reaches tools only through MCP integrations. Send the tool definitions to `/v1/chat/completions`, `/v1/responses` or `/v1/messages` instead, and run the functions in your own code.
- How do you continue a conversation on /api/v1/chat without resending it, and how do you opt out?Each stored response returns a `response_id` starting with `resp_`; pass it as `previous_response_id` in the next request and the server supplies the earlier turns. Storage is on because `store` defaults to `true`; set `store: false` to keep nothing on the server.
- /api/v1/chat takes the same messages array as /v1/chat/completions.
- Only LM Studio's native API can stream responses.
- /v1/chat/completions keeps conversation state between calls on its own.
- The /api/v0 REST API is still LM Studio's recommended native API.
- Any of the four routes can set the context length per request.
Assumes LM Studio 0.4.1 or newer: /v1/responses arrived in 0.3.29, the native /api/v1 API in 0.4.0 and /v1/messages in 0.4.1.