ko ▾
Start now

OpenAI-Compatible API Documentation

Get started with our uncensored LLM API in minutes using standard OpenAI-compatible tools. Send text, receive text, and handle streaming responses with predictable token pricing.

Authentication & Base URL

Authentication relies on a single API key passed in the Authorization header. You generate this key instantly via Google or email on the signup page, with no phone number required. The base URL for all requests is https://api.glmnsfw.com/v1.

This endpoint works with any OpenAI SDK by simply changing the base_url variable. Your key grants access to one active key per account; generating a new key replaces the old one immediately. Keep your key secure, as it identifies your prepaid credit balance.

Chat Completions Endpoint

Send text prompts and receive completions via a standard POST request to /v1/chat/completions. The model identifier is always uncensored, which runs on our own servers and is tuned for adult content without unexpected refusals.

  • Input: JSON array of message objects.
  • Output: Standard chat completion response with usage stats.

Errors like 402 indicate insufficient prepaid credit, while 401 means your key is invalid. Every request consumes tokens from your balance, but failed requests due to server errors do not charge you.

curl https://api.glmnsfw.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Set up the proxy server on port 8080"}]
  }'

Streaming Responses (SSE)

Enable streaming by setting stream: true in your request body. The API returns Server-Sent Events (SSE) chunks, allowing you to display text as it generates. This is crucial for chatbot interfaces where latency matters.

Each chunk contains partial content. The final chunk includes the total token usage for the request. You can parse these events to build a responsive user experience without waiting for the full response to complete.

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Function Calling & Tools

Support for function calling allows your application to define tools that the model can invoke. Pass a tools array in the request and specify tool_choice to control behavior. The model returns tool calls in the response, which you can then execute.

This feature works alongside the standard chat interface. You can mix text prompts with structured tool definitions. Use this to integrate your uncensored LLM into existing workflows that rely on structured data extraction or action triggering.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.glmnsfw.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

JSON Mode & Parameters

Force structured output by setting response_format to {"type": "json_object"}. This ensures the model returns valid JSON, which is essential for programmatic integration. You can also control randomness with temperature and top_p.

Additional parameters like stop, seed, presence_penalty, and frequency_penalty are supported. Adjust these to fine-tune the model's behavior for your specific use case, whether it's creative writing or precise data extraction.

from openai import OpenAI

client = OpenAI(base_url="https://api.glmnsfw.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Model Information & Limits

The model supports a 100,000 token context window for both input and output combined. The maximum output per request is 16,000 tokens, or 2,048 if max_tokens is not set. Rate limits are 300 requests per minute and 8 concurrent requests per key.

Request bodies are limited to 8 MB. The 429 error indicates you have exceeded these limits. There is no fine-tuning or embedding endpoint; this is a dedicated text completion API. Credit never expires, so you can pause usage and resume later.

FAQ

What is the base URL for the glm NSFW API?

The base URL is HTTPS://api.glmnsfw.com/v1. This endpoint is OpenAI-compatible, meaning you can use it with standard SDKs by updating the base URL configuration. It supports chat completions with the model ID "uncensored".

How do I handle streaming responses in my app?

Set <code>stream: true</code> in your request body to receive Server-Sent Events (SSE). Each chunk contains partial text, and the final chunk includes token usage statistics. This allows for low-latency display of generated content in chat interfaces.

What happens if I hit the rate limit?

You will receive a <code>429</code> status code. The limit is 300 requests per minute and 8 concurrent requests per key. If you exceed this, wait briefly before retrying or consider distributing requests across multiple keys if your account allows it.

Get your API key

Sign up, retrieve your key, and update your base URL. Setup is that simple.

Start now