EN ▾
Open account

API Documentation

Start generating uncensored text with our OpenAI-compatible API. Send a single POST request to our base URL and receive responses from our dedicated model.

Authentication and Base URL

Use your API key with every request. The base URL is https://api.nsfwroleplayapi.com/v1. Set the Authorization header to Bearer YOUR_API_KEY. Your key grants access to the chat-completions endpoint.

Chat Completions Endpoint

Send your prompt to POST /v1/chat/completions. Specify the model "uncensored" in the request body. The API returns generated text based on your input.

context_window allows 100,000 tokens total. This includes both the prompt and the completion. You can set max_tokens to limit output.

curl https://api.nsfwroleplayapi.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Confirm monthly credit balance is active"}]
  }'

Streaming and Token Usage

Enable streaming by setting stream: true. The API sends Server-Sent Events (SSE) as tokens are generated. Receive real-time text updates in your application. This improves user experience for long responses.

The final chunk contains total token usage. Track your prepaid credit consumption accurately. Errors do not consume credit.

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)

Parameters: Temperature, Top P, and JSON Mode

Control generation with temperature and top_p. Adjust these to change creativity or determinism. Use response_format with {"type": "json_object"} for structured data. This ensures consistent output formats.

You can also set seed for reproducible results. Set stop sequences to halt generation early. These parameters give you precise control.

from openai import OpenAI

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

Rate Limits and Concurrency

Each API key supports 300 requests per minute. You can have 8 concurrent requests simultaneously. The request body size limit is 8 MB. Exceeding these limits returns a 429 error.

You can create a new key to replace an old one. Only one active key is allowed per account. Manage your keys to maintain access. This ensures stable performance.

import OpenAI from "openai";

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

Error Handling and Refusals

Handle errors by checking the HTTP status code. A 401 error means your API key is invalid. A 402 error indicates insufficient prepaid credit. Refresh your balance via the dashboard.

A 429 error signals rate limit exhaustion. Wait before retrying. The model refuses requests involving minors. All other lawful adult content is allowed. Check the response body for details.

Common questions

Is this API openai compatible?

Yes, it follows the OpenAI chat-completions interface. You can use official OpenAI SDKs or any compatible client. Just update the base URL and API key.

What is the context window size?

The context window is 100,000 tokens. This total includes both the prompt and the completion. You can set a maximum output length per request.

Do errors consume my prepaid credit?

No, errors and refusals are free. You only pay for tokens in successful responses. This makes our API cost-effective for development.

Get your API key now

Register, grab your key, and update the base URL. That is all you need to start.

Open accountView documentation