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.
| Parameter | Details |
|---|---|
| Compatibility | OpenAI Chat Completions schema; official openai SDKs work unchanged |
| Authentication | Bearer token in the Authorization header |
| Base URL | https://api.nsfwwriter.com/v1 |
| Model | uncensored |
| Methods | POST /v1/chat/completions · GET /v1/models |
| SSE streaming | Yes — server-sent events; the last chunk carries token usage |
| Structured output | response_format: {"type": "json_object"} |
| Completion length | prompt + completion fit within 100,000 tokens; max_tokens optional, no separate output cap |
| Sampling parameters | temperature, top_p, stop, seed, presence_penalty, frequency_penalty |
| Context window | 100,000 tokens (prompt + completion together) |
| Tools / tool calls | Yes — tools, tool_choice; replies carry tool_calls, also when streaming; send results back as role: tool |
| Rate limit | 300/min per key |
| Max body | 8 MB request body |
| Response headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Concurrency | up to 8 in parallel per key |
| Top-up | USDT (TRC20) or USDC (Base), any whole amount from $20 to $500 |
| Subscription | paid 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+ |
| Billing | pay 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-in | sign in with Google or with e-mail + password |
| Content | uncensored for adults; the only hard rule: no sexual content involving minors |
| Keys | one 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.
| Status | Type | Reason |
|---|---|---|
400 | bad_request | invalid JSON, empty messages, bad parameter, or a prompt longer than the window — fix and resend |
401 | missing_key · invalid_key · key_revoked | no key, wrong key, or a key replaced by a newer one |
402 | no_credit | balance is empty — top up, requests resume at once |
403 | content_blocked | refused by the content policy |
404 | not_found | only /v1/chat/completions and /v1/models exist |
413 | request_too_large | request body larger than 8 MB |
429 | rate_limited · concurrency | over 300/min or 8 parallel — back off and retry |
503 | upstream_busy | temporary 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.