EN ▾
Uncensored Imageuncensoredimage.cc
Get API key

Integrating Uncensored Image API with Python Scripts

Many developers seek a reliable way to automate NSFW image generation using standard OpenAI-compatible clients. This guide shows how to configure your Python environment to communicate with our uncensored text API, ensuring your scripts can drive image generation pipelines effectively.

Laptop screen showing Python code for API integration with floating digital tokens

Setting Up Your Python Environment

Before you can send any requests, you need to establish a connection to our service. The first step is obtaining your API key. When you sign up using Google or an email and password, the key is shown immediately. You must copy this key and store it securely in your Python environment variables. This key is the only credential needed for authentication, and it is tied to your prepaid credit balance.

Next, you need to install the standard OpenAI Python library. This library is widely used and supports the OpenAI-compatible protocol that our API follows. By using this familiar library, you can use existing code snippets and documentation. The library handles the HTTP requests, headers, and response parsing for you. You do not need to learn a new SDK or protocol from scratch.

You should also set the base URL to point to our specific endpoint. The base URL is https://api.uncensoredimage.cc/v1 . This tells the library where to send your requests. Without this configuration, the library will default to the standard OpenAI servers, and your requests will fail. Ensure that your environment variable for the API key is set correctly before running any scripts.

Finally, verify that your Python version is compatible with the library. Most modern Python versions work well. You can test the connection by making a simple request to the models endpoint. This will confirm that your key is valid and that the network connection is established. If the request succeeds, you are ready to start sending prompts for image generation workflows.

Configuring Authentication and Endpoints

Authentication is handled via the API key in the Authorization header. When you initialize your client, pass the key as the API key parameter. This key allows access to the uncensored model. The model ID you must send is 'uncensored'. This model does not refuse lawful adult, fictional, security-research, or controversial topics. It is designed to provide text output without the typical restrictions found in other models.

The primary endpoint for sending prompts is POST /v1/chat/completions. This endpoint accepts a message array containing your prompt. You can also use POST /v1/responses for a different response format. Both endpoints support the same model and parameters. The GET /v1/models endpoint allows you to verify the available models. Currently, only the uncensored model is available for text generation.

It is important to note that this API is text-only. It does not support image, audio, or video generation directly. The text output from this API is typically used as a prompt for an image generation model. You will need to handle the image generation part separately in your workflow. The API serves as the text engine that drives the creative direction of your images.

When configuring your client, ensure that you set the correct model ID. Sending a different model ID may result in an error. The API expects the string 'uncensored' exactly as specified. Any deviation from this ID will cause the request to fail. This strict requirement ensures that you are using the correct model for your uncensored content needs.

Sending Prompts and Handling Responses

Once your client is configured, you can start sending prompts. The prompt is sent as a message in the message array. You can include multiple messages to create a conversation history. The context window supports up to 100,000 tokens for the prompt and completion combined. This allows for detailed and complex prompts without losing context. You can send long descriptions for your image generation needs.

The API supports streaming over Server-Sent Events (SSE). This allows you to receive the response in chunks as it is generated. The usage information is included in the last chunk. Streaming is useful for real-time feedback in your application. You can process each chunk as it arrives, providing a smoother user experience. This is particularly helpful for long responses or when you want to display progress to the user.

You can also use JSON mode to get structured output. This is useful if you need to parse the response programmatically. The API returns the response in a JSON format that you can easily parse in Python. This ensures that your scripts can handle the output reliably. You can extract specific fields from the response and use them in your image generation pipeline.

Error handling is important for reliable automation. The API returns specific error codes for different issues. A 401 error indicates an invalid key, while a 402 error means you have no credit. A 429 error indicates that you have hit the rate limit. You should handle these errors gracefully in your script to avoid crashes. Implementing retry logic can help manage rate limits effectively.

Parameters and Customization Options

The API supports several parameters to customize the output. You can set the temperature to control the randomness of the response. A higher temperature produces more creative and varied outputs, while a lower temperature produces more deterministic results. You can also set top_p to control the diversity of the output. This parameter works in conjunction with temperature to shape the response.

You can use the stop parameter to specify sequences that end the response. This is useful for controlling the length of the output or for stopping the response at a specific point. The seed parameter allows you to set a random seed for reproducibility. This ensures that you get the same response for the same input, which is helpful for testing and debugging.

The penalties parameter allows you to adjust the frequency and presence penalties. These penalties help control the repetition and diversity of the output. You can fine-tune these parameters to get the desired style and tone for your prompts. Experimenting with these settings can help you find the best configuration for your specific use case.

It is important to note that the API does not support fine-tuning or model routing. You are using the single uncensored model with the available parameters. This simplifies the integration process but limits the ability to customize the model itself. You can still achieve a wide range of outputs by adjusting the parameters and prompts.

When This API Is Not the Right Choice

While our API is powerful for text generation, it is not suitable for every project. If you need image generation directly from the API, this is not the right choice. The API only outputs text. You will need to integrate with an image generation model separately to create images. This adds complexity to your workflow but allows for more flexibility in choosing the best image model.

If you require embeddings, search, or OCR capabilities, this API does not support them. The API is focused on text generation for uncensored content. If you need to analyze images or search through large datasets, you will need to use a different service. This API is best used for generating the text prompts that drive your image generation workflows.

Additionally, if you need real-time audio or video generation, this API is not the right choice. The API is text-only and does not support multimedia outputs. If your project requires a multi-modal experience, you will need to combine this API with other services. This API serves as the text engine, while other services handle the multimedia aspects.

Finally, if you need a subscription-based model with monthly fees, this API may not fit your budget. The API uses a prepaid credit system with no monthly fee. This is cost-effective for intermittent use but may not be ideal for high-volume, continuous usage. Consider your usage patterns and budget before deciding if this API is the right fit for your project.

Addressing Common Developer Questions

Developers often ask how to handle NSFW content generation in their scripts. The uncensored model is designed to handle adult, fictional, and controversial topics without refusal. This makes it ideal for NSFW image generation workflows. You can send detailed prompts for NSFW images, and the model will generate the text description without blocking the content. This allows you to drive your image generation pipeline with precise control over the content.

Another common question is how to manage credit and billing. The API uses a prepaid credit system with no monthly fee. You can top up your credit using crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up is $20, and the maximum is $500. Bonus credit is available for top-ups of $50 or more. This flexible billing model allows you to pay only for what you use.

Developers also inquire about rate limits. The API allows 300 requests per minute per key. This is a generous limit for most automation tasks. If you hit the rate limit, you will receive a 429 error. You can implement retry logic in your script to handle this gracefully. This ensures that your automation continues to run smoothly even during peak usage.

Finally, many developers ask about the trial credit. Every new account gets $0.50 of trial credit, with no card required. This allows you to test the API without any financial commitment. You can send a few prompts and verify that the integration works correctly before purchasing more credit. This trial credit is a great way to get started with the API and evaluate its suitability for your project.

Best Practices for Reliable Automation

To ensure reliable automation, it is important to handle errors gracefully. The API returns specific error codes for different issues. A 401 error indicates an invalid key, while a 402 error means you have no credit. A 429 error indicates that you have hit the rate limit. You should implement retry logic in your script to handle these errors. This ensures that your automation continues to run smoothly even if there are temporary issues.

Using streaming responses can improve the user experience. The API supports streaming over Server-Sent Events (SSE). This allows you to receive the response in chunks as it is generated. You can process each chunk as it arrives, providing real-time feedback to the user. This is particularly useful for long responses or when you want to display progress in your application.

It is also important to monitor your credit balance. The API charges based on real token usage. Errors and refusals are free, so you only pay for successful responses. You can check your balance and usage through the API or the dashboard. This helps you manage your budget and avoid unexpected charges. Keep an eye on your credit usage to ensure that you have enough balance for your automation tasks.

Finally, consider using JSON mode for structured output. This allows you to parse the response programmatically and extract specific fields. This is useful if you need to use the output in your image generation pipeline. JSON mode ensures that the output is consistent and easy to parse. This reduces the risk of errors in your automation and makes your scripts more reliable and reliable.

Frequently asked questions

How do I authenticate my Python script?

Pass your API key to the OpenAI Python library as the API key parameter. The key is shown immediately after signup. Use the base URL https://api.uncensoredimage.cc/v1 to point the client to our service.

What is the model ID I should use?

The model ID is 'uncensored'. This is the only model available for text generation. Ensure you send this exact string in your requests to use the uncensored model.

Can I generate images directly with this API?

No, this API is text-only. It generates text prompts that you can use to drive an image generation model. You will need to integrate with an image generation service separately to create images.

How do I top up my credit?

You can top up using crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up is $20, and the maximum is $500. Bonus credit is available for top-ups of $50 or more.