EN ▾

Uncensored LLM API for developers

Get API key

Troubleshooting NSFW API Errors and Rate Limits

Developers often face hurdles when integrating uncensored chat endpoints into high-volume applications. This guide explains how to handle common error codes and manage rate limits effectively using our hosted service.

Developer workspace with holographic API interface showing code and token counters

Understanding Common Error Codes

When integrating our API, you will encounter specific HTTP status codes that indicate the state of your request. The most common errors are 401, 402, and 429. A 401 error means your API key is invalid or missing. This usually happens if you copy the key incorrectly during signup or if you are using a key from a different environment. Always verify your key immediately after creation, as it is shown only once on the dashboard.

A 402 error indicates that your account has no prepaid credit remaining. Since we do not offer a free unlimited tier, every request consumes tokens from your balance. Errors and refusals are free, but successful completions charge you. If you see a 402, you must top up your account using cryptocurrency to resume service. The trial credit of $0.50 is only available for new accounts and does not roll over.

A 429 error signals that you have hit the rate limit. Our service allows 300 requests per minute per key. If you exceed this, subsequent requests will be rejected until the window resets. This limit applies to the key, not the account, so using multiple keys can increase throughput but requires careful management. Always check your response headers for any rate limit information provided by the server.

To avoid these errors, implement reliable error handling in your code. Catch 401 errors by refreshing the key or checking your dashboard. Handle 402 errors by prompting the user to top up via crypto. For 429 errors, use exponential backoff to retry requests. This ensures your application remains stable even during peak usage times.

Managing Rate Limits Effectively

Rate limiting is important for maintaining stability when using our API. The limit is set at 300 requests per minute per key. This means you can send up to 300 distinct calls in a 60-second window. If you are building a bot or a high-volume generator, you might hit this limit quickly. It is important to distribute your load across multiple keys if you need higher throughput.

Implementing exponential backoff is the standard strategy for handling rate limits. When you receive a 429 error, wait for a short period, then retry. If the error persists, increase the wait time exponentially. This prevents your application from flooding the server with retries, which could exacerbate the issue. Most HTTP clients and SDKs have built-in support for exponential backoff, making it easy to integrate.

Monitoring your usage is also key. Keep track of how many requests you are making per minute. If you are consistently near the limit, consider optimizing your prompts to reduce token usage. Our API charges per token, so shorter prompts can help you stay within both rate and budget limits. You can also use the streaming mode to process responses faster, reducing the time each request holds up the connection.

Remember that the rate limit is per key, not per account. If you have multiple keys, you can split your traffic among them. However, each key still has its own 300 requests per minute limit. This allows you to scale your application by adding more keys, but you must manage each key's usage independently. Always check the official support pages for any updates to rate limit policies.

Optimizing Token Usage and Costs

Understanding how tokens are counted is essential for managing your budget. Our API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. The context window is 100,000 tokens, which includes both the prompt and the completion. This means you can send long prompts without worrying about immediate overages, but you must stay within the total limit.

To reduce costs, optimize your prompts for brevity. Use clear, concise instructions to minimize the number of input tokens. You can also use the stop parameter to halt generation early if the model produces unnecessary text. This can significantly reduce output token usage, which is more expensive than input tokens. Always test your prompts to find the right balance between detail and efficiency.

Use JSON mode when you need structured data from the model. This can help you parse responses more efficiently and reduce the need for additional processing. JSON mode also ensures that the model adheres to a specific format, which can improve reliability. You can enable JSON mode by setting the appropriate parameter in your request. This is particularly useful for applications that require consistent output formats.

Keep an eye on your token usage in the dashboard. You can see how many tokens you have used and how much credit remains. This helps you plan your top-ups and avoid unexpected 402 errors. Remember that prepaid credit never expires, so you can top up whenever it is convenient. Use the crypto top-up feature to add funds securely and efficiently.

Handling Streaming and JSON Modes

Streaming over SSE (Server-Sent Events) is a powerful feature for real-time applications. It allows you to receive parts of the response as they are generated, rather than waiting for the entire completion. This can improve the user experience by providing immediate feedback. Our API supports streaming, and you can access usage information in the last chunk of the stream. This helps you track token usage in real-time.

JSON mode is another valuable feature for developers who need structured data. By enabling JSON mode, you can ensure that the model outputs data in a specific format, such as a JSON object. This makes it easier to parse and use the response in your application. You can enable JSON mode by setting the appropriate parameter in your request. This is particularly useful for applications that require consistent output formats.

Function calling (tools) allows you to define custom functions that the model can call. This enables more complex interactions and decision-making within your application. You can define tools in your request, and the model will return calls to these tools when appropriate. This feature is useful for building agents that can perform actions based on user input.

Parameters like temperature, top_p, stop, and seed allow you to control the behavior of the model. Temperature affects the randomness of the output, while top_p controls the diversity of the tokens. The stop parameter allows you to define stop sequences, and the seed ensures reproducibility. Experiment with these parameters to find the best settings for your use case. Always refer to the API documentation for detailed information on each parameter.

When Our API Is Not the Right Choice

While our API is excellent for uncensored text generation, it may not be the right choice for every project. Our service is text-only, meaning it does not support image, audio, or video generation. If your application requires multimodal capabilities, you may need to combine our API with other services. For example, you can use our API to generate text and then use a separate service to create images based on that text.

Our API also does not offer embeddings, OCR, or fine-tuning. If you need to analyze images or train a custom model, you will need to use a different provider for those tasks. Our API is designed for chat-completions, so it is best suited for applications that rely on conversational AI. If you need advanced data processing features, consider using a more comprehensive AI platform.

Additionally, our API is hosted and does not support on-premises deployment. If you require data to stay within your own infrastructure, you may need to look for a provider that offers local deployment options. Our service is ideal for developers who want a simple, hosted solution for uncensored text generation. However, if data sovereignty is a critical requirement, you may need to explore other options.

Finally, our API is not suitable for applications that require real-time audio or video processing. Since we do not support multimedia generation, you will need to integrate with other services for those features. Our API is best used for text-based interactions, such as chatbots, content generation, and data extraction. Always evaluate your specific needs before choosing a provider.

Integrating with Other Tools and Frameworks

Integrating our API with other tools and frameworks can enhance your application's functionality. Our API is compatible with standard OpenAI-compatible clients, making it easy to use with popular libraries. You can use tools like LangChain or LlamaIndex to build complex workflows. These frameworks allow you to chain multiple API calls and manage state effectively.

For Discord bots, you can use our API to provide uncensored responses in your server. Many developers use our API to power chatbots that can handle a wide range of topics. You can integrate our API with Discord.js or other Discord libraries to create a smooth experience for your users. Remember to handle rate limits and errors appropriately to ensure smooth operation.

You can also use our API with web frameworks like Flask or Django. This allows you to build custom web applications that use our uncensored model. You can create endpoints that accept user input and return responses from our API. This is useful for building custom chat interfaces or content generation tools. Always test your integration thoroughly to ensure reliability.

Finally, consider using our API with data processing tools. You can use our API to generate text that can be analyzed by other tools. For example, you can use our API to generate summaries of long documents and then use a separate tool to extract key insights. This combination of tools can help you build powerful applications that use the strengths of each component.

Best Practices for Developers

Following best practices can help you get the most out of our API. Always use the latest version of the API endpoints. Our service supports POST /v1/chat/completions, POST /v1/responses, and GET /v1/models. Make sure your client is compatible with these endpoints. You can check the official documentation for the latest API specifications.

Use environment variables to store your API key. This prevents accidental exposure of your key in code repositories. Always keep your key secure and rotate it if you suspect it has been compromised. Our API allows you to generate new keys easily, so you can manage your security effectively.

Monitor your application's performance and error rates. Use logging to track successful and failed requests. This can help you identify issues early and optimize your integration. You can also use monitoring tools to track token usage and costs. This helps you stay within your budget and avoid unexpected charges.

Engage with the community to stay updated on best practices. Many developers share their experiences and tips on forums and social media. You can learn from others and improve your own integration. Always check the official support pages for any updates or changes to the API. This ensures that you are using the most current and reliable methods.

Frequently asked questions

Why am I getting a 401 error?

A 401 error means your API key is invalid or missing. Verify your key in the dashboard and ensure it is copied correctly. If the key is correct, try regenerating it.

How do I fix a 402 error?

A 402 error indicates no prepaid credit is available. Top up your account using USDT on TRC20 or USDC on Base. The minimum top-up is $20.

What is the rate limit?

The rate limit is 300 requests per minute per key. If you exceed this, you will receive a 429 error. Use exponential backoff to retry requests.

Does the API support image generation?

No, the API is text-only. It does not support image, audio, or video generation. You can use it for text-based tasks like chat and content generation.