obsidian/raw/_processed/Embeddings.md
2026-04-30 14:27:25 +01:00

1.1 KiB

title source author published created description tags
Embeddings https://lmstudio.ai/docs/developer/openai-compat/embeddings 2026-04-30 Generate embedding vectors from input text.
clippings

Generate embedding vectors from input text.

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."))
```[Completions (Legacy)](https://lmstudio.ai/docs/developer/openai-compat/completions)

[

Text completion for base models (legacy OpenAI endpoint).

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

List Models

List available models via the OpenAI-compatible endpoint.

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