Documentation

LM Studio REST API

Get up and running with the LM Studio API

Download a model and start a simple Chat session using the REST API

Start the server

Install and launch LM Studio.

Then ensure the server is running through the toggle at the top left of the Developer page, or through lms in the terminal:

lms server start

By default, the server is available at http://localhost:1234.

If you don't have a model downloaded yet, you can download the model:

lms get ibm/granite-4-micro

API Authentication

By default, the LM Studio API server does not require authentication. You can configure the server to require authentication by API token in the server settings for added security.

To authenticate API requests, generate an API token from the Developer page in LM Studio, and include it in the Authorization header of your requests as follows: Authorization: Bearer $LM_API_TOKEN. Read more about authentication here.

Chat with a model

Use the chat endpoint to send a message to a model. By default, the model will be automatically loaded if it is not already.

The /api/v1/chat endpoint is stateful, which means you do not need to pass the full history in every request. Read more about it here.

curl http://localhost:1234/api/v1/chat \
  -H "Authorization: Bearer $LM_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ibm/granite-4-micro",
    "input": "Write a short haiku about sunrise."
  }'

See the full chat docs for more details.

Use MCP servers via API

Enable the model interact with ephemeral Model Context Protocol (MCP) servers in /api/v1/chat by specifying servers in the integrations field.

curl http://localhost:1234/api/v1/chat \
  -H "Authorization: Bearer $LM_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ibm/granite-4-micro",
    "input": "What is the top trending model on hugging face?",
    "integrations": [
      {
        "type": "ephemeral_mcp",
        "server_label": "huggingface",
        "server_url": "https://huggingface.co/mcp",
        "allowed_tools": ["model_search"]
      }
    ],
    "context_length": 8000
  }'

You can also use locally configured MCP plugins (from your mcp.json) via the integrations field. Using locally run MCP plugins requires authentication via an API token passed through the Authorization header. Read more about authentication here.

curl http://localhost:1234/api/v1/chat \
  -H "Authorization: Bearer $LM_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ibm/granite-4-micro",
    "input": "Open lmstudio.ai",
    "integrations": [
      {
        "type": "plugin",
        "id": "mcp/playwright",
        "allowed_tools": ["browser_navigate"]
      }
    ],
    "context_length": 8000
  }'

See the full chat docs for more details.

Download a model

Use the download endpoint to download models by identifier from the LM Studio model catalog, or by Hugging Face model URL.

curl http://localhost:1234/api/v1/models/download \
  -H "Authorization: Bearer $LM_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ibm/granite-4-micro"
  }'

The response will return a job_id that you can use to track download progress.

curl -H "Authorization: Bearer $LM_API_TOKEN" \
  http://localhost:1234/api/v1/models/download/status/{job_id}

See the download and download status docs for more details.

This page's source is available on GitHub