LM Studio can serve a loaded model through an OpenAI-compatible API on http://localhost:1234/v1. Any tool that speaks the OpenAI chat format can then use the local model by changing only the base URL.
What you need
- LM Studio installed with a model downloaded
- curl installed
- A terminal on the same machine
Step 1: Start the local server
In LM Studio open the Developer tab and click Start Server, or run lms server start from the command line. The server listens on http://localhost:1234 by default, and its base URL is http://localhost:1234/v1.
Step 2: List the loaded models
Run curl http://localhost:1234/v1/models. The reply lists the model identifiers the server knows; copy the identifier of the model you want to call.
Step 3: Send a chat completion
Run: curl http://localhost:1234/v1/chat/completions -H Content-Type: application/json -d ‘{model: <model-id>, messages: [{role: user, content: What is a GGUF file?}]}’. The reply JSON holds the answer in choices[0].message.content.
Worked example: one chat call to LM Studio
The table below is a synthetic example. The base URL and endpoints come from the cited LM Studio guides; the model identifier is illustrative.
| Step | Request | Expected result |
|---|---|---|
| Models | GET /v1/models | A list with one model id |
| Chat | POST /v1/chat/completions | HTTP 200 with choices |
| Reply | choices[0].message.content | The answer text |
Expected result (UNTESTED). the models call lists the loaded model, and the chat call returns HTTP 200 with an answer in choices[0].message.content. This check was not run live; the endpoints come from the cited LM Studio guides.
Limits
- The server only serves a model that is loaded; start one first.
- The model field must match the identifier from /v1/models.
- Presets set in the app do not auto-apply to API calls.
- The server binds localhost by default; LAN access needs an explicit bind and care.
