EN ▾
gptnsfw.cc
GptNsfw
Get API key

Integration guide for uncensored completions

Drop your uncensored LLM into any OpenAI-compatible client by swapping the base URL and API key. This guide covers the exact integration steps for Python, Node, and streaming responses without model refusals.

Prerequisites: SDK installation and environment variables

Install the official SDK for your language and export your credentials before making requests. You need an API key from our portal and the standard library for your chosen runtime. This ensures your code can authenticate against our endpoints immediately.

  • Python: pip install openai
  • Node.js: npm install openai
  • Export OPENAI_API_KEY with your key from the dashboard.

from openai import OpenAI

client = OpenAI(base_url="https://api.gptnsfw.cc/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)

Configuring the base_url and API key

Point your client to our dedicated endpoint to bypass standard model restrictions. Set the base_url to https://api.gptnsfw.cc/v1 and use the key you generated. This single change directs traffic to our uncensored infrastructure.

  • Base URL: https://api.gptnsfw.cc/v1
  • Model ID: uncensored

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.gptnsfw.cc/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);

Making your first POST /v1/chat/completions request

Send a standard completion request with your system and user prompts. The model returns text responses without the usual content filters for lawful adult topics. Use the uncensored model ID in your payload.

curl https://api.gptnsfw.cc/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Return the full API response for the /v1/messages endpoint"}]
  }'

Handling streaming responses (SSE) and token usage

Stream tokens as they generate using Server-Sent Events for real-time output. The final chunk contains the total token usage for your request. This approach reduces perceived latency for long-form roleplay or story generation.

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)

Enforcing JSON mode for structured data outputs

Force the model to output valid JSON by setting response_format to {"type": "json_object"}. This is critical when parsing structured data or feeding results into other applications. The model adheres to this format strictly without adding conversational filler.

Configuring temperature, top_p, and stop sequences

Adjust temperature and top_p to control creativity or determinism in your outputs. Use stop sequences to halt generation at specific markers. These parameters give you precise control over the uncensored chatbot's behavior.

Support & FAQs

Why am I getting a 401 or 429 error?

A 401 error means your API key is invalid or expired. A 429 error indicates you have hit the rate limit of 300 requests per minute or the concurrent request cap of 8 per key. Generate a new key or wait for the window to reset.

What is the context window and cost?

The context window is 100,000 tokens for prompt and completion combined. You pay $0.15 per 1M input tokens and $0.50 per 1M output tokens. Errors are free, and credit never expires.

Is this the official GPT NSFW API?

No, this is an independent service running a dedicated open-weight model. We are not affiliated with OpenAI or other major vendors. We provide an openai compatible API that works with standard client code.

Retrieve your API key

Register an account, copy the key, and update your base URL. That is the entire configuration.

Get API key