EN ▾
Get API key

Integrating an Uncensored LLM API with Python

Developers often seek a straightforward way to connect their applications to an uncensored text endpoint using standard SDKs. This guide provides a tested checklist for configuring client settings, handling text-in/text-out responses, and verifying connectivity without relying on image or audio features. We focus on the specific mechanics of our API to help you build reliable integrations.

Developer workspace with laptop showing code and chat interface, abstract data streams, minimalist tech style

Understanding the API Architecture

When integrating an LLM API, it is essential to understand the underlying architecture that powers your application. Our service provides a hosted, OpenAI-compatible chat-completions API that serves a single uncensored open-weight text model. This means you can use familiar tools and libraries to interact with our endpoint, reducing the learning curve for new developers. The API is designed for text in and text out, ensuring that your application receives clear, structured responses.

The base URL for our API is https://api.openllmgateway.com/v1, which simplifies the configuration process. You do not need to worry about complex routing or multiple endpoints for different model types. The API supports three main endpoints: POST /v1/chat/completions for generating responses, POST /v1/responses for handling specific response formats, and GET /v1/models for retrieving available model information. This simplified approach allows you to focus on building your application logic rather than managing infrastructure.

One key feature of our API is the context window, which supports up to 100,000 tokens for both prompt and completion together. This large context window enables your application to handle complex queries and maintain long conversations without losing context. Developers can use this capability to build more sophisticated chatbots, code assistants, and content generators that require a deep understanding of previous interactions.

Unlike some competitors, our API does not offer embeddings, image, audio, or video generation. It also lacks OCR, fine-tuning, and model routing capabilities. This focused approach ensures that the API remains fast and reliable for text-based tasks. If your application requires multimodal features, you may need to integrate additional services alongside our text API.

Configuring Client Settings in Python

Setting up your Python environment to interact with our API is straightforward. You will need to install the official OpenAI Python package, which provides a convenient interface for making requests. Once installed, you can configure the client by setting the API key and the base URL. The API key is generated immediately upon signup, and you can use Google authentication or email and password to create your account.

When configuring the client, ensure that you set the model ID to 'uncensored'. This tells the API which model to use for generating responses. The uncensored model does not refuse lawful adult, fictional, security-research, or controversial topics, providing a more flexible experience for developers who need unrestricted text generation. However, it is important to note that the API does have a hard content limit regarding sexual content involving minors, which will be refused.

You can also configure various parameters to customize the behavior of the API. These include temperature, top_p, stop sequences, seed, and penalties. The temperature parameter controls the randomness of the output, while top_p influences the diversity of the generated text. Stop sequences allow you to define specific strings that terminate the response, and the seed parameter ensures reproducibility by setting a random seed for the generation process.

Additionally, our API supports streaming over Server-Sent Events (SSE), which allows you to receive responses in real-time. This is particularly useful for applications that require immediate feedback, such as chat interfaces. The usage information is included in the last chunk of the stream, allowing you to track token consumption accurately. This feature enhances the user experience by providing a more dynamic and responsive interaction.

Handling Text Responses and Errors

Handling responses from the API involves parsing the JSON data returned by the endpoint. The API returns a structured response that includes the generated text, along with metadata such as token usage and model information. You can access the generated text by navigating through the JSON structure, typically under the 'choices' key. This allows you to easily integrate the response into your application's UI or logic.

Error handling is important for building reliable applications. Our API returns specific HTTP status codes to indicate different types of errors. A 401 error indicates an invalid API key, which means you should verify your credentials. A 402 error indicates that you have no credit left, and you will need to top up your account to continue using the service. A 429 error indicates that you have exceeded the rate limit of 300 requests per minute per key, and you may need to implement exponential backoff in your code.

It is important to note that errors and refusals are free, meaning you are not charged for tokens when an error occurs or when the API refuses a request due to content limits. This can help reduce costs for applications that frequently encounter errors or trigger content filters. Additionally, prepaid credit never expires, so you can use your balance at any time without worrying about expiration dates.

When integrating with Python, you can use try-except blocks to handle these errors gracefully. This allows your application to continue running even if an error occurs, providing a better user experience. You can also log these errors for debugging purposes, helping you identify and resolve issues more quickly. By implementing proper error handling, you can ensure that your application remains stable and reliable.

Managing Tokens and Pricing

Understanding how tokens are counted and priced is essential for managing your application's costs. Our API charges $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. This pricing model is based on real token usage, meaning you are only charged for the tokens that are actually processed. Errors and refusals are free, which can help reduce overall costs.

To estimate your costs, you can use the formula: (tokens divided by 1,000,000) times the per-million price. For example, if your application processes 100,000 input tokens and 50,000 output tokens, you would calculate the cost as follows: (100,000 / 1,000,000) * $0.15 for input tokens, and (50,000 / 1,000,000) * $0.50 for output tokens. This allows you to budget effectively and avoid unexpected charges.

Top-up options are available via cryptocurrency only, specifically USDT on TRC20 or USDC on Base. You can add any whole amount from $20 to $500 to your account. Additionally, if you top up $50 or more, you receive bonus credit ranging from +5% to +15%. This bonus credit can help you get more value from your purchases. Note that there are no cards, PayPal, or bank transfer options available for top-ups.

It is important to monitor your token usage to ensure that you do not exceed your budget. You can track usage through the API responses, which include token counts for both input and output. By understanding how tokens are counted and priced, you can optimize your application to minimize costs while maintaining performance.

When Our API Is Not the Right Choice

While our API is powerful for text-based tasks, it may not be the right choice for every application. If your application requires image, audio, or video generation, our API does not support these features. You would need to integrate additional services to handle multimodal content. Similarly, if you need OCR capabilities to extract text from images, our API does not provide this functionality.

Another limitation is that our API does not offer fine-tuning options. If you need to train a model on your specific dataset to improve performance for a particular task, you would need to use a different service that supports fine-tuning. Additionally, if you require model routing to distribute requests across multiple models for load balancing or cost optimization, our API does not support this feature.

Furthermore, if you are looking for an API that offers embeddings for vector search or semantic similarity, our API does not provide this capability. You would need to use a separate embedding service to generate vectors from your text data. Finally, if you need a service with specific SLA guarantees, certifications like SOC2 or HIPAA, or on-prem deployment options, our API may not meet your requirements.

In these cases, it is important to evaluate your application's needs carefully. If your primary requirement is uncensored text generation with a simple, cost-effective pricing model, our API is an excellent choice. However, if you need advanced features like multimodal support or fine-tuning, you may need to consider other options. Always check the documentation of other vendors for current prices, limits, and features to make an informed decision.

Addressing Community Questions on Reddit

Developers frequently discuss LLM gateways and integration challenges on Reddit, particularly in subreddits like r/openziti, r/AIToolsPerformance, and r/OpenSourceAI. A common theme in these discussions is the need for open-source solutions that provide visibility into costs and performance. Users often ask how to benchmark gateways and reduce token usage, with some sharing their experiences with tools that offer significant token reduction and failover capabilities.

Another frequent topic is the comparison between different gateways and their ability to route requests to multiple providers. Developers are interested in solutions that can handle context pruning, caching, and coding-agent workflows. Some users have shared their experiences with open-source gateways built on technologies like OpenZiti, highlighting the benefits of decentralized networking and improved reliability.

Cost reduction is also a major concern, with many users seeking ways to lower their monthly expenses on LLM APIs. Discussions often revolve around the trade-offs between cost, performance, and feature set. Users appreciate gateways that offer transparent pricing and detailed usage tracking, allowing them to optimize their spending. Additionally, there is interest in gateways that provide reliable error handling and failover mechanisms to ensure continuous service.

By addressing these community questions, we can provide valuable insights for developers looking to integrate our API. Understanding the common pain points and solutions discussed on Reddit helps us tailor our documentation and support to meet the needs of our users. This ensures that developers can make the most of our API while addressing their specific integration challenges.

Best Practices for Production Integration

Integrating our API into a production environment requires careful planning and testing. One best practice is to implement exponential backoff for rate limit errors. This ensures that your application does not overwhelm the API with requests and helps prevent 429 errors. By waiting longer between retries, you can reduce the likelihood of hitting the rate limit and improve the overall stability of your application.

Another important practice is to monitor token usage closely. Since pricing is based on real token usage, it is essential to track how many tokens your application consumes. You can use the token counts provided in the API responses to calculate costs and identify areas for optimization. For example, you might find that certain prompts are using more tokens than necessary, and you can adjust them to reduce costs.

It is also recommended to use the streaming feature for real-time applications. Streaming allows you to display responses to users as they are generated, providing a more engaging experience. By handling the SSE events correctly, you can ensure that your application responds quickly and efficiently. Additionally, you can use the seed parameter to generate reproducible responses, which is useful for testing and debugging.

Finally, always keep your API key secure and rotate it regularly. Since the key is shown immediately upon signup, make sure to store it in a secure environment variable or secret manager. Avoid hardcoding the key in your source code, as this can lead to security vulnerabilities. By following these best practices, you can ensure that your integration with our API is reliable, secure, and cost-effective.

Frequently asked questions

How do I set up the Python client for our uncensored API?

Install the OpenAI Python package and configure the client with your API key and the base URL https://api.openllmgateway.com/v1. Set the model ID to 'uncensored' to use our specific model.

What happens if I run out of credit?

If you run out of credit, the API will return a 402 error. You can top up your account with USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500. Credit never expires, so you can use it whenever you need.

Does the API support streaming responses?

Yes, the API supports streaming over Server-Sent Events (SSE). This allows you to receive responses in real-time, which is ideal for chat interfaces. Usage information is included in the last chunk of the stream.

Are there any limitations on content?

The API has a hard content limit regarding sexual content involving minors, which will be refused. However, it does not refuse lawful adult, fictional, security-research, or controversial topics, providing a more flexible experience.