Back to guides

The API, at your fingertips.

Endpoints, examples and the fields you need. Keep your OpenAI-compatible client and connect it to Uncensured AI.

POST/v1/chat/completions

Generate a response

Send the conversation in messages and select the model by its exact ID. These examples use GLM 5.3 Flash.

Install the openai package and set UNCENSURED_API_KEY as shown in the quickstart.

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://uncensuredai.com/v1",
    api_key=os.environ["UNCENSURED_API_KEY"],
)

response = client.chat.completions.create(
    model="glm-5.3-flash-abliterated",
    messages=[{"role": "user", "content": "Scrivi un breve saluto in italiano."}],
    reasoning_effort="low",
    max_tokens=4096,
)

print(response.choices[0].message.content)

The fields in the example

FieldHow to use it
modelAn exact model ID returned by GET /v1/models for your key.
messagesA list of messages, each with role and content.
max_tokensThe output budget, which can include reasoning tokens. The example uses 4096.
reasoning_effortA level supported by the selected model. GLM Flash uses low in this example.
streamSet to true to receive the response in successive chunks.

OpenAI compatibility refers to Chat Completions. Images, tools, context limits and reasoning options depend on the model and client.

Read the response

The generated text is in choices[0].message.content. Check finish_reason to understand how generation ended and usage for the reported token counts.

Python · after the request
print(response.choices[0].message.content)
print(response.choices[0].finish_reason)
print(response.usage)
POST/v1/chat/completions

Display text as it arrives

Reuse the client from the Python example and enable streaming. Each event may contain only part of the response.

Python · streaming
stream = client.chat.completions.create(
    model="glm-5.3-flash-abliterated",
    messages=[{"role": "user", "content": "Ciao!"}],
    reasoning_effort="low",
    max_tokens=4096,
    stream=True,
)

for chunk in stream:
    if chunk.choices:
        text = chunk.choices[0].delta.content
        if text:
            print(text, end="", flush=True)
print()

Some events have no text. Check choices and delta.content before displaying a chunk.

GET/v1/models

Find the models available to your key

Reuse the Python client to list model IDs. This checks the connection without generating a reply.

Python · models
models = client.models.list()
for model in models.data:
    print(model.id)

Availability comes from your authenticated model list. The public capabilities catalogue separately describes confirmed limits and reasoning settings.

Open the model capabilities catalogue
A request did not go through?Find the error and the next step

Uncensured AI

Loading...