---
title: "LM Studio — Embeddings Endpoint"
aliases: [lmstudio-embeddings, lm-studio-embeddings, local-embeddings]
tags: [lmstudio, embeddings, openai-compat, local-llm, vectors]
sources: [raw/Embeddings.md]
created: 2026-04-30
updated: 2026-04-30
---

# LM Studio — Embeddings Endpoint

LM Studio exposes an OpenAI-compatible `/v1/embeddings` endpoint for generating dense vector representations of text. Drop-in compatible with the `openai` Python SDK.

## Endpoint

- **Method:** `POST /v1/embeddings`
- **Base URL:** `http://localhost:1234/v1`
- **API key:** any non-empty string (e.g. `"lm-studio"`)
- **Spec:** mirrors [OpenAI Embeddings API](https://platform.openai.com/docs/api-reference/embeddings)

## Python Example

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")

def get_embedding(text, model="model-identifier"):
    text = text.replace("\n", " ")
    return client.embeddings.create(input=[text], model=model).data[0].embedding

print(get_embedding("Once upon a time, there was a cat."))
```

- Replace `"model-identifier"` with the name of an embedding model loaded in LM Studio
- Newlines are stripped before embedding — standard preprocessing step
- Returns a flat Python list of floats (`data[0].embedding`)

## Usage Notes

- Must have an embedding model loaded in LM Studio (not a chat model)
- Common embedding models: `nomic-embed-text`, `text-embedding-3-small` clones, `all-MiniLM-L6-v2`
- The `model` param must match the identifier shown in LM Studio's loaded models list
- Batch inputs: pass multiple strings in the `input` list for efficiency

## Key Takeaways

- LM Studio's `/v1/embeddings` is a drop-in OpenAI replacement — zero code changes beyond `base_url` and `api_key`
- Use any non-empty string as the API key; auth is not enforced locally
- Strip newlines before embedding for cleaner vectors
- Return value is `response.data[0].embedding` — a list of floats
- Pair with a vector store (FAISS, Chroma, pgvector) to build a fully local RAG pipeline

## Related Articles

- [[wiki/claude-code/lmstudio-anthropic-compat|LM Studio — Anthropic Compat]] — redirect Claude Code / Anthropic SDK to local LM Studio
- [[wiki/claude-code/lmstudio-chat-completions|LM Studio — Chat Completions]] — `/v1/chat/completions` with full param list
- [[wiki/architecture/rag-pattern|RAG Pattern]] — retrieval-augmented generation using embeddings

## Sources

- `raw/Embeddings.md` — clipped from https://lmstudio.ai/docs/developer/openai-compat/embeddings
