Integrate Ollama Abliterated with Python SDK
Connecting your Python application to an uncensored text API requires precise configuration of the SDK client and authentication headers. This guide walks you through the exact steps to integrate our service, ensuring you handle the text-in, text-out flow correctly while managing your prepaid credit balance.

Setting Up the Python Environment
Before writing any code, you need to install the official Python SDK package that connects to our API. Open your terminal and run the installation command for the openai library, which is compatible with our endpoint structure. This library provides the necessary classes to handle HTTP requests, JSON parsing, and streaming responses efficiently.
Once installed, import the OpenAI client from the package in your Python script. You will need to initialize this client by providing your API key and specifying the base URL of our service. The base URL is https://api.ollamaabliterated.com/v1, which directs requests to our uncensored inference engine.
Ensure that you store your API key securely, perhaps using environment variables, to avoid hardcoding sensitive credentials in your source code. This key is generated immediately after signup and is required for all authenticated requests. Without a valid key, your requests will receive a 401 error, indicating an invalid or missing key.
After initialization, verify the connection by listing available models. This simple check confirms that your SDK is correctly configured and can reach our servers. You should see the uncensored model listed, which is the only model our API serves for text generation.
Configuring the API Client
With the client initialized, you must configure it to use the correct model ID. Our API accepts only one model ID, which is uncensored. This model is an open-weight text model designed to provide minimal refusal for lawful adult, fictional, or controversial topics. When sending requests, ensure you specify this ID in the model parameter of your completion calls.
Set the base_url parameter in your client configuration to https://api.ollamaabliterated.com/v1. This ensures that all requests, including chat completions and model listings, are routed correctly. The client will handle the HTTP methods and headers automatically, so you do not need to manage low-level request details.
Configure the client to handle streaming responses if you plan to use real-time text generation. Streaming allows you to receive tokens as they are generated, which can improve the perceived latency of your application. The SDK supports Server-Sent Events (SSE) for streaming, and you can access usage information in the final chunk of the stream.
Remember that our API supports function calling, JSON mode, and various sampling parameters. You can set the temperature, top_p, stop sequences, and seed values to control the output behavior. These parameters allow you to fine-tune the creativity and determinism of the model's responses.
Handling Authentication and Keys
Authentication for our API relies on a simple API key passed in the authorization header. When you sign up via Google or email, you receive a key immediately. This key is unique to your account and is used to identify your requests and deduct credit from your prepaid balance.
If your key is invalid or missing, the API returns a 401 status code. This indicates that the key is either incorrect or has not been provided. Ensure that you are passing the correct key in the Authorization header for each request. A 402 error indicates that you have no remaining credit, while a 429 error means you have hit the rate limit of 300 requests per minute.
Since we do not support cards, PayPal, or bank transfers, your credit management is handled through crypto payments. You can top up using USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500. Bonus credit is available for purchases of $50 or more, ranging from +5% to +15%.
New accounts receive $0.50 of trial credit, which allows you to test the API without immediate payment. This trial credit is charged by real token usage, just like paid credit. Errors and refusals do not consume credit, so you can test your integration freely without worrying about wasting your balance.
Making Text Completions
To generate text, use the POST /v1/chat/completions endpoint. Pass your messages in the messages parameter, specifying the role and content for each turn. The model will respond with a completion that you can process in your application. The context window supports up to 100,000 tokens for both prompt and completion combined.
For simpler text generation, you can use the POST /v1/responses endpoint. This endpoint provides a simplified way to get text outputs without managing complex message structures. Both endpoints return text, and the model does not support image, audio, or video generation, so you only need to handle text data.
When processing responses, check the finish_reason to determine if the generation was complete or if it hit a limit. You can also access the usage statistics, which include the number of input and output tokens. These statistics are important for tracking your credit consumption and understanding the cost of your requests.
Remember that our API is uncensored, meaning it does not refuse lawful adult, fictional, or controversial topics. However, there is a hard limit on sexual content involving minors, which will be refused. Ensure your prompts align with these guidelines to avoid unexpected refusals.
Streaming and Real-Time Updates
Streaming responses allow you to receive tokens as they are generated, providing a smoother user experience for real-time applications. To enable streaming, set the stream parameter to True in your request. The SDK will yield chunks of text as they become available, allowing you to display them incrementally.
Each chunk contains a portion of the generated text, and the final chunk includes the usage statistics. This is useful for tracking token consumption in real-time, ensuring you stay within your budget. The usage data includes the number of input and output tokens, which are charged at $0.15 per million input tokens and $0.50 per million output tokens.
When implementing streaming, handle potential network interruptions gracefully. If the connection drops, you may need to retry the request or handle the partial response. The SDK provides tools to manage these scenarios, but it is good practice to implement your own error handling logic.
Streaming is particularly useful for chat applications where users expect immediate feedback. By displaying tokens as they are generated, you reduce the perceived latency and create a more engaging interaction. Ensure your UI updates efficiently to avoid lag or jank.
When Our API Is Not the Right Choice
While our API excels at uncensored text generation, it may not be the right choice for all use cases. If you need image, audio, or video generation, our service does not support these capabilities. You would need to integrate with a different provider for multimodal tasks.
Similarly, if you require embeddings, OCR, or fine-tuning, our API does not offer these features. Our service is focused solely on text completion and chat completions. If your application relies on these advanced features, you should consider a more comprehensive provider.
Additionally, if you need an SLA guarantee, SOC2/HIPAA/ISO certification, or on-prem deployment, our service does not provide these. We are an independent service without these formal certifications or deployment options. For enterprise-grade requirements, you may need a different solution.
Finally, if you prefer to pay with credit cards or PayPal, our crypto-only payment model might not suit your needs. We accept USDT on TRC20 or USDC on Base, with no card or bank transfer options. Ensure your payment preferences align with our model before integrating.
Troubleshooting and Best Practices
When integrating with our API, common issues include invalid keys, insufficient credit, and rate limits. A 401 error indicates an invalid key, so verify that you are using the correct key from your account. A 402 error means you have no credit, so check your balance and top up if necessary. A 429 error indicates you have exceeded the rate limit of 300 requests per minute.
To avoid rate limits, implement exponential backoff in your retry logic. This ensures that you do not overwhelm the API with rapid requests. Additionally, monitor your token usage to ensure you stay within your budget. The usage statistics in the response help you track consumption accurately.
Use the GET /v1/models endpoint to verify the available models and their details. This endpoint confirms that the uncensored model is available and provides information about its capabilities. Regularly checking this endpoint can help you stay updated on any changes to the model or API structure.
Finally, test your integration thoroughly before deploying to production. Use the $0.50 trial credit to experiment with different parameters and scenarios. This helps you identify potential issues and optimize your implementation for performance and reliability.
Frequently asked questions
How do I set up the Python SDK for our API?
Install the openai library and initialize the client with your API key and the base URL https://api.ollamaabliterated.com/v1. Use the model ID uncensored for all requests.
What happens if I run out of credit?
You will receive a 402 error. You can top up using USDT on TRC20 or USDC on Base, with amounts from $20 to $500. Bonus credit is available for purchases of $50 or more.
Does the API support streaming?
Yes, you can enable streaming by setting the stream parameter to True. The SDK yields chunks of text, and the final chunk includes usage statistics for tracking token consumption.
What are the pricing details?
The API charges $0.15 per million input tokens and $0.50 per million output tokens. Errors and refusals are free, and trial credit is $0.50 for new accounts.