---
title: "LM Studio — OpenAI Compatibility Endpoints"
aliases: [lmstudio-openai-compat, lmstudio-oai-endpoints]
tags: [lmstudio, openai, local-llm, api, embeddings, chat-completions]
sources: [raw/OpenAI Compatibility Endpoints.md]
created: 2026-04-30
updated: 2026-04-30
---

# LM Studio — OpenAI Compatibility Endpoints

LM Studio exposes an OpenAI-compatible HTTP server. Any existing OpenAI client (Python, TypeScript, cURL, C#, etc.) works against it by changing only the **base URL**.

Default port: `1234`.

## Supported Endpoints

| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/v1/models` | GET | List loaded/available models |
| `/v1/responses` | POST | Responses API (Codex-compatible) |
| `/v1/chat/completions` | POST | Chat with text and images |
| `/v1/embeddings` | POST | Generate text embeddings |
| `/v1/completions` | POST | Legacy completions |

## Switching Base URL

Only one line changes — the `base_url` / `baseUrl` property.

### Python

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:1234/v1"
)
# rest of your code unchanged
```

### TypeScript

```typescript
import OpenAI from 'openai';

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

### cURL

```bash
curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-identifier-from-lmstudio>",
    "messages": [{"role": "user", "content": "Say this is a test!"}],
    "temperature": 0.7
  }'
```

## Codex Support

LM Studio supports OpenAI Codex via the `POST /v1/responses` endpoint — the same one Codex targets.

## Key Takeaways

- **Drop-in replacement** — swap `base_url` to `http://localhost:1234/v1`; no other code changes needed
- **Five endpoints** — models, responses, chat/completions, embeddings, legacy completions
- **No API key required** by default (LM Studio runs locally)
- **Codex works** because LM Studio implements `/v1/responses`
- **Model IDs differ** — use the model identifier shown in LM Studio, not OpenAI slugs like `gpt-4o`
- For richer stats (token/s, TTFT, model lifecycle) use the [[wiki/claude-code/lmstudio-rest-api|native LM Studio REST API]] instead

## Related Articles

- [[wiki/claude-code/lmstudio-anthropic-compat|Anthropic Compat Endpoints]] — `/v1/messages` drop-in for Claude SDK
- [[wiki/claude-code/lmstudio-chat-completions|Chat Completions]] — full param reference for `/v1/chat/completions`
- [[wiki/claude-code/lmstudio-embeddings|Embeddings]] — `/v1/embeddings` for local RAG pipelines
- [[wiki/claude-code/lmstudio-rest-api|LM Studio REST API]] — native v1 API with extended model metadata
- [[wiki/claude-code/lmstudio-idle-ttl-auto-evict|Idle TTL & Auto-Evict]] — memory management for loaded models

## Sources

- [LM Studio OpenAI Compat Docs](https://lmstudio.ai/docs/developer/openai-compat) — raw/OpenAI Compatibility Endpoints.md
