| title |
aliases |
tags |
sources |
created |
updated |
| LM Studio — Embeddings Endpoint |
| lmstudio-embeddings |
| lm-studio-embeddings |
| local-embeddings |
|
| lmstudio |
| embeddings |
| openai-compat |
| local-llm |
| vectors |
|
|
2026-04-30 |
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
Python Example
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
Sources