EN ▾
Get API key

Uncensored API billing for developers

per 1M input tokens
$0.15
Output tokens / 1M
$0.50
token context
100,000
trial credit
$0.50
requests per minute
300

NSFW Detection API: Integration Guide

An NSFW detection API helps you automatically classify text content as safe or unsafe before it reaches your users. By integrating a dedicated detection layer, you can reduce moderation costs, improve user experience, and maintain content standards at scale without manual review.

NSFW Detection API: Integration Guide

Updated:

Key points

  • NSFW detection APIs automate content classification, reducing manual moderation overhead.
  • Using an LLM-based approach allows for nuanced understanding of context and slang.
  • Prepaid billing models offer predictable costs for high-volume detection pipelines.
  • Crypto payments and token-based usage provide transparency and flexibility for developers.

Why Use an NSFW Detection API?

Content moderation is a critical component of any platform dealing with user-generated text. If you are running a social network, a forum, or a chat application, ensuring that content adheres to your community guidelines is essential. An NSFW detection API automates this process, analyzing text in real-time to identify inappropriate material. This automation reduces the need for large human moderation teams, lowering operational costs and increasing speed.

Traditional keyword-based filters often struggle with context, missing nuanced violations or flagging safe content incorrectly. Modern detection APIs use large language models (LLMs) to understand the subtleties of language, including slang, irony, and cultural references. This results in higher accuracy and fewer false positives. By integrating an API, you ensure consistent moderation standards across your entire platform, regardless of traffic volume. The API handles the heavy lifting of analysis, allowing your team to focus on handling edge cases and improving user experience.

Choosing the Right Detection Model

Not all detection models are created equal. When selecting a model for your NSFW detection pipeline, consider factors like accuracy, speed, and cost. Open-weight models offer flexibility, allowing you to fine-tune the model for your specific domain. Proprietary models may offer out-of-the-box accuracy but often come with higher per-token costs and less transparency.

For text-based detection, the model's ability to understand context is essential. A model that simply flags keywords like "sex" may miss contextually appropriate uses. Look for models that have been trained on diverse datasets and can distinguish between different types of NSFW content, such as sexual content, violence, or hate speech. Additionally, consider the model's context window. A larger context window allows the model to analyze longer texts or conversations, providing a more comprehensive assessment. Evaluate the model's latency to ensure it fits within your application's performance requirements. Some models may be slower but more accurate, while others prioritize speed with slightly lower precision.

Step 1: Get Your LTX NSFW Key

To start using the LTX NSFW API, you need an API key. The signup process is designed for speed and simplicity. You can sign up using your Google account or by creating a standard email and password account. No phone number verification is required, making the onboarding process frictionless.

  • Visit the "Get API key" page on ltxnsfw.cc.
  • Choose your preferred sign-in method: Google or email/password.
  • Upon registration, your API key is displayed immediately. Copy and store it securely.

Each account is limited to one active API key. If you generate a new key, the old one is replaced. This ensures security and simplifies key management. The LTX NSFW API is an OpenAI-compatible service, meaning you can use existing SDKs and client libraries that are designed for OpenAI's API structure. This compatibility reduces the learning curve and integration time for developers already familiar with OpenAI's ecosystem.

Step 2: Configure Your Client

Configuring your client involves setting the correct base URL and API key. The LTX NSFW API uses the standard OpenAI-compatible endpoint structure. This means you can use libraries like openai for Python or the official OpenAI SDK for Node.js with minimal changes.

Set the base URL to https://api.ltxnsfw.cc/v1. This URL directs your requests to the LTX NSFW servers. Ensure you pass your API key in the authorization header as Authorization: Bearer YOUR_API_KEY. The API supports standard parameters like model, messages, temperature, and max_tokens. For detection tasks, you might set temperature to 0 to ensure consistent, deterministic outputs. The API key you obtained in Step 1 is used to authenticate these requests. Remember to keep your API key secure and avoid exposing it in client-side code if possible.

Step 3: Sending Prompts

Once your client is configured, you can start sending prompts. The API accepts POST requests to /v1/chat/completions. You need to structure your request with a system message that defines the detection task and user messages containing the text to be analyzed.

For example, your system message might instruct the model to classify the text as "safe", "nsfw_sexual", "nsfw_violence", or "other". The user message contains the actual text content. You can send single or multiple messages in a conversation format, allowing the model to consider context if needed. The API supports streaming responses via Server-Sent Events (SSE), which is useful for real-time applications where you want to display partial results as they are generated. For batch processing, you might prefer non-streaming responses to process the entire response at once. The context window is 100,000 tokens, allowing for extensive input texts.

Step 4: Processing Responses

When you receive a response from the API, it will contain the model's classification of the text. The response structure follows the standard OpenAI format, including fields like choices and message. You should parse the content field to extract the classification label.

Implement logic in your application to handle different classification results. For example, if the text is classified as "nsfw_sexual", you might hide it from public view, flag it for human review, or apply a warning label. The API provides token usage information in the response, which is important for monitoring your credit consumption. Each token counts towards your prepaid balance. The API is transparent about token usage, allowing you to track costs accurately. Errors in processing do not consume credits, ensuring you only pay for valid completions.

Step 5: Handling Refusals

Even with an "uncensored" model, there are hard limits. The LTX NSFW API refuses requests containing sexual content involving minors. This is a strict policy applied to all requests. If your input text contains such content, the API will return a refusal response. It's important to handle these refusals gracefully in your application. Check the response status and content to detect refusals.

Refusals do not consume your prepaid credit. This is a key benefit of the LTX NSFW billing model. You only pay for successful token usage. If you encounter a refusal, you can log it for analysis or adjust your pre-filtering logic to catch such content before sending it to the API. This can save API calls and reduce latency. Understanding the refusal criteria helps in designing solid detection pipelines that account for both model limitations and hard policy constraints.

Optimizing Token Costs

The LTX NSFW API uses a prepaid credit model with transparent token-based pricing. Input tokens cost $0.15 per million tokens, and output tokens cost $0.50 per million tokens. This pricing structure is competitive for high-volume detection tasks. To optimize costs, consider the length of your input texts. Trimming unnecessary whitespace or redundant text can reduce input token counts.

Use streaming responses only when necessary. Non-streaming responses are more efficient for batch processing. Monitor your token usage regularly to avoid unexpected credit depletion. The API supports crypto top-ups with USDT (TRC20) or USDC (Base), with bonus credits for larger deposits. This flexibility allows you to manage your budget effectively. Since errors are free, you can experiment with different prompts or models without worrying about wasted credits. The prepaid model ensures no monthly fees, making it ideal for variable workloads.

Questions and answers

Is the LTX NSFW API an official OpenAI product?

No, it is an independent, hosted service that is compatible with the OpenAI API format. It uses its own uncensored open-weight model, not GPT-4 or other OpenAI models. You can use it with OpenAI SDKs by changing the base URL.

How do I pay for the API?

Payments are made via crypto top-ups using USDT (TRC20) or USDC (Base). You can top up any whole amount from $20 to $500. Credits are prepaid and never expire. No credit cards or PayPal are accepted for direct payment.

Does the API charge for errors or refusals?

No, you only pay for successful token usage. Errors and refusals (such as hard content blocks) do not consume your prepaid credit. This makes it cost-effective for testing and high-volume pipelines.

What is the context window size?

The context window is 100,000 tokens, which includes both the prompt and the completion. There is no separate output cap. This allows for analyzing long texts or conversations in a single request.

Your key is one form away

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

Get API key
$0.50
trial credit