Chat completions

Create a model response from a list of messages.

POST/v1/chat/completions

Parameters

NameTypeRequiredDescription
modelstringYesA model ID returned by the models endpoint.
messagesarrayYesConversation messages with a role and content.
streambooleanNoSet to true for server-sent events.
temperaturenumberNoSampling temperature supported by the model.
max_tokensintegerNoOutput budget, within the provider's model limits.
toolsarrayNoFunctions 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.

JSON · example response
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help?"
      },
      "finish_reason": "stop"
    }
  ]
}

Example request

Python
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.