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

1.8 KiB
Raw Blame History

title source author published created description tags
Chat Completions https://lmstudio.ai/docs/developer/openai-compat/chat-completions 2026-04-30 Send a chat history and get the assistant's response.
clippings

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

Python example
from openai import OpenAI
client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")

completion = client.chat.completions.create(
  model="model-identifier",
  messages=[
    {"role": "system", "content": "Always answer in rhymes."},
    {"role": "user", "content": "Introduce yourself."}
  ],
  temperature=0.7,
)

print(completion.choices[0].message)

Supported payload parameters

See https://platform.openai.com/docs/api-reference/chat/create for parameter semantics.

model
top_p
top_k
messages
temperature
max_tokens
stream
stop
presence_penalty
frequency_penalty
logit_bias
repeat_penalty
seed
```[OpenAI Compatibility Endpoints](https://lmstudio.ai/docs/developer/openai-compat)

[

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

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

Completions (Legacy)

Text completion for base models (legacy OpenAI endpoint).

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