Local AI Local AI Intermediate

Use LM Studio as an OpenAI-Compatible Server

Expose local models to Claude Code, Cursor, or scripts via API

51 of 66

Why server mode matters

Server mode turns LM Studio into a drop-in replacement for the OpenAI API. Any tool that accepts a custom base URL can talk to your local model.

Start the server

  1. Go to the Developer tab
  2. Click Start Server
  3. Note the URL, usually
http://localhost:1234/v1

Test with curl

curl http://localhost:1234/v1/chat/completions   -H "Content-Type: application/json"   -d '{
    "model": "local-model",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Connect Claude Code

claude --api-url http://localhost:1234/v1

Connect Cursor

Open Settings → Models → OpenAI API. Set the base URL to:

http://localhost:1234/v1

Use any non-empty string for the API key.

Keep the server running

Server mode only works while LM Studio is open. For headless automation, prefer Ollama.

Working out which model to run this on? See The Codex. Packaging it as a reusable skill? See The Armory.