Integrating a Text Moderation API with Python
Developers often struggle to balance content safety with creative freedom in LLM applications. This guide walks you through integrating a reliable, uncensored text API using Python, ensuring your pipeline handles both standard requests and edge cases efficiently.

Setting Up Your API Credentials
Before you can send any requests, you need to establish your identity with the service. Our API uses a simple API key system that you receive immediately after signing up. You can create an account by continuing with Google or using an email and password combination. Once registered, the system displays your key right away, allowing you to start testing without waiting for email verification.
It is important to keep this key secure, as it acts as your sole identifier for billing and usage tracking. The key is tied to your prepaid credit, which is charged based on real token usage. Errors and refusals do not consume credit, so you can test your integration freely without worrying about unexpected costs.
To begin coding, store your key in an environment variable or a secure configuration file. This practice prevents accidental exposure in version control systems. When making requests, include this key in the Authorization header. The base URL for all endpoints is https://api.contentmoderationapis.com/v1. This uniform structure ensures that if you are sending chat completions or checking model details, you are connecting to the correct service.
Remember that our API is uncensored, meaning it does not refuse lawful adult, fictional, security-research, or controversial topics. This makes it ideal for developers who want full control over the output without predefined safety filters interfering with the model's responses. Always verify your key works by sending a simple test request before building complex logic.
Understanding Endpoints and Methods
The core of our API revolves around three main endpoints. The POST /v1/chat/completions endpoint is your primary tool for generating text. It accepts a standard OpenAI-compatible format, making it easy to integrate with existing libraries. You send a JSON payload containing your messages, and the API returns the model's response. The model ID you must specify is always "uncensored".
For more modern interactions, you can use the POST /v1/responses endpoint. This endpoint follows the newer response format, which may offer better performance or different streaming behaviors depending on your client library. It is designed for developers who prefer the latest API standards. Both endpoints handle text input and return text output, maintaining a simple and predictable data flow.
Finally, the GET /v1/models endpoint allows you to verify the available models. This is useful for debugging or checking if the service is online. You do not need to route between different models, as there is only one uncensored text model available. This simplicity reduces complexity in your codebase, as you do not need to manage model selection logic.
Keep in mind that this service does not support embeddings, image generation, audio, video, OCR, fine-tuning, or model routing. If your application requires these features, you will need to integrate additional services. For now, focus on mastering the text generation endpoints to build a reliable moderation layer.
Configuring Parameters for Control
Our API offers several parameters to fine-tune the behavior of the uncensored model. You can adjust the temperature to control randomness, with lower values producing more deterministic outputs. The top_p parameter allows you to limit the diversity of tokens, while stop sequences let you define specific strings that terminate the response. These tools give you precise control over the generation process.
For applications requiring structured data, JSON mode is available. This ensures the model outputs valid JSON, which is essential for parsing responses in your Python code. You can also set a seed for reproducible results, which is useful for testing and debugging. The penalty parameters allow you to adjust frequency and presence penalties, helping to reduce repetitive or biased outputs.
Streaming is supported over Server-Sent Events (SSE), allowing you to receive tokens as they are generated. This improves the perceived performance of your application, especially for long responses. The usage information is included in the last chunk, so you can track token consumption in real-time. This is particularly useful for monitoring your prepaid credit balance.
When integrating these parameters, ensure your Python client handles the JSON responses correctly. Use libraries like requests or httpx to manage the HTTP connections. Always validate the response structure before processing the text. This prevents errors when the model returns unexpected formats or empty responses.
Handling Errors and Rate Limits
Reliable error handling is critical for any API integration. Our API returns specific HTTP status codes to help you diagnose issues. A 401 error indicates an invalid or missing API key. A 402 error means you have insufficient prepaid credit to complete the request. A 429 error signals that you have exceeded the rate limit of 300 requests per minute per key.
To handle these errors, implement retry logic in your Python code. For 429 errors, wait for a short period before retrying, as the limit is per key and resets quickly. For 402 errors, you will need to top up your credit. Our API accepts crypto payments only, specifically USDT on TRC20 or USDC on Base. You can top up any whole amount between $20 and $500.
It is important to note that errors and refusals are free. This means you do not lose credit if the model refuses a request or if your request fails due to network issues. This policy protects your budget during the development and testing phases. Always log these errors to monitor the health of your integration.
When implementing retries, avoid infinite loops. Set a maximum number of attempts and a timeout duration. This ensures your application does not hang indefinitely if the API is experiencing issues. Use exponential backoff strategies to reduce the load on the server during high traffic periods.
When This API Is Not the Right Choice
While our API is excellent for text generation and moderation, it may not be the right choice for every project. If your application requires image generation, audio processing, or video analysis, you will need a different solution. Our service focuses solely on text input and output, so any multimodal features must be handled by separate tools.
Similarly, if you need fine-tuning capabilities to customize the model for your specific domain, this API does not offer that feature. You would need to use a different provider that supports fine-tuning. Additionally, if you require model routing to switch between different models based on the task, our single-model approach may be limiting.
Another consideration is the payment method. Our API accepts only crypto payments, specifically USDT on TRC20 or USDC on Base. If your organization prefers traditional payment methods like credit cards, PayPal, or bank transfers, this service might not align with your financial workflows. You must be comfortable managing crypto wallets to top up your credit.
Finally, if you need an SLA guarantee or certifications like SOC2 or HIPAA, our service does not currently offer these. We are an independent service that focuses on providing uncensored text generation without the overhead of enterprise-grade compliance. For applications with strict regulatory requirements, you may need to evaluate other providers that offer these certifications.
Addressing Community Questions on Guardrails
Developers often discuss the need for small, fast guardrail models for LLM input moderation. Threads on r/LLMDevs and r/LocalLLaMA highlight the demand for models that can detect 14 types of unsafe content quickly. These discussions emphasize the importance of real-time inference and low latency in moderation pipelines.
Our API addresses this need by providing a straightforward text moderation solution. While it does not use a separate guardrail model, the uncensored model itself can be configured to handle moderation tasks. By setting appropriate parameters and using the JSON mode, you can structure the output to include moderation flags.
Users in these communities appreciate the focus on real-time performance. Our API supports streaming over SSE, which allows you to process tokens as they arrive. This reduces the delay between input and output, making it suitable for applications that require immediate feedback. The 300 requests per minute limit ensures that your moderation layer can handle moderate traffic without significant delays.
When integrating a guardrail, consider how it fits into your existing pipeline. You might use our API to generate the initial response and then pass it through a separate guardrail model for final validation. This hybrid approach combines the flexibility of our uncensored model with the specificity of dedicated moderation tools. Always test your integration thoroughly to ensure it meets your latency and accuracy requirements.
Estimating Costs and Budgeting
Understanding the cost structure is essential for managing your API usage. Our API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. These rates apply to prepaid credit, which is charged based on real token usage. Errors and refusals are free, so you do not pay for failed requests.
To estimate your costs, you need to calculate the token count of your inputs and outputs. The context window is 100,000 tokens, which includes both the prompt and the completion. This is a generous limit that allows for long conversations or large documents. You can monitor your token usage through the streaming responses, which include usage information in the last chunk.
When budgeting, consider the variability in token usage. Some requests may generate long responses, while others may be short. It is helpful to set up alerts for high usage or to regularly check your credit balance. You can top up your credit with any whole amount between $20 and $500, and the credit never expires.
For developers who want to optimize costs, consider using the JSON mode to reduce unnecessary text in the output. You can also adjust the temperature and top_p parameters to control the length and diversity of the responses. By fine-tuning these settings, you can balance quality and cost effectively. Always review your usage patterns to identify opportunities for optimization.
Frequently asked questions
How do I sign up for the API?
You can sign up by continuing with Google or using an email and password. Your API key is displayed immediately after registration, allowing you to start using the service right away.
What payment methods are accepted?
The API accepts only crypto payments. You can top up your credit using USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500.
Does the API support streaming?
Yes, the API supports streaming over Server-Sent Events (SSE). You can receive tokens as they are generated, and usage information is included in the last chunk of the response.
What happens if I run out of credit?
If you run out of credit, you will receive a 402 error. You can top up your credit at any time using crypto. Errors and refusals are free, so you do not lose credit for failed requests.
More guides
- What Is JSON Mode in an LLM API and How to Use It
- LangChain init_chat_model with an OpenAI-Compatible API
- OpenAI Moderation API Pricing vs a Token-Priced LLM
- Speech to Text API: Troubleshooting Common Mistakes
- How to Calculate Content Moderation API Costs
- Choosing a Guardrail for Real-Time Toxicity Detection