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

- Method: `POST`
- Prompt template is applied automatically for chat‑tuned models
- Provide inference parameters (temperature, top\_p, etc.) in the payload
- See OpenAI docs: [https://platform.openai.com/docs/api-reference/chat](https://platform.openai.com/docs/api-reference/chat)
- Tip: keep a terminal open with [`lms log stream`](https://lmstudio.ai/docs/cli/serve/log-stream) to inspect model input

##### 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](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)