Integrating the Uncensored Ollama API with Python
Connecting your Python application to an uncensored language model is straightforward when you use an OpenAI-compatible endpoint. This guide walks you through the essential steps to configure your SDK, handle authentication, and execute your first request to our hosted service.

Setting Up Your Python Environment
Before you can interact with our API, you need to prepare your Python environment. The most common way to communicate with an OpenAI-compatible endpoint is by using the official openai Python package. You can install this package using pip, which is the standard package installer for Python. This package provides a clean interface for sending requests and handling responses from the server.
Once installed, you will need to import the necessary modules in your Python script. Typically, this involves importing the OpenAI class from the openai library. This class acts as the client that manages the connection to our API. You will also need to handle environment variables or hardcode your API key for authentication purposes.
It is important to note that our API serves only text. There are no embeddings, image generation, or audio processing capabilities. Therefore, your Python script should focus solely on text input and output. You do not need to configure any additional parameters for multimodal features. The model ID you will use is simply uncensored.
After setting up the client, you should verify that your API key is valid. A valid key allows you to make requests to the /v1/chat/completions endpoint. If the key is invalid, the API will return a 401 error. You can generate a new key immediately after signing up with Google or an email and password combination.
Authentication and Crypto Top-ups
Authentication for our API is handled via an API key. You receive this key immediately after signing up. It is important to keep this key secure, as it grants access to your account and allows you to send requests. The API key is used in the Authorization header of your HTTP requests.
Our pricing model is prepaid, meaning you must top up your credit before you can use the service. Payments are accepted only in cryptocurrency. Specifically, we accept USDT on the TRC20 network or USDC on the Base network. You can top up with any whole amount between $20 and $500. There are no monthly subscriptions or recurring fees.
When you top up, your credit is charged based on real token usage. Errors and refusals are free, so you do not pay for failed requests. The cost is $0.15 per million input tokens and $0.50 per million output tokens. This transparent pricing allows you to budget accurately for your applications.
If you are new to the platform, every new account receives $0.50 of trial credit. This allows you to test the API without immediate financial commitment. However, for sustained usage, you will need to perform a crypto top-up. The credit never expires, so you can use it whenever you need it.
Making Your First Request
With your environment set up and your API key ready, you can now make your first request. The primary endpoint for generating text is POST /v1/chat/completions. This endpoint accepts a JSON payload containing the model ID, messages, and various parameters. The model ID you must specify is uncensored.
The request structure follows the standard OpenAI chat completion format. You provide a list of messages, which can include system, user, and assistant roles. The API returns a text response based on your input. You can also enable streaming to receive the response in chunks, which is useful for real-time applications.
Our API supports a context window of 100,000 tokens. This allows for long conversations or large documents to be processed in a single request. The context window includes both the prompt and the completion. This is significantly larger than many standard models, making it suitable for complex tasks.
You can also use the POST /v1/responses endpoint for alternative response formats. Additionally, you can use the GET /v1/models endpoint to verify the available models. These endpoints provide flexibility in how you integrate the API into your Python application.
Handling Parameters and Streaming
The API supports several parameters to fine-tune the output. You can set the temperature to control creativity, top_p for nucleus sampling, and stop sequences to halt generation. You can also set a seed for reproducibility and adjust penalties for repetition.
Streaming is supported via Server-Sent Events (SSE). When you enable streaming, the API sends chunks of the response as they are generated. This allows your application to display text in real-time. The usage information, such as token counts, is included in the last chunk of the stream.
Function calling is also supported. You can define tools in your request, and the model will return structured data that can be used to trigger actions in your application. This is useful for building agents that can interact with external systems.
JSON mode is available if you need the output to be strictly valid JSON. This is helpful for parsing responses in your Python code. You can specify this in the request parameters to ensure consistent formatting.
Error Handling and Rate Limits
When integrating with any API, error handling is critical. Our API returns specific HTTP status codes to indicate the outcome of your requests. A 401 error means your API key is invalid. A 402 error indicates that you have no credit left. A 429 error means you have exceeded the rate limit.
The rate limit is 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. It is important to implement retry logic in your Python script to handle these errors gracefully. You can wait for a short period and retry the request.
Since errors and refusals are free, you do not need to worry about wasting credit on failed requests. However, you should still monitor your usage to ensure you have enough credit for your intended tasks. You can check your balance and usage through your account dashboard.
Implementing reliable error handling ensures that your application remains reliable even when encountering issues. You can log errors and notify users if a request fails. This improves the user experience and helps you diagnose problems quickly.
When This API Is Not the Right Choice
While our API is excellent for text generation, it may not be the right choice for every project. If you need image generation, audio processing, or video creation, this API will not meet your needs. It serves only text in and text out.
Similarly, if you require embeddings for vector search, this API does not provide that capability. You would need to use a different service for embedding generation. The same applies if you need OCR for reading text from images or fine-tuning models for specific tasks.
Additionally, if you need model routing to switch between different models dynamically, this API does not support that feature. It serves a single uncensored open-weight text model. You cannot route requests to different models based on specific criteria.
Finally, if you need an SLA guarantee or certifications like SOC2 or HIPAA, this independent service does not offer those. It is designed for developers who need a reliable, uncensored text API without the overhead of enterprise-level certifications. Always evaluate your specific needs before integrating.
Addressing Common Developer Questions
Developers often ask how to handle rate limits mid-stream. When a 429 error occurs during a streaming request, the entire completion is retried. This ensures that the client receives the full response, even if the initial stream was interrupted. The API returns a 200 status as streaming starts, so mid-stream 429s are detected and handled.
Another common question is about key management for agencies. Some developers build tools that rotate multiple API keys to manage usage across different clients. While our API does not natively support key rotation, you can implement this logic in your Python script. You can store multiple keys and switch between them based on usage or time.
Users also inquire about the context window. With a 100,000 token limit, you can process large documents or long conversations. This is beneficial for tasks that require understanding extensive context. However, be mindful of the token usage to manage costs effectively.
Finally, developers often ask about the trial credit. The $0.50 trial credit is a great way to test the API without financial commitment. It allows you to verify that your integration works correctly before topping up with crypto. This trial credit is available to every new account.
Frequently asked questions
How do I top up my API credit?
You can top up your credit using USDT on the TRC20 network or USDC on the Base network. The minimum top-up amount is $20, and the maximum is $500. Payments are processed immediately, and your credit is available for use right away.
What is the context window size?
The context window is 100,000 tokens, which includes both the prompt and the completion. This allows for long conversations and large document processing in a single request.
Does the API support image generation?
No, the API serves only text in and text out. There are no image, audio, or video generation capabilities. It is designed specifically for text-based interactions.
How do I handle rate limits in Python?
If you exceed the rate limit of 300 requests per minute, you will receive a 429 error. You should implement retry logic in your Python script to wait and retry the request. This ensures your application remains reliable.