EN ▾
Try with trial credit

Integrating an Uncensored API with Python SDK

Developers often need a straightforward way to integrate open-weight text models into their applications without the restrictions of commercial providers. This guide walks through configuring the OpenAI-compatible SDK to connect with our uncensored endpoint, handling authentication, and managing token usage efficiently.

Developer workspace with laptop showing API code and digital token network

Setting Up the Environment

Before writing any code, you need to prepare your development environment. The first step is installing the official OpenAI Python client, which serves as the standard interface for our uncensored API. This library handles the HTTP requests and response parsing, allowing you to focus on the logic of your application rather than network details.

Once installed, you must configure the client to point to our specific base URL. Unlike the default OpenAI endpoint, our service hosts the model at a distinct address. You will need to set the base_url parameter in your client initialization. This ensures that all requests are routed correctly to our uncensored text model.

Next, you need to obtain an API key. You can generate this key immediately after signing up via Google or email. The key is displayed right away, so make sure to copy it securely. This key is required for all subsequent requests to authenticate your identity and access your prepaid credit balance.

Finally, verify your connection by sending a simple test request. This confirms that your environment is correctly configured and that your API key is valid. A successful test response indicates that you are ready to proceed with more complex interactions and data processing.

Authentication and Header Configuration

Authentication is the first layer of security in any API integration. Our uncensored API uses a simple API key mechanism for authentication. You must include this key in the Authorization header of every request. The format is typically Bearer your_api_key, which the SDK handles automatically when you provide the key during client initialization.

It is important to keep your API key secure. Avoid hardcoding it directly in your source code if possible. Instead, use environment variables or a secure configuration file to store the key. This practice prevents accidental exposure when you share your code or deploy it to a production server. The key is tied to your prepaid credit, so unauthorized use will deduct from your balance.

If you encounter a 401 error, it usually means your API key is invalid or missing. Check that you are using the correct key and that it has not been revoked. Similarly, a 402 error indicates that you have run out of credit. Since we do not offer subscriptions, you must top up your balance to continue using the service.

The SDK allows you to set default headers for all requests. This simplifies your code by avoiding repetitive header assignments. You can configure the client once at the start of your application and reuse it throughout your project. This approach reduces code duplication and minimizes the risk of configuration errors.

Making Text-Only Requests

Our uncensored API is designed for text-in, text-out interactions. It does not support image, audio, or video generation. When making requests, you must provide text messages in the standard chat completion format. The model id you should send is uncensored. This ensures you are interacting with the correct open-weight model.

You can send single or multiple messages in a conversation. The context window supports up to 100,000 tokens, allowing for long conversations or large documents. The token count includes both the input prompt and the output completion. This generous limit is useful for processing extensive texts or maintaining long-term context in chat applications.

Since there are no embeddings or search capabilities, you must handle any external data retrieval yourself. If you need to incorporate external information, you can append it to the prompt before sending the request. The model will process the combined text and generate a response based on the provided context.

Remember that the API is uncensored, meaning it does not refuse lawful adult, fictional, or controversial topics. However, it does refuse sexual content involving minors. Be sure to structure your prompts clearly to get the desired output. The model responds with text only, so you can easily parse the response for further processing in your application.

Handling Streaming and Parameters

For real-time applications, streaming responses are essential. Our uncensored API supports streaming over Server-Sent Events (SSE). This allows you to receive tokens as they are generated, providing a smoother user experience. The SDK handles the streaming logic, delivering chunks of text to your application as they become available.

You can control the model's behavior using various parameters. The temperature parameter adjusts the randomness of the output, while top_p limits the diversity of token choices. You can also set stop sequences to halt generation at specific points. These parameters give you fine-grained control over the model's output.

Additionally, you can use the seed parameter to ensure reproducibility. By setting a specific seed, you can get consistent results for the same input, which is useful for testing and debugging. The penalties parameter allows you to adjust token frequencies, helping to reduce repetition in the generated text.

When streaming, the usage information is included in the last chunk. This allows you to track token consumption in real-time. Since errors and refusals are free, you do not need to worry about being charged for failed requests. This billing model is fair and predictable for developers building cost-sensitive applications.

When This API Is Not the Right Choice

While our uncensored API is powerful for text generation, it may not be the right choice for every project. If you need image generation, audio synthesis, or video creation, this API will not meet your needs. It is strictly a text-in, text-out service, so you must integrate other tools for multimodal capabilities.

Similarly, if you require embeddings for semantic search or document retrieval, you will need to use a separate service. Our API does not offer embedding endpoints, so you cannot use it for vector database indexing. You must handle data retrieval and processing externally before sending it to the model.

Another limitation is the lack of fine-tuning capabilities. If you need to train the model on your specific dataset, you will need to use a different provider. Our API serves a pre-trained open-weight model, so you cannot customize its weights through our endpoint. You must rely on the base model's knowledge and capabilities.

Finally, if you need on-premises deployment or strict SLA guarantees, this hosted service may not fit your infrastructure requirements. We do not offer on-prem solutions or certified uptime guarantees. If your project demands high availability and data sovereignty, you might need to consider a self-hosted option or a different vendor that offers those specific features.

Addressing Community Questions

Developers in communities like r/LocalLLaMA and r/LocalAIServers often discuss latency and model performance. While some threads highlight ultra-low latency voice cloning or local TTS solutions, our API focuses on text generation. Users appreciate the speed of local inference but may wonder how our API compares in terms of response time for text tasks.

Another common topic is the availability of free or low-cost API access. Threads on r/codex and r/WebAfterAI discuss various free API options, including reverse-engineered endpoints and serverless inference. Our API offers a prepaid credit model with no monthly fees, which appeals to developers who want predictable costs without the complexity of managing GPUs or serverless quotas.

Users also ask about the reliability of uncensored models. Some threads mention concerns about rate limiting or account locks with experimental projects. Our API provides a stable, hosted service with clear rate limits of 300 requests per minute per key. This stability is important for production applications that require consistent performance.

Finally, developers often seek guidance on integrating multiple models. While some threads discuss routing between different vendors, our API serves a single uncensored model. This simplicity reduces integration complexity, allowing developers to focus on the logic of their application rather than managing multiple model endpoints.

Billing and Credit Management

Understanding the billing structure is essential for managing your API usage. Our uncensored API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. These rates are applied to real token usage, ensuring you only pay for what you consume. Errors and refusals do not incur charges, which protects your balance from wasted requests.

You can top up your credit using crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. If you top up $50 or more, you receive a bonus credit ranging from 5% to 15%. This bonus provides extra value for larger purchases.

There are no monthly fees or subscriptions, so your credit never expires. You can use your prepaid balance at any time, making it flexible for projects with variable usage patterns. This model is ideal for indie builders and developers who want to avoid recurring charges.

To track your spending, you can monitor the token usage in your API responses. The SDK provides usage information in the streaming chunks, allowing you to estimate costs in real-time. This transparency helps you budget effectively and avoid unexpected charges.

Frequently asked questions

How do I authenticate with the uncensored API?

You authenticate by including your API key in the Authorization header as a Bearer token. You can generate this key immediately after signing up with Google or email.

What is the context window size?

The context window supports up to 100,000 tokens, which includes both the input prompt and the output completion. This allows for long conversations and large document processing.

Can I use image or audio features with this API?

No, this API is strictly text-in, text-out. It does not support image, audio, video generation, or embeddings. You must handle multimodal tasks with other tools.

How do I top up my credit?

You can top up using USDT on TRC20 or USDC on Base. The minimum amount is $20, and the maximum is $500. Credits do not expire.