HOW-TO · SET

How to use LM Studio as a local API server

intermediate10 minBy Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.xWindows 11 · Ollama 0.4.xmacOS 15 · Ollama 0.4.x
PREREQUISITES

LM Studio installed, a model downloaded

What this does

Starts a local API server inside LM Studio so that clients such as Continue.dev or custom scripts can send prompts over HTTP and receive model-generated responses. After completion, an OpenAI-compatible REST endpoint is available on the local machine.

Steps

  1. Switch to the Server tab. In the left-side navigation bar inside LM Studio, click the Server icon to access the built-in server configuration panel.

  2. Select the model and start the server. Use the model dropdown to choose the previously downloaded model. Click Start Server to bind the REST endpoint. The server status indicator changes to green and the local address becomes active.

  3. Send a test chat request using curl. With the server running, verify that the endpoint responds correctly.

    curl -X POST http://localhost:1234/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{"model": "lmstudio-community/Mistral-7B-Instruct-v0.3", "messages": [{"role": "user", "content": "Hello, world!"}], "max_tokens": 20}'
    

    Expected output: a JSON response containing a choices array with model-generated text.

  4. Explore the available endpoints. Visit http://localhost:1234/v1/models to inspect which model the server exposes.

    curl http://localhost:1234/v1/models
    

    Expected output: JSON response listing the active model's name and ID.

Verification

curl -s http://localhost:1234/v1/models
# Expected: JSON object with a data key containing model metadata

Common failures

  • "connection refused" — The server has not been started. Confirm the server tab shows a green status indicator before sending requests.
  • Wrong model ID in the request body — The request payload must match exactly the model identifier shown in the server tab.
  • Port 1234 already in use — Another program has claimed the default port. Change the port in LM Studio server settings to an available number such as 5000.
  • Empty response or timeout — The model may be too large for available resources. Switch to a smaller model or enable GPU offload in settings.

Related guides

RELATED GUIDES