Integrate the NSFW Chatbot API

Get started with the NSFW Chatbot API by sending a simple request to our uncensored LLM API endpoint. This guide covers the base URL, authentication, and integration patterns for Python and Node.js.

Base URL and Authentication

The NSFW Chatbot API is fully compatible with the OpenAI API format. To begin, direct your client requests to the base URL: https://api.nsfwchatbot.top/v1. This ensures your existing OpenAI SDKs and HTTP clients work without modification, provided you update the base URL.

Authentication is handled via an API key passed in the Authorization header. You receive this key immediately after signing up via Google or email. Keep this key secure, as it is the only credential needed for your API NSFW requests. The model identifier for all requests is uncensored.

Your First Request

Test the integration with a simple prompt. The following example demonstrates a standard chat completion request using the uncensored ai api endpoint. Replace YOUR_API_KEY with the key from your dashboard.

This request sends a prompt to the model and returns a text response. The model is tuned to answer without content refusals for lawful adult use, making it suitable for various creative and technical applications.

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

If you receive a response, your integration is successful. Check the usage field to see token consumption for billing purposes.

Python SDK Integration

Using the official OpenAI Python library simplifies the process. Configure the client to point to our base URL and provide your API key. This approach leverages familiar patterns for developers already using OpenAI-compatible services.

The code below initializes the client and sends a message. Ensure you have the openai package installed. This method is reliable for synchronous operations where you wait for the full response before proceeding.

from openai import OpenAI

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

Remember that the context window is 64,000 tokens for the entire conversation (prompt + completion). Manage your history carefully to stay within this limit.

Node.js SDK Integration

For JavaScript and TypeScript developers, the OpenAI Node SDK works seamlessly. Configure the baseUrl and apiKey properties to match our infrastructure. This allows you to integrate the unrestricted ai api into your web applications or backend services.

The following snippet demonstrates a basic chat completion call. Handle the response to extract the generated text. This synchronous approach is straightforward for server-side rendering or API endpoints.

import OpenAI from "openai";

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

Ensure your environment supports the required Node.js version for the SDK you are using. The API key should be stored in environment variables for security.

Streaming Responses

For applications requiring real-time text generation, enable streaming by setting stream: true. The API returns data as Server-Sent Events (SSE). Each chunk contains a partial response, allowing you to display text as it is generated.

Token usage statistics are included in the final chunk of the stream. This ensures you can track costs accurately even during streaming operations. Handle the stream events to update your UI progressively.

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)

Streaming is ideal for chat interfaces where latency matters. It provides a smoother user experience compared to waiting for the entire response.

Limits, Errors, and Context

Your API key is limited to 300 requests per minute and 8 concurrent requests. If you exceed these limits, you will receive a 429 rate limit error. Request bodies must not exceed 8 MB. The context window is 64,000 tokens total, with a max output of 16,000 tokens per request.

Error handling is critical. A 401 error indicates an invalid or missing API key. A 402 error means your prepaid credit is exhausted. Since billing is per-token, errors during processing are free, but you must top up to continue.

Use JSON mode (response_format: {"type": "json_object"}) for structured outputs. If you need image generation, refer to our separate guide, as this API handles text only. Credit never expires, so you can top up when convenient.

Questions and answers

What is the context window size?

The context window is 64,000 tokens, covering both the prompt and the completion. The maximum output per request is 16,000 tokens, or 2,048 if max_tokens is not set.

How are errors billed?

Errors and refusals are free. You are only charged for tokens successfully processed. If you receive a 402 error, your credit is exhausted, and you need to top up.

Can I use this API for commercial projects?

Yes, the uncensored llm api is designed for developers building applications. There are no subscription fees, and prepaid credit does not expire, making it cost-efficient for any scale.

Your key is one form away

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

Get API key