EN ▾
Get API key

NSFW API Documentation

Get started with the NSFW API by authenticating with your key and sending a request to the OpenAI-compatible chat endpoint. This guide covers the essential Python and Node.js integrations, streaming, and error handling for uncensored text generation.

Base URL and Authentication

The NSFW API uses a standard OpenAI-compatible base URL. To authenticate, include your API key in the Authorization header. You can generate a key immediately after signing up with Google or email on the Get API key page. Each account holds one active key; generating a new one replaces the old. Requests are limited to 300 per minute and 8 MB body size. Ensure your client library supports custom base URLs to point to https://api.nsfwapi.top/v1.

curl https://api.nsfwapi.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
  }'

First Request with Python

Use the official OpenAI Python SDK to interact with the uncensored LLM API. Set the base_url to our endpoint and provide your API key. The model identifier is uncensored. This model is open-weight and tuned for lawful adult content without refusals. You can send simple text prompts or complex system instructions. The response contains the generated text, token usage, and finish reasons. This approach works for most integration needs without extra dependencies.

from openai import OpenAI

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

Node.js Integration

For JavaScript environments, the Node SDK follows the same OpenAI-compatible pattern. Configure the base URL to our API endpoint and inject your authentication key. Call the chat completions endpoint with the uncensored model. This method is suitable for server-side applications or backend services. You can handle the response object to extract the generated content and monitor token consumption. The structure matches standard OpenAI responses, making it easy to swap or adapt existing code.

import OpenAI from "openai";

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

Streaming Responses

Enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream. Each chunk contains partial text and metadata. Token usage details are included in the final chunk. Streaming reduces perceived latency for long outputs. You must handle the stream events to accumulate the full response. This is ideal for chat interfaces where real-time text display is required.

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)

Parameters: Temperature, Top P, Seed

Control the model's output variability using standard parameters. temperature adjusts randomness; higher values produce more creative text. top_p limits sampling to the top probability mass. Use seed for reproducible outputs. These parameters affect how the uncensored model generates content. Experiment with these values to balance coherence and creativity. The model supports max_tokens to limit output length; if unspecified, the response can run to the end of the window.

Limits, Errors, and Context Window

The API enforces strict limits: 300 requests per minute and 8 concurrent requests per key. The context window is 100,000 tokens total, with no separate output cap. Errors include 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. Credit is prepaid via crypto and never expires. Errors do not consume tokens. If you exceed limits, your requests will be rejected until the window resets. Monitor your usage via the response headers or token counts in the JSON output.

Under the hood: specs

Before you integrate, here is exactly what you get with a key.

ParameterDetails
ProtocolOpenAI Chat Completions schema; official openai SDKs work unchanged
Modeluncensored
AuthenticationBearer token in the Authorization header
Base URLhttps://api.nsfwapi.top/v1
MethodsPOST /v1/chat/completions · GET /v1/models
Tools / tool callsYes — tools, tool_choice; replies carry tool_calls, also when streaming; send results back as role: tool
Structured outputJSON object mode via response_format json_object
SSE streamingSupported (stream: true), usage included at the end
Context window100,000 tokens, input and output combined
Completion lengthup to the rest of the 100,000-token window; max_tokens optional (no separate cap)
Other parameterstemperature, top_p, stop, seed and the two penalties are passed through
Max bodyup to 8 MB per request
HeadersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Requests per minute300/min per key
Concurrencyup to 8 in parallel per key
Token prices$0.15 per 1M input tokens · $0.50 per 1M output tokens
Trial credit$0.50 for 7 days, no card · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up
How you paypay as you go from prepaid credit; nothing is charged for failed or refused requests
Subscriptionno monthly fee; paid credit does not expire
PaymentUSDT (TRC20) or USDC (Base), any whole amount from $20 to $500
Volume bonus+5% on $50+, +10% on $100+, +15% on $200+
Contentadult content allowed; sexual content involving minors is refused
AccountGoogle or e-mail and password
Keysone active key per account; a new key replaces the old one

Error reference

Every error is JSON with a type you can switch on. You are never charged for an error.

HTTPTypeWhat to do
400bad_requestmalformed request or too long for the context window
401missing_key · invalid_key · key_revokedcheck the Authorization header or use your current key
402no_creditbalance is empty — top up, requests resume at once
403content_blockedsexual content involving minors — refused, not billed
404not_foundonly /v1/chat/completions and /v1/models exist
413request_too_largerequest body larger than 8 MB
429rate_limited · concurrencyover 300/min or 8 parallel — back off and retry
503upstream_busytemporary overload, retry shortly

Questions and answers

How do I get API credit?

Credit is topped up using crypto only, specifically USDT (TRC20) or USDC (Base). Minimum top-up is $20, and credit never expires. Errors and refusals do not consume your credit.

What is the context window size?

The context window is 100,000 tokens for prompt and completion combined. There is no separate output cap, and if you do not set max_tokens, the response can run to the end of the window.

Can I use this for chat applications?

Yes, the API is designed for chat workflows. It supports streaming, function calling, and JSON mode. It is an uncensored text generation API suitable for adult content workflows.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key