EN ▾
Get API key

Integrating Uncensored Text API: SDK Setup & Error Handling

Connecting to an uncensored text API requires careful setup to ensure reliable communication with the model. This guide walks through the essential steps for initializing your client, configuring the correct model endpoint, and handling common errors like rate limits and invalid keys.

Developer workspace with laptop and digital elements illustrating API integration

Initializing the API Client

Start by configuring your development environment with the correct base URL and authentication credentials. Our API uses a standard OpenAI-compatible structure, which means you can likely use existing SDKs with minimal changes. The base URL for all requests is https://api.uncensoredaiimage.com/v1. You will need to generate an API key during signup, which is shown immediately after you create an account via Google or email.

When initializing the client, ensure you pass your key in the Authorization header. This key is unique to your account and allows you to access the model. Remember that your key is the only way to authenticate your requests, so keep it secure. The service does not require a subscription or monthly fee, so your access is tied directly to your prepaid credit balance.

It is important to verify that your client library supports the version of the API you are using. Since our API is compatible with the OpenAI chat completions format, most modern SDKs should work out of the box. However, always check the documentation for your specific SDK to ensure it handles streaming and JSON modes correctly.

Once initialized, you can test the connection by making a simple request to the models endpoint. This confirms that your key is valid and that you have credit available. If the request fails, check for common issues like incorrect key formatting or network connectivity problems.

Configuring the Model Endpoint

The core of your integration involves sending requests to the correct model endpoint. For our service, the model ID you must send is 'uncensored'. This ensures that you are interacting with the specific open-weight text model we host. The endpoint for chat completions is POST /v1/chat/completions. This endpoint accepts text input and returns text output, making it suitable for a wide range of conversational and generative tasks.

When constructing your request, include the model ID in the payload. This tells the API which model to use for generating the response. Since we only host one model, this ID is fixed. However, it is good practice to explicitly set it to avoid any ambiguity, especially if you are using a SDK that defaults to a different model.

The API also supports a POST /v1/responses endpoint and a GET /v1/models endpoint. The models endpoint allows you to verify the available models, while the responses endpoint can be used for specific response formats. Stick to the chat completions endpoint for standard text generation tasks.

Ensure that your requests include the necessary parameters such as temperature, top_p, and stop sequences. These parameters allow you to control the creativity and format of the output. By correctly configuring the model endpoint and parameters, you can tailor the API's behavior to fit your specific use case.

Handling Authentication and Credit Errors

Understanding error codes is important for a smooth integration. The API returns a 401 error if the API key is invalid or missing. This usually indicates a typo in your key or that the key has been revoked. A 402 error signifies that you have no credit left. Since the service is prepaid, you must top up your account to continue making requests. Errors and refusals are free, so you won't be charged for failed requests.

To handle these errors, implement logic in your application to check the status code of the response. If you receive a 401, prompt the user to re-enter their API key or check their account settings. If you receive a 402, notify the user that their credit has run out and guide them to the top-up page.

Top-ups can be done using crypto only, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. You can also receive bonus credit when topping up $50 or more. These bonuses range from +5% to +15%, providing extra value for larger purchases.

Always handle these errors gracefully in your application. Display clear messages to the user and provide options for resolution. This improves the user experience and reduces frustration when issues arise. By proactively managing authentication and credit errors, you ensure that your application remains reliable and responsive.

Managing Rate Limits and Performance

The API enforces a rate limit of 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. This limit is designed to ensure fair usage and maintain service stability. It is important to monitor your request rate, especially if you are processing large volumes of data or have multiple users accessing the API simultaneously.

To handle rate limits effectively, implement exponential backoff in your application. This means that if you receive a 429 error, wait for a short period before retrying the request, and increase the wait time with each subsequent failure. This approach helps to prevent overwhelming the API and reduces the likelihood of hitting the limit again.

Consider batching your requests if possible. Instead of sending individual requests for each item, group them together and send them in batches. This can help you stay within the rate limit while still processing your data efficiently. Additionally, you can use the streaming feature to receive responses in real-time, which can improve the perceived performance of your application.

Keep an eye on your token usage as well. The API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. By optimizing your prompts and managing your token count, you can control your costs and ensure that your credit lasts longer. Use the context window of 100,000 tokens to your advantage by including relevant information in your prompts.

When This API Is Not the Right Choice

While our API is powerful for text generation, it may not be the right choice for every project. If your application requires image, audio, or video generation, this text-only API will not suffice. We do not offer embeddings, OCR, or fine-tuning capabilities. If you need to process images or extract text from them, you will need a different solution.

Additionally, if you require model routing or the ability to switch between different models, our API may not meet your needs. We host only one uncensored open-weight text model. If you need to experiment with different models or switch between them based on performance, you will need a more flexible solution.

For projects that demand high availability with specific SLA guarantees, our service may not be the best fit. We do not claim specific SLA percentages or certifications like SOC2 or HIPAA. If your business relies on strict uptime guarantees, you may need to consider other providers.

Finally, if you need to deploy the model on-premises or in a private cloud, our hosted service may not be suitable. We offer a hosted solution, so you do not have control over the underlying infrastructure. If you require full control over the deployment environment, you might want to look into open-source models that you can host yourself.

Addressing Common Developer Questions

Developers often ask about the nature of uncensored AI and how it differs from standard models. In discussions on Reddit, users frequently mention that uncensored AIs can be 'extremely horny' because they are trained on data from the internet, including content from sites like Archive of Our Own. This means the AI may produce more adult-oriented content, but it does not mean it is purely adult-oriented.

Another common question is whether uncensored AI can act as an ally. Users note that AI has biases from the data it is fed, and since the internet can be prejudiced, the AI may reflect those biases. However, uncensored models can also reason freely without guardrails, which can be beneficial for certain applications.

Some developers are looking for AI that is unfiltered but not necessarily adult-oriented. They want a model that can reason freely without 'hall monitor' behavior. Our API provides this flexibility, allowing you to generate content that is not constrained by strict safety filters, while still maintaining technical advanced capabilities.

There is also discussion about the demand for open, uncensored AI and the lack of progress in model decentralization. Users point out that while there is demand, the market is often dominated by large companies. Our service offers an independent alternative, allowing developers to access uncensored text generation without relying on major tech giants.

Best Practices for Integration

To ensure a successful integration, follow these best practices. First, always use the correct model ID 'uncensored' to avoid any confusion. Second, handle errors gracefully, especially rate limits and credit issues. Third, optimize your prompts to manage token usage and costs effectively.

Use the streaming feature to provide a better user experience. Streaming allows you to receive responses in real-time, which can make your application feel more responsive. This is particularly useful for chat applications where users expect immediate feedback.

Test your integration thoroughly before deploying to production. Use the trial credit of $0.50 to test your setup without risking your main credit. This allows you to verify that your client is working correctly and that you can handle errors appropriately.

Keep your API key secure and avoid hardcoding it in your source code. Use environment variables or a secure configuration file to store your key. This helps prevent unauthorized access to your account and ensures that your credit is used only by your application.

Frequently asked questions

How do I top up my credit?

You can top up your credit using USDT on TRC20 or USDC on Base. The minimum amount is $20, and the maximum is $500. You can receive a bonus of +5% to +15% when topping up $50 or more.

What happens if I run out of credit?

If you run out of credit, you will receive a 402 error. You can continue to make requests, but they will not be processed until you top up your account. Errors and refusals are free, so you won't be charged for failed requests.

Can I use this API for image generation?

No, this API is text-only. It does not support image, audio, or video generation. If you need image generation, you will need to use a different service or combine this API with an image API.

What is the context window size?

The context window is 100,000 tokens, which includes both the prompt and the completion. This allows you to process large amounts of text in a single request.