Chat completions
Create a model response from a list of messages.
POST/v1/chat/completions
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A model ID returned by the models endpoint. |
messages | array | Yes | Conversation messages with a role and content. |
stream | boolean | No | Set to true for server-sent events. |
temperature | number | No | Sampling temperature supported by the model. |
max_tokens | integer | No | Output budget, within the provider's model limits. |
tools | array | No | Functions your application makes available. |
Response format
A successful response follows the OpenAI-compatible chat-completion shape. Additional usage and policy fields depend on the gateway and provider.
{
"id": "chatcmpl_example",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help?"
},
"finish_reason": "stop"
}
]
}Example request
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.unrefused.com/v1",
)
response = client.chat.completions.create(
model="glm-5.3-uncensored",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)Streaming
Set stream: true and consume the response as a stream. See the streaming guide.
Availability depends on your connected provider. Check service status and keep x-request-id with your diagnostics.