Skip to content

How-ToGPU

How to Use LM Studio as a Local API Server

How to turn LM Studio into a local LLM API server on http://localhost:1234: start the server from the Developer tab or with lms server start, then send OpenAI-compatible chat requests, using LM Studio's official developer docs.

By , Editorial team

· 4 min read

How to Use LM Studio as a Local API Server

LM Studio is a desktop app for downloading and chatting with local models, but it can also serve those models over HTTP. If another app expects an OpenAI-style API, you can often point it at LM Studio on your PC instead of at a cloud endpoint.

Forge PC has not measured throughput through this server, and we have not audited every client library. The steps and URLs below come from LM Studio's official developer documentation.

This page assumes you already have LM Studio installed and at least one model downloaded. Our Ollama and LM Studio install guide covers that, and our guide to GGUF quantisation explains the file names you will see in the catalogue. This article does not walk through picking a model file again.

Start the server

LM Studio's developer docs say you can serve models from the Developer tab, on localhost or on the network.

To start it in the app, open the Developer tab and toggle Start server.

To start it from a terminal, use LM Studio's CLI:

lms server start

The official OpenAI-compatibility examples assume the server port is 1234, so a typical base URL is:

http://localhost:1234/v1

If you have changed the port in Server Settings, use that port instead. The documentation also covers serving on the local network, authentication, running LM Studio as a headless service, idle TTL and auto-evict. For a first test, leave the server on localhost only.

Load a model in LM Studio before you send a request, or the client will have nothing to talk to. The REST API can also list, load and unload models, but the app's own loader is the straightforward route for a first check.

Send an OpenAI-compatible request

LM Studio documents OpenAI-compatible endpoints including:

  • GET /v1/models

  • POST /v1/chat/completions

  • POST /v1/completions

  • POST /v1/embeddings

  • POST /v1/responses

  • POST /v1/decisions

The official curl example for chat looks like this, with the model identifier taken from LM Studio rather than copied from OpenAI:

curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
     "model": "use the model identifier from LM Studio here",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Replace the model string with the identifier shown in LM Studio for the loaded model.

In Python, the official snippet is to point the OpenAI client at the local base URL:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:1234/v1")

Then call client.chat.completions.create as you would against OpenAI, using your local model name. The TypeScript example sets baseUrl to the same path.

LM Studio also implements POST /v1/responses, which its docs say is why Codex can be pointed at LM Studio. That is a compatibility note, not a requirement for ordinary chat scripts.

There is a separate LM Studio REST API, with its own quick start, that can report details such as tokens per second and whether a model is loaded. You do not need it for a first OpenAI-compatible chat request.

LM Studio and Ollama are different servers

If you already run Ollama, do not assume the two servers are interchangeable without changing the URL.

  • LM Studio's documented default is port 1234, base URL http://localhost:1234/v1.

  • Ollama's documented local OpenAI-compatible base URL is http://localhost:11434/v1.

They can both be installed on the same PC, but they should not both try to bind the same port, and a client must point at the server that actually has the model loaded. Keep both on localhost unless you have followed the vendor's guidance for authentication and network access.

If a request fails, check that the server toggle is on, that a model is loaded, that the port in the URL matches Server Settings, and that the model field matches an identifier LM Studio actually lists.

Keep the server local unless you mean to share it

LM Studio can serve on the local network, and the developer docs have separate pages for authentication, LM Link, and running the app as a headless service. Those are optional. A first setup should stay on localhost. If you later toggle "Serve on Local Network", you are letting other devices on that network reach a model that can read whatever you send it. Use the official authentication guidance before you do that, and do not port-forward 1234 to the internet as a shortcut.

If you start the server and a request still fails, work through a short list:

  • Is the Developer tab server switch on, or did lms server start actually succeed?

  • Is a model loaded, and does the model field match the identifier in the app?

  • Does the URL use the port shown in Server Settings, not an assumed 1234 after you changed it?

  • Is something else already bound to that port? The official default is 1234, which is easy to collide with if you have another local tool using it.

The REST API can list loaded versus unloaded models if you want to inspect state from a script. For everyday use, looking at the Developer tab is enough.

Our verdict

Open LM Studio's Developer tab, start the server, load a model, and point an OpenAI-compatible client at http://localhost:1234/v1. Use the model identifier from the app, and leave the server on localhost until you have a reason to share it. We have not benchmarked this API; the steps come from LM Studio's official developer documentation.

The bottom line

Open LM Studio's Developer tab, start the server, load a model, and point an OpenAI-compatible client at `http://localhost:1234/v1`. Use the model identifier from the app, and leave the server on localhost until you have a reason to share it. We have not benchmarked this API; the steps come from LM Studio's official developer documentation.

Sources

About the author

Forge PC Staff

Editorial team

More from Forge PC Staff

Read next

How to Use Continue in VS Code with a Local Ollama Model

How-To

How to Use Continue in VS Code with a Local Ollama Model

How to connect the Continue extension in VS Code to a local Ollama model for AI coding help without sending your code to a cloud API: official prerequisites, ollama pull, config.yaml, Autodetect, and common errors from Continue's documentation.

Forge PC Staff

How to Use Ollama's OpenAI-Compatible API

How-To

How to Use Ollama's OpenAI-Compatible API

How to call a local Ollama model from curl, Python or JavaScript using Ollama's official OpenAI-compatible API on http://localhost:11434/v1, including which endpoints are supported and how to pull a model first.

Forge PC Staff

NVIDIA App vs AMD Software: Which GPU Control App to Use

Versus

NVIDIA App vs AMD Software: Which GPU Control App to Use

NVIDIA App and AMD Software: Adrenalin Edition are the official apps for GeForce and Radeon PCs. We compare driver updates, overlays, recording, upscaling and one-click performance tools using NVIDIA's and AMD's own pages, not invented frame-rate tests.

Forge PC Staff

How to Install Open WebUI with Ollama on Windows

How-To

How to Install Open WebUI with Ollama on Windows

How to give Ollama a browser-based chat interface with Open WebUI on Windows: install Docker Desktop with the WSL 2 backend, run the official container, set a secret key, and connect to Ollama on port 11434.

Forge PC Staff