obsidian/raw/_processed/OpenAI Compatibility Endpoints.md
2026-04-30 14:42:43 +01:00

2.8 KiB

title source author published created description tags
OpenAI Compatibility Endpoints https://lmstudio.ai/docs/developer/openai-compat 2026-04-30 Send requests to Responses, Chat Completions (text and images), Completions, and Embeddings endpoints.
clippings

Send requests to Responses, Chat Completions (text and images), Completions, and Embeddings endpoints.

Supported endpoints

Endpoint Method Docs
/v1/models GET Models
/v1/responses POST Responses
/v1/chat/completions POST Chat Completions
/v1/embeddings POST Embeddings
/v1/completions POST Completions

Set the base url to point to LM Studio

You can reuse existing OpenAI clients (in Python, JS, C#, etc) by switching up the "base URL" property to point to your LM Studio instead of OpenAI's servers.

Note: The following examples assume the server port is 1234

Python Example

from openai import OpenAI

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

# ... the rest of your code ...

Typescript Example

import OpenAI from 'openai';

const client = new OpenAI({
+  baseUrl: "http://localhost:1234/v1"
});

// ... the rest of your code ...

cURL Example

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

Using Codex with LM Studio

Codex is supported because LM Studio implements the OpenAI-compatible POST /v1/responses endpoint.

See: Use Codex with LM Studio and Responses.


Other OpenAI client libraries should have similar options to set the base URL.

If you're running into trouble, hop onto our Discord and enter the #🔨-developers channel.REST API v0

[

The REST API includes enhanced stats such as Token / Second and Time To First Token (TTFT), as well as rich information about models such as loaded vs unloaded, max context, quantization, and more.

](https://lmstudio.ai/docs/developer/rest/endpoints)[

Chat Completions

Send a chat history and get the assistant's response.

](https://lmstudio.ai/docs/developer/openai-compat/chat-completions)