EN ▾

Uncensored text API for your pipeline

Base URLhttps://api.sdxlapi.com/v1Modeluncensored
Get API key

Troubleshooting SDXL API: Safety & Common Errors

Developers often face challenges when integrating text-based APIs for image prompt generation, from unexpected token costs to connection drops. This guide addresses safety considerations and common troubleshooting steps to ensure stable usage.

Developer workspace with code and digital tokens illustrating API safety and troubleshooting

Understanding Rate Limits and Token Costs

When integrating our API, understanding rate limits is important for maintaining stable connections. Our service allows 300 requests per minute per key, which is generally sufficient for most development workflows. However, if you exceed this limit, you will receive a 429 error. This indicates that you have hit the rate limit, and you should implement exponential backoff in your client code to handle retries gracefully.

Token costs are another common concern for developers. Our API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. It is important to note that errors and refusals are free, so you only pay for actual token usage. This pricing model means that inefficient prompt design can lead to higher costs, so optimizing your prompts is essential.

Many users inquire about handling unexpected token costs in their applications. The best approach is to monitor your token usage closely and set up alerts if possible. Since prepaid credit is charged by real token usage, you can track your spending accurately. Errors do not incur charges, which helps in reducing unnecessary costs during testing phases.

Additionally, our API supports streaming over SSE, which can help manage token costs by providing usage information in the last chunk. This feature allows you to estimate costs more accurately during long-running requests. By understanding these limits and costs, you can design more efficient and cost-effective applications.

Common Errors and How to Resolve Them

One of the most common errors developers encounter is the 401 invalid key error. This typically occurs when the API key is missing, incorrect, or has been revoked. To resolve this, ensure that you are passing the correct key in the Authorization header. If you suspect the key is invalid, you can generate a new one immediately after signup.

Another frequent issue is the 402 no credit error, which indicates that your prepaid credit has been exhausted. Since we do not offer a subscription or monthly fee, you must top up your credit to continue using the API. You can top up using crypto only, specifically USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500.

Connection drops can also occur, especially when using streaming responses. If you experience intermittent disconnections, check your network stability and ensure that your client handles reconnection logic properly. Our API supports function calling and JSON mode, which can help in managing complex interactions more reliably.

Finally, the 429 rate limit error is a clear signal that you are sending too many requests too quickly. Implementing a retry mechanism with exponential backoff is the standard solution. This approach ensures that your application does not overwhelm the server and reduces the likelihood of hitting the rate limit repeatedly.

Safety Considerations and Content Limits

Safety is a key aspect of using our API, especially for applications that generate content for diverse audiences. Our model does not refuse lawful adult, fictional, security-research, or controversial topics, providing a truly uncensored experience. However, there is a hard content limit: no sexual content involving minors. Requests containing such content will be refused, ensuring a baseline of safety for all users.

Developers should be aware that while the model is uncensored, it is not without limits. The refusal of specific content types helps maintain a usable environment for a wide range of applications. It is important to design your application to handle these refusals gracefully, perhaps by notifying the user or retrying with a modified prompt.

Another safety consideration is the context window. Our API supports a context window of 100,000 tokens, which is quite generous for most use cases. However, if your application involves very long conversations or documents, you may need to implement chunking strategies to manage the context effectively. This ensures that the model can process the information accurately without exceeding the token limit.

Additionally, the API supports parameters like temperature, top_p, stop, seed, and penalties, which allow you to fine-tune the model's behavior. By adjusting these parameters, you can control the creativity and consistency of the generated text, which is important for maintaining safety and relevance in your application's output.

When Our API Is Not the Right Choice

While our API is powerful for text generation, it is not the right choice for every project. If your application requires image, audio, or video generation, our service will not meet your needs. We serve only one uncensored open-weight text model, so if you need multi-modal capabilities, you should look for a different solution.

Similarly, if you require embeddings, OCR, or fine-tuning, our API does not support these features. Our focus is on text-in, text-out interactions, so if your workflow involves processing images or training custom models, our service may not be suitable. In such cases, consider using our API for the text generation steps and integrating it with other tools that handle the specific capabilities you need.

Another scenario where our API might not be the right choice is if you need model routing. We do not offer the ability to switch between different models dynamically. If your application requires accessing multiple models with different strengths, you may need a more flexible solution that supports model routing.

Finally, if you are looking for a free unlimited tier, our API may not be the best fit. We offer a trial credit of $0.50 for new accounts, but ongoing usage requires prepaid credit. If your project has a very high volume of requests and a limited budget, you might find a different service more cost-effective. Always evaluate your specific needs before committing to a service.

Handling Streaming and Function Calling

Streaming is a powerful feature of our API, allowing you to receive responses in real-time. This is particularly useful for applications that require immediate feedback, such as chatbots or interactive tools. Our API supports streaming over SSE, and you can access usage information in the last chunk, which helps in managing resources efficiently.

Function calling is another key feature that enhances the utility of our API. By using tools, you can extend the capabilities of the model, allowing it to perform specific actions or retrieve data from external sources. This is especially useful for applications that need to interact with databases or other APIs, as it enables the model to make informed decisions based on real-time data.

JSON mode is also supported, which ensures that the output is structured and easy to parse. This is important for applications that need to process the generated text programmatically. By using JSON mode, you can ensure that the output is consistent and reliable, reducing the need for additional parsing logic in your application.

Parameters like temperature, top_p, stop, seed, and penalties allow you to fine-tune the model's behavior. For example, setting a specific seed ensures reproducibility, which is important for testing and debugging. By using these features, you can create more reliable and flexible applications that meet your specific requirements.

Top-Up and Payment Methods

Our API uses a prepaid credit system, which means you must top up your account to continue using the service. The top-up process is straightforward and supports crypto only. You can use USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500. This flexibility allows you to choose the cryptocurrency that best suits your needs.

One of the benefits of our payment system is the bonus credit available for larger top-ups. If you top up $50 or more, you receive a bonus of +5% to +15%. This bonus credit can help you stretch your budget further, making it more cost-effective to use the API for larger projects or higher volume applications.

It is important to note that we do not accept cards, PayPal, or bank transfers. If you prefer these payment methods, you may need to use a different service. However, for those who are comfortable with cryptocurrency, our top-up process is simple and efficient. You can top up any whole amount within the specified range, and the credit is added to your account immediately.

Errors and refusals are free, so you only pay for actual token usage. This means that you can test your application extensively without incurring significant costs. Once you are ready to go live, you can top up your credit and start using the API with confidence. The prepaid credit never expires, so you can use it whenever you need it.

Best Practices for Stable API Usage

To ensure stable API usage, it is essential to implement proper error handling and retry logic. As mentioned earlier, encountering a 429 rate limit error is common, and implementing exponential backoff is the standard solution. This approach helps prevent overwhelming the server and reduces the likelihood of hitting the rate limit repeatedly.

Another best practice is to optimize your prompts to minimize token usage. Since our API charges based on token count, efficient prompt design can lead to significant cost savings. Use clear and concise language, and avoid unnecessary information in your prompts. This not only reduces costs but also improves the quality of the generated text.

Monitoring your token usage is also important. By keeping track of your usage, you can identify patterns and optimize your application accordingly. Our API provides usage information in the last chunk of streaming responses, which can help you estimate costs accurately. Use this information to set up alerts and manage your budget effectively.

Finally, take advantage of the parameters available in our API to fine-tune the model's behavior. By adjusting temperature, top_p, stop, seed, and penalties, you can control the creativity and consistency of the generated text. This allows you to tailor the output to your specific needs, ensuring that your application performs as expected. Regularly test and adjust these parameters to find the optimal configuration for your use case.

Frequently asked questions

How do I handle rate limits in my application?

Implement exponential backoff in your client code to handle 429 rate limit errors gracefully. This ensures that you do not overwhelm the server and reduces the likelihood of hitting the limit repeatedly.

What happens if I run out of credit?

You will receive a 402 no credit error. You can top up your account using USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500. Bonus credit is available for top-ups of $50 or more.

Does the API support image generation?

No, our API serves only one uncensored open-weight text model. If you need image generation, you should look for a different solution that supports multi-modal capabilities.

Are errors charged to my account?

No, errors and refusals are free. You only pay for actual token usage, which means you can test your application extensively without incurring significant costs.