EN ▾
Get API key

Integrating Flux Uncensored Text API in Python

Developers often seek reliable ways to integrate uncensored language models into their Python applications. This guide walks you through setting up the client, managing crypto payments, and handling responses efficiently.

Developer workspace showing Python code and streaming text interface with crypto tokens

Setting Up the Python Client

Connecting to our API requires standard Python libraries that support OpenAI-compatible endpoints. You can use the official openai package or any compatible SDK. The base URL for our service is https://api.fluxuncensored.cc/v1. This URL directs your requests to the correct endpoint for text completions. Ensure you have the latest version of the library installed to support all modern features.

You need an API key to authenticate your requests. You can obtain this key by signing up with Google or using an email and password. The key is displayed immediately after registration. Store this key securely in your environment variables or a configuration file. Never hardcode the key directly in your source code to prevent accidental exposure.

Initialize the client object with your base URL and API key. This setup allows you to make requests using standard methods. The client handles the authentication headers automatically. You can then call the chat completions endpoint to send text and receive text responses. This simple setup works for most basic integration scenarios.

Remember that our service is independent. Do not assume it is an official product of any other company. Check the vendor's documentation for specific details on their models. Our API serves a single uncensored open-weight model. The model ID to send is "uncensored". This ensures you are interacting with the correct model for your workflow.

Configuring Headers and Parameters

When making requests, you can configure various parameters to control the model's behavior. Our API supports parameters like temperature, top_p, stop sequences, and seed. These parameters allow you to fine-tune the output. For example, setting a lower temperature makes the output more deterministic. A higher temperature introduces more creativity and variability.

You can also use JSON mode to force the model to output valid JSON. This is useful for building structured data pipelines. Function calling is also supported, allowing you to define tools that the model can invoke. These features make our API versatile for complex applications. You can define tool schemas and let the model decide when to use them.

The API key must be included in the authorization header. Use the Bearer token format. Ensure the key is valid and has sufficient credit. If the key is invalid, you will receive a 401 error. If you have no credit, you will receive a 402 error. Rate limits are enforced at 300 requests per minute per key. Exceeding this limit results in a 429 error.

Streaming is supported over Server-Sent Events (SSE). This allows you to receive responses in chunks as they are generated. This is particularly useful for real-time applications. The usage information is included in the last chunk of the stream. This helps you track token consumption accurately. You can handle the stream in Python using async iterators or standard loops.

Managing Crypto Top-Ups and Credits

Our API uses a prepaid credit system charged by real token usage. Errors and refusals are free, so you only pay for actual text generated. The pricing is $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. You can top up your account using cryptocurrency. We accept USDT on the TRC20 network or USDC on the Base network.

The minimum top-up amount is $20, and the maximum is $500. You can top up any whole amount within this range. Bonus credit is available for top-ups of $50 or more. The bonus ranges from 5% to 15% depending on the amount. This bonus credit never expires, so you can use it whenever you need it.

There is no monthly subscription fee. You pay only for what you use. This model is ideal for developers who want predictable costs. You can monitor your usage through the dashboard. If you run out of credit, your requests will fail with a 402 error. Simply top up again to resume service.

We do not accept credit cards, PayPal, or bank transfers. All payments must be made via crypto. This ensures fast and borderless transactions. You can top up any amount from $20 to $500. The bonus credit is added automatically after the transaction is confirmed. This makes it easy to scale your usage as needed.

Handling Responses and Errors

When you send a request, you receive a text response. The model does not refuse lawful adult, fictional, security-research, or controversial topics. However, there is a hard content limit regarding sexual content involving minors. Such requests are refused. This ensures the model remains usable for a wide range of applications.

Errors are handled with specific HTTP status codes. A 401 error indicates an invalid key. A 402 error means you have no credit. A 429 error indicates you have hit the rate limit. You can handle these errors in your code by retrying or prompting the user to top up. This makes your application reliable and user-friendly.

Streaming responses allow you to display text as it is generated. This improves the user experience for real-time applications. You can handle the stream in Python using async iterators. The usage information is included in the last chunk. This helps you track token consumption accurately. You can log this information for billing or analytics purposes.

Our API serves only text. We do not offer image, audio, video, or embedding generation. If you need these features, you may need to use other services. Our API is designed for text-in, text-out workflows. This focus ensures high performance and reliability for text-based applications. You can combine our API with other tools to build comprehensive solutions.

When Our API Is Not the Right Choice

Our API is optimized for text completions. If you need image generation, audio processing, or video creation, our service may not be the right choice. We do not support embeddings, OCR, or fine-tuning. If your workflow requires these features, you may need to use a different provider.

We also do not offer model routing. You are limited to a single uncensored model. If you need to switch between different models for different tasks, our API may not meet your needs. You can, however, build your own routing logic using our API as one of the endpoints.

Our API is best suited for applications that require uncensored text generation. If you need strict content filtering or specific model capabilities, you may need to explore other options. Our focus is on providing a reliable, uncensored text endpoint for developers who need it.

Additionally, we do not offer an on-prem deployment option. If you need to host the model on your own infrastructure, our API may not be suitable. We are a hosted service. This means you rely on our infrastructure for availability and performance. For most developers, this is a convenient and cost-effective solution.

Addressing Common Reddit Questions

Users on Reddit often discuss updates to uncensored models and their integration. For example, threads on r/aicuriosity mention updates to Flux Uncensored V2, which brings unfiltered AI image generation. While our API focuses on text, users often ask how to combine text and image workflows. You can use our API for text generation and then pass the text to an image model.

Another common question is about the difference between Flux 1 and Flux 2. Users wonder if Flux 1 is more realistic for certain tasks. While our API does not generate images, the text model can be used to generate prompts for image models. This allows you to use the strengths of both text and image generation.

Developers also ask about the best way to handle rate limits. Our API enforces a limit of 300 requests per minute per key. You can manage this by implementing retry logic with exponential backoff. This ensures your application does not overwhelm the API and maintains smooth operation.

Finally, users often inquire about the bonus credit system. Our API offers bonus credit for top-ups of $50 or more. This bonus ranges from 5% to 15%. Users appreciate this feature as it provides extra value for their investment. You can use this bonus credit to test new features or scale your usage without additional cost.

Best Practices for Production Use

When using our API in production, it is important to monitor your usage and errors. Implement logging to track token consumption and error rates. This helps you identify issues early and optimize your workflow. You can use the usage information in the streaming response to log token counts accurately.

Handle rate limits gracefully by implementing retry logic. Use exponential backoff to avoid overwhelming the API. This ensures your application remains responsive even during high traffic periods. You can also implement a queue system to manage requests during peak times.

Secure your API key by storing it in environment variables or a secure configuration file. Avoid hardcoding the key in your source code. This prevents accidental exposure and makes it easier to rotate keys if necessary. You can also implement key rotation strategies to enhance security.

Test your integration thoroughly before deploying to production. Use the trial credit to test your workflow without risking your paid credit. This allows you to identify any issues and optimize your code. Once you are satisfied with the performance, you can scale up your usage. Our API is designed to handle high volumes of requests efficiently.

Frequently asked questions

How do I top up my account?

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

What is the context window size?

Our API has a context window of 100,000 tokens. This includes both the prompt and the completion. This large context window allows you to process long documents and complex conversations.

Can I use the API for image generation?

No, our API is text-only. It does not support image, audio, or video generation. You can use the text output to generate prompts for image models, but the API itself only handles text.

How do I handle rate limits?

Our API enforces a limit of 300 requests per minute per key. You can handle this by implementing retry logic with exponential backoff. This ensures your application does not hit the rate limit too frequently.