EN ▾
Get API key

NSFW WriterNSFW Writer API Quickstart Guide

NSFW Writer API Quickstart Guide

Get started with the NSFW Writer API in minutes. This uncensored AI API lets you integrate unrestricted LLM capabilities into your chatbots and roleplay apps with a single base URL change.

Authentication & Headers

The NSFW Writer API follows the standard OpenAI-compatible protocol. You authenticate by passing your API key in the Authorization header as a Bearer token. You can generate your key instantly by signing up with Google or an email address on the Get API key page. Your key is the only credential needed to access the uncensored LLM hosted on our infrastructure.

  • Header: Authorization: Bearer YOUR_API_KEY
  • Base URL: https://api.nsfwwriter.com/v1

This setup ensures compatibility with any OpenAI SDK or HTTP client. You do not need to modify your authentication logic, just swap the base URL and inject your new key. The API key is unique to your account, and you can regenerate it if needed.

Sending Your First Request

Start by sending a simple chat completion request to the /v1/chat/completions endpoint. The model ID is uncensored. This model is tuned to answer without content refusals for lawful adult use, making it ideal for NSFW chatbots and roleplay scenarios.

Below is a basic cURL example demonstrating a standard text generation request.

curl https://api.nsfwwriter.com/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."}]
  }'

The response will contain the generated text in the choices[0].message.content field. You can adjust parameters like temperature and top_p to control creativity. Remember that the total context window is 100,000 tokens, combining both prompt and completion.

SDK Examples

Integrating the NSFW Writer API is straightforward with your preferred language. The Python SDK handles the underlying HTTP requests efficiently, allowing you to focus on your application logic. Use the official openai package, pointing it to our base URL.

from openai import OpenAI

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

For JavaScript developers, the Node.js SDK provides similar ease of use. Ensure you pass the correct apiKey and baseURL to initialize the client. This ensures all requests are routed to the uncensored model hosted on our servers. The SDK handles retries and JSON parsing automatically.

import OpenAI from "openai";

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

Handling Streaming Responses

For real-time chat experiences, enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream, delivering tokens as they are generated. This reduces perceived latency significantly for users.

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)

Token usage statistics are included in the final chunk of the stream. This allows you to track costs accurately without storing the entire response in memory. Streaming works with all parameters, including function calling and JSON mode, providing a consistent developer experience regardless of the response type.

Function Calling & JSON Mode

The uncensored AI API supports advanced features like function calling and strict JSON output. Use response_format: {"type": "json_object"} to enforce structured data, which is useful for game logic or data extraction. You can also define tools for dynamic actions.

Function calling allows the model to return structured arguments for your custom functions. This is particularly useful for NSFW character AI writers that need to manage inventory, stats, or scene transitions. The model will respect the tool definitions provided in the request, ensuring reliable integration with your backend logic.

Rate Limits & Error Handling

Understand the limits to build a robust application. You are allowed 300 requests per minute per key and 8 concurrent requests. The request body must not exceed 8 MB. If you exceed these limits, you will receive a 429 Too Many Requests error.

Other common errors include 401 for an invalid or missing API key, and 402 if your prepaid credit is exhausted. Errors do not consume your tokens, so you can retry safely. Note that the model blocks sexual content involving minors, which will return a refusal response. Credit never expires, so you can top up whenever needed.

Capabilities and limits

One table with every limit, feature and price that applies to your key.

ParameterDetails
CompatibilityOpenAI Chat Completions schema; official openai SDKs work unchanged
AuthenticationBearer token in the Authorization header
Base URLhttps://api.nsfwwriter.com/v1
Modeluncensored
MethodsPOST /v1/chat/completions · GET /v1/models
SSE streamingYes — server-sent events; the last chunk carries token usage
Structured outputresponse_format: {"type": "json_object"}
Completion lengthprompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap
Sampling parameterstemperature, top_p, stop, seed, presence_penalty, frequency_penalty
Context window100,000 tokens (prompt + completion together)
Tools / tool callsYes — tools, tool_choice; replies carry tool_calls, also when streaming; send results back as role: tool
Rate limit300/min per key
Max body8 MB request body
Response headersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Concurrencyup to 8 in parallel per key
Top-upUSDT (TRC20) or USDC (Base), any whole amount from $20 to $500
Subscriptionpaid credit never expires, no subscription
Price$0.15 per 1M input tokens · $0.50 per 1M output tokens
Volume bonus+5% on $50+, +10% on $100+, +15% on $200+
Billingpay as you go from prepaid credit; nothing is charged for failed or refused requests
Free trial$0.50 for 7 days, no card · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up
Sign-insign in with Google or with e-mail + password
Contentuncensored for adults; the only hard rule: no sexual content involving minors
Keysone key per account, regenerate any time (the old one stops working)

HTTP errors

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

StatusTypeReason
400bad_requestinvalid JSON, empty messages, bad parameter, or a prompt longer than the window — fix and resend
401missing_key · invalid_key · key_revokedno key, wrong key, or a key replaced by a newer one
402no_creditbalance is empty — top up, requests resume at once
403content_blockedrefused by the content policy
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

Does the NSFW Writer API use GPT-4 or other major models?

No. The API serves a dedicated open-weight model tuned for uncensored responses. It is not GPT, Claude, Gemini, or any other vendor's model. It runs on our own servers and is specifically optimized for adult content generation without refusals.

How do I top up my credit?

Top-ups are crypto-only, accepting USDT (TRC20) or USDC (Base). You can add any whole amount from $20 to $500. Credits never expire, and you receive bonuses for larger amounts: +5% from $50, +10% from $100, +15% from $200.

What is the context window size?

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

Your key is one form away

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

Get API keyRead the docs

Get API keynsfwwriter.comuncensoreden