Text API quickstart
Integrate the wan nsfw text API into your pipeline with this quickstart. Use the uncensored model to generate scripts, captions, or prompts for your media workflows without content refusals.
Authentication & Base URL
Start by visiting the Get API key page and signing in with Google or your email. Your key appears immediately; no phone number is required. The API key authenticates your requests to the base URL: https://api.wannsfw.top/v1. This endpoint is compatible with official OpenAI SDKs and any standard client. You only need one active key per account. If you generate a new key, the old one is replaced. Keep your key secure. It grants access to the uncensored model for all your text generation needs.
Sending Requests with uncensored Model
Send a POST request to /v1/chat/completions. Specify the model ID as uncensored. This model is open-weight and tuned to answer without content refusals for lawful adult use. It is not GPT, Claude, or any other vendor model. The API accepts standard parameters like temperature, top_p, and stop. Use this endpoint for prompt engineering, script generation, or captioning. It serves as the logic layer for your pipelines. Remember, this is a text-only API. It does not generate images, audio, or video. Use it to prepare the text inputs for those media generators.
curl https://api.wannsfw.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."}]
}'
Python SDK Integration
Use the official OpenAI Python library for a clean integration. Set the base URL and API key in your client configuration. This approach works seamlessly with our endpoint. You can stream responses or retrieve full text in one go. The client handles tokenization and request formatting for you. This is the recommended way to integrate the text API into your backend services. It simplifies error handling and response parsing. Ensure you handle the max_tokens parameter correctly, as it is optional and, if not specified, the response can run to the end of the window.
from openai import OpenAI
client = OpenAI(base_url="https://api.wannsfw.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 SDK Implementation
For JavaScript or TypeScript environments, use the openai npm package. Configure the client with your API key and the base URL. This allows you to integrate the wan nsfw API directly into your Node.js applications. You can make synchronous or asynchronous calls to the chat completions endpoint. This is ideal for serverless functions or web backends. The SDK abstracts the HTTP details, letting you focus on the prompt logic. Remember that the uncensored model handles context windows up to 100,000 tokens. Use this to process long scripts or detailed prompts for your media pipelines.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.wannsfw.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 (SSE)
Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE). Each chunk contains a fragment of the generated text. The final chunk includes the token usage statistics. This reduces perceived latency for your users. Streaming is essential for real-time applications. It allows you to display text as it is generated. Use this for chat interfaces or live captioning. Note that errors may interrupt the stream. Handle connection drops gracefully in your client code. The streaming feature works with all SDKs and raw HTTP clients.
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)
JSON Mode for Structured Data
Force the model to output valid JSON by setting response_format to {"type": "json_object"}. This is useful for extracting structured data from text or generating configuration objects. The uncensored model adheres to this format reliably. Use it to parse script metadata or generate prompt templates. JSON mode ensures your downstream parsers receive consistent input. This reduces the need for additional validation layers. It is particularly effective when combined with function calling. You can define complex schemas and get precise outputs. This feature enhances the utility of the text API for automated workflows.
Function Calling Support
Define tools in your request to enable function calling. The model can invoke these functions based on the user's input. This allows for interactive workflows and data retrieval. Specify the function name, description, and parameters. The API returns the function call details. You can then execute the function and send the result back to the model. This creates a loop of interaction. Use this for complex logic in your pipelines. It supports multiple tools and choices. The uncensored model handles tool definitions effectively. This feature expands the API's utility beyond simple text generation.
Parameters: Temperature, Top P, and Seed
Control the creativity of the output with temperature. Lower values make the output more deterministic. Higher values increase randomness. Use top_p to control the nucleus sampling. This limits the model to the most likely tokens. Set seed for reproducible results. This is useful for testing and debugging. These parameters work together to fine-tune the output. Adjust them based on your use case. For script generation, a moderate temperature might work best. For code extraction, a lower temperature is preferable. Experiment to find the right balance for your pipeline.
Limits, Errors, and Context Window
The API has a 100,000 token context window. There is no separate output cap, and if max_tokens is unset, the response can run to the end of the window. You are limited to 300 requests per minute and 8 concurrent requests per key. Request bodies must be under 8 MB. Errors return standard HTTP codes: 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. Errors and refusals do not consume credit. Your prepaid credit never expires. Use these limits to plan your pipeline scaling. Monitor your usage to avoid interruptions. The 8 concurrent limit ensures fair usage for all users.
Specs at a glance
Use this table to decide whether the API fits your project before you buy credit.
| Item | Value |
|---|---|
| Protocol | OpenAI-compatible: any OpenAI SDK or client works — change the base URL and the key |
| Model ID | uncensored |
| Authentication | Authorization: Bearer YOUR_KEY |
| Base URL | https://api.wannsfw.top/v1 |
| Methods | POST /v1/chat/completions · GET /v1/models |
| Completion length | up to the rest of the 100,000-token window; max_tokens optional (no separate cap) |
| Sampling parameters | temperature, top_p, stop, seed and the two penalties are passed through |
| Context window | 100,000 tokens (prompt + completion together) |
| Streaming | Yes — server-sent events; the last chunk carries token usage |
| Function calling | Supported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages |
| JSON mode | response_format: {"type": "json_object"} |
| Request size | 8 MB request body |
| Response headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Rate limit | 300 requests per minute per key |
| Parallel requests | 8 requests at the same time per key |
| Billing | prepaid credit, charged by real token usage; errors and refusals are free |
| Token prices | input $0.15 / 1M tokens, output $0.50 / 1M 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 |
| Volume bonus | +5% on $50+, +10% on $100+, +15% on $200+ |
| Top-up | crypto: USDT on TRON or USDC on Base, $20–$500, any whole sum |
| Subscription | no monthly fee; paid credit does not expire |
| Keys | one key per account, regenerate any time (the old one stops working) |
| Sign-in | sign in with Google or with e-mail + password |
| Content policy | adult content allowed; sexual content involving minors is refused |
Error codes
Errors come back as JSON with a stable type; failed and refused requests are not billed.
| HTTP | Type | What to do |
|---|---|---|
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 | sexual content involving minors — refused, not billed |
404 | not_found | unknown endpoint |
413 | request_too_large | body over 8 MB |
429 | rate_limited · concurrency | over 300/min or 8 parallel — back off and retry |
503 | upstream_busy | model busy — retry in a few seconds |
Questions and answers
What is the context window size?
The context window is 100,000 tokens, including both the prompt and the completion. There is no separate output cap, and if you do not specify the max_tokens parameter the response can run to the end of the window.
How do I handle streaming responses?
Set the stream parameter to true in your request. The API returns Server-Sent Events (SSE). Each chunk contains a fragment of the text, and the final chunk includes token usage statistics.
What happens if I exceed the rate limit?
You will receive a 429 Too Many Requests error. The limit is 300 requests per minute and 8 concurrent requests per key. Errors and refusals do not count against your rate limit.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.