EN ▾

API Documentation

Get your API key and start sending requests immediately. This guide covers the essential endpoints, authentication, and code samples for integrating our uncensored LLM into your application.

Authentication and Base URL

The base URL is HTTPS://api.nsfwcom.com/v1. Append your API key to the Authorization header as a bearer token. This header authenticates every request sent to the endpoint.

  • Include your key in every request.
  • Keep your key secure and do not share it publicly.

Generate your key via the dashboard and start integrating immediately.

Chat Completions Endpoint

Send a POST request to /v1/chat/completions with your messages and model name. The API returns text completions based on your prompt.

curl https://api.nsfwcom.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List the top five benefits of remote work for engineers"}]
  }'

Use the model ID uncensored to ensure consistent, unfiltered outputs for your use case. Configure parameters like temperature to control creativity.

Python SDK

Use the official OpenAI Python library to interact with the API easily. Set the base URL to our endpoint and provide your API key.

from openai import OpenAI

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

This approach lets you leverage familiar SDK methods for chat completions. You can pass lists of messages and receive structured text responses directly in your Python scripts.

Node SDK

Install the OpenAI Node.js package and configure it with our base URL. This allows you to integrate the API into your JavaScript or TypeScript projects seamlessly.

import OpenAI from "openai";

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

Define your messages array and call the completion endpoint. The SDK handles the HTTP requests and parsing, returning the generated text for your application logic.

Streaming Responses via SSE

Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) for real-time token delivery.

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)

Parse the stream to display tokens as they generate. This improves user experience by showing progress instantly. The final chunk contains the total token usage for billing.

Limits, Errors, and Context

The context window supports 100,000 tokens total. Monitor your request limits to avoid service interruptions. Common errors include 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits.

Refunds are not issued for consumed credit. Errors during processing do not consume tokens. Use these codes to handle failures gracefully in your application.

Common questions

How do I get started with the nsfw.com API?

Sign up via Google or email to receive your API key instantly. Add crypto credit to your account and send your first request using the provided code samples.

What happens if I run out of credit?

Requests will return a 402 error until you top up. Credit never expires, so you can add funds whenever you are ready to continue using the service.

Does the API support streaming?

Yes, set the stream parameter to true to receive Server-Sent Events. This allows you to display tokens as they are generated for a faster user experience.

Secure your API key

Register an account, retrieve your key, and update your base URL. Setup takes seconds.