EN ▾
Get API key

NSFW API Quickstart Guide

Start with a small scene-planning request. This guide covers the base URL, authentication and Chat Completions messages, then streaming and error handling for a text-based roleplay client.

Authentication and Base URL

Our API is OpenAI-compatible, so you can use existing SDKs with minimal changes. The base URL is https://api.nsfwapihub.com/v1. You must include your API key in the Authorization header as a Bearer token. Get your key from the dashboard after signing up with just an email. The key is shown immediately and can be regenerated anytime, which revokes the old one.

Eligible new accounts can request a $0.50 trial for 7 days, subject to verification and processing. Paid credit does not expire. Top-ups range from $20 to $500. Keep your key server-side; anyone with it can spend account credit.

First Request

Send a standard chat completion request to test your setup. Use the model ID uncensored to access our open-weight model tuned for adult content. The API accepts text input and returns text output. It does not support embeddings, images, or audio. Ensure your request body stays under 8 MB. This is a pure text completion API optimized for narrative and roleplay contexts.

The response includes generated text and token usage. Check both before using the result: validate scene details, handle refusals and record token counts for cost estimates.

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

Python SDK Integration

Use the official OpenAI Python library to integrate quickly. Set the base_url and api_key in your client configuration. The rest of the syntax mirrors the standard OpenAI chat completions endpoint. This approach works for both synchronous and asynchronous applications. It is the most straightforward way to add an uncensored AI API to your Python backend.

Remember that the model ID is uncensored, not gpt-4 or similar. The API supports tool calling, so you can define functions in your system prompt or tools array. This allows for structured outputs or integration with external systems. The context window is 100,000 tokens, allowing for long conversations or large documents.

from openai import OpenAI

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

Node SDK Integration

For JavaScript or TypeScript projects, the OpenAI Node SDK works directly. Configure the client with the base_url pointing to our API and provide your API key. This ensures compatibility with existing codebases that already use OpenAI-compatible services. You can switch between different providers easily by changing just these two configuration values.

Send the user and assistant messages needed for the next step of the scene. Inspect the generated reply for changed characters or events. Handle rate limits, insufficient credit, incomplete streams and refusals in your client.

import OpenAI from "openai";

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

Streaming Responses

For a better user experience, use Server-Sent Events (SSE) to stream the response. This allows your application to display text as it is generated, reducing perceived latency. Set the stream parameter to true in your request. The API will return a stream of chunks, each containing a portion of the completion.

Process these chunks in your client-side code or backend proxy to build the final message. Streaming is supported by most OpenAI-compatible SDKs. This feature is essential for chat applications where users expect real-time interaction. The uncensored model generates text efficiently, making streaming a smooth experience for end-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)

Rate Limits, Errors, and Context

You are limited to 300 requests per minute per API key. If you exceed this, you will receive a 429 Too Many Requests error. Requests are also limited to 8 MB in body size. If your key is invalid, you get a 401 Unauthorized error. If you run out of credits, you get a 402 Payment Required error. Refill your balance via the dashboard to continue using the service.

The context window is 100,000 tokens, including both the prompt and the completion. This allows for extensive conversation history or large input texts. The model is not GPT, Claude, or any other vendor's model; it is a distinct open-weight model. Ensure your application handles these limits and errors appropriately to maintain a smooth user experience.

Technical specifications

A quick checklist for developers: format, limits, features, billing.

SpecValue
CompatibilityOpenAI-compatible: any OpenAI SDK or client works — change the base URL and the key
Base URLhttps://api.nsfwapihub.com/v1
MethodsPOST /v1/chat/completions · GET /v1/models
API keyBearer token in the Authorization header
Model IDuncensored
SSE streamingYes — server-sent events; the last chunk carries token usage
Function callingYes — tools, tool_choice; replies carry tool_calls, also when streaming; send results back as role: tool
JSON modeJSON object mode via response_format json_object
Context window100,000 tokens (prompt + completion together)
Completion lengthup to the rest of the 100,000-token window; max_tokens optional (no separate cap)
Other parameterstemperature, top_p, stop, seed, presence_penalty, frequency_penalty
Request size8 MB request body
Response headersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Rate limit300/min per key
Concurrency8 requests at the same time per key
Top-upcrypto: USDT on TRON or USDC on Base, $20–$500, any whole sum
Free trial$0.50 of credit valid 7 days, no card needed · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up
How you payprepaid credit, charged by real token usage; errors and refusals are free
Volume bonus+5% from $50, +10% from $100, +15% from $200
Price$0.15 per 1M input tokens · $0.50 per 1M output tokens
Credit expirypaid credit never expires, no subscription
Keysone key per account, regenerate any time (the old one stops working)
Content policyuncensored for adults; the only hard rule: no sexual content involving minors
Sign-insign in with Google or with e-mail + password

Errors and what to do

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

StatusTypeReason
400bad_requestmalformed request or too long for the context window
401missing_key · invalid_key · key_revokedno key, wrong key, or a key replaced by a newer one
402no_creditout of credit; add credit and retry
403content_blockedrefused by the content policy
404not_foundunknown endpoint
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

Is this API truly uncensored?

You can submit fictional adult-character tasks within the service’s rules. The model may still refuse or return unsuitable text. Your application must review output; sexual content involving minors is prohibited.

Do I need a credit card for the trial?

No. You only need an email and a password to sign up. You receive $0.50 in trial credit valid for 7 days without providing payment details. Claim this credit with one click on your API key page.

What is the context window size?

The context window is 100,000 tokens, covering both the input prompt and the output completion. This allows for long conversations or large document processing.

Your key is one form away

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

Get API key