EN ▾
Get API key

Integrating the Abliterated Model API with OpenAI SDK

Developers often look for a reliable way to access uncensored language models without building infrastructure from scratch. This guide walks you through configuring the OpenAI SDK to communicate with our hosted endpoint, ensuring you can send and receive text efficiently.

Modern developer workspace with monitor showing code and chat interface

Understanding the Endpoint and Model ID

Before writing any code, you need to know where your requests are going. Our service provides a hosted endpoint that mimics the standard OpenAI chat completions interface. This means you can use familiar SDKs without rewriting your entire integration layer. The base URL for our API is https://api.abliteratedmodel.cc/v1. You must configure your SDK client to point to this specific address rather than the default OpenAI endpoint.

When sending a request, you need to specify the model ID. For our uncensored open-weight text model, the model ID is simply uncensored. This identifier tells the server which underlying model to run. It is important to note that this is a text-only service. We do not support image generation, audio processing, or video outputs. If your application requires multimodal capabilities, you will need to handle those separately.

The API supports standard chat completion endpoints. You will primarily use the POST /v1/chat/completions endpoint for most interactions. There is also a POST /v1/responses endpoint and a GET /v1/models endpoint available. However, the chat completions endpoint is the standard way to interact with the model for text generation tasks. Keep these endpoints in mind as you structure your API calls.

One key feature of this service is that it serves one specific uncensored model. This simplifies your integration because you do not need to manage model routing or switch between different model versions. The model does not refuse lawful adult, fictional, security-research, or controversial topics. This makes it ideal for applications where standard content filters might interfere with the desired output. However, there is a hard limit: the model will refuse requests involving sexual content with minors. This is the only major content restriction you need to account for in your application logic.

Configuring Authentication and API Keys

Authentication is handled via API keys, which you generate when you sign up for an account. You can sign up using Google or by providing an email and password. Once registered, your API key is shown immediately. You must include this key in your HTTP requests to authenticate your usage. The SDK handles this by adding the key to the Authorization header.

When configuring the OpenAI SDK, you set the API key in your client initialization. This key is unique to your account and allows you to access the service. If you send a request with an invalid key, the API returns a 401 error. If you have no credit left, you will receive a 402 error. If you exceed the rate limit, you get a 402 error as well. Understanding these error codes helps you troubleshoot integration issues quickly.

It is important to keep your API key secure. Since the key is shown immediately upon signup, make sure to store it in a secure environment variable or configuration file. Do not hardcode it in your source code if you are sharing your repository. The service charges based on token usage, so unauthorized use of your key could lead to unexpected costs.

Our pricing is straightforward: $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. There is no monthly subscription fee, and prepaid credit never expires. Errors and refusals are free, so you only pay for actual token usage. This pay-as-you-go model is suitable for developers who want to test the API without committing to a recurring bill. You can top up your credit using cryptocurrency, specifically USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500.

Sending Requests with the OpenAI SDK

Once your SDK is configured with the correct base URL and API key, you can start sending requests. The process is similar to calling any other OpenAI-compatible API. You create a client instance, passing in your base URL and API key. Then, you call the chat completions method with your desired parameters.

When constructing your request, you specify the model as uncensored. You also provide a list of messages, which typically includes a system prompt and user messages. The system prompt can be used to set the behavior of the model. Since the model is uncensored, you do not need to worry about standard safety filters blocking your inputs, unless they involve minors.

The API supports several parameters that allow you to control the output. You can set the temperature to adjust randomness, use top_p for nucleus sampling, and specify stop sequences to halt generation. You can also set a seed for reproducible results. These parameters are standard in OpenAI-compatible APIs, so you likely already know how to use them. The context window is 100,000 tokens, which includes both the prompt and the completion. This allows for long conversations or large documents to be processed in a single request.

One advantage of using the OpenAI SDK is that it handles the serialization of your request and the parsing of the response. You do not need to manually construct JSON payloads or parse the response body. The SDK returns a structured object that contains the generated text, usage statistics, and other metadata. This makes it easy to integrate the output into your application. However, remember that this is a text-only API, so you cannot request images or audio in the same call.

Handling Streaming and JSON Mode

For applications that require real-time feedback, our API supports streaming over Server-Sent Events (SSE). This allows you to receive the generated text token by token as it is produced. The SDK makes it easy to handle streaming responses by providing a stream option. When you enable streaming, the response object yields chunks of text as they are generated.

One important detail about streaming is that the usage information is included in the last chunk of the response. This means you need to wait for the stream to complete before you can access the total token count and costs. If you are building a chat interface, you can display the text as it arrives, giving users a smooth experience. The streaming feature is useful for long responses where users do not want to wait for the entire completion.

In addition to streaming, the API supports JSON mode. This is useful when you need the model to output structured data that can be parsed by your application. You can instruct the model to return a JSON object, and the API will ensure the output is valid JSON. This is particularly helpful for extracting data from text or generating configuration files. The model adheres to the JSON structure you specify, making it reliable for programmatic use.

Function calling is also supported, allowing you to define tools that the model can use. You can provide a list of tools with their schemas, and the model will return a tool call if it determines one is needed. This enables more complex interactions where the model can trigger actions in your application. The combination of streaming, JSON mode, and function calling makes this API versatile for a wide range of developer needs.

Rate Limits and Error Handling

Our API has a rate limit of 300 requests per minute per key. This limit is designed to prevent abuse and ensure fair usage for all users. If you exceed this limit, you will receive a 429 error. It is important to implement retry logic in your application to handle these errors gracefully. You can use exponential backoff to wait before retrying the request.

Errors are an inevitable part of any API integration. Our API returns specific error codes to help you diagnose issues. A 401 error indicates an invalid key, which means you should check your authentication. A 402 error means you have no credit left, so you need to top up your account. A 429 error indicates a rate limit violation. By handling these errors appropriately, you can ensure a smooth user experience.

It is also important to monitor your token usage. Since you are charged per token, keeping track of your usage helps you manage your budget. The response includes usage statistics, which you can log and analyze. This data can help you optimize your prompts and reduce costs. For example, you might find that shorter prompts achieve the same result with fewer tokens.

If you encounter persistent errors, you can check the API documentation for more details. The service is designed to be reliable, but network issues or server maintenance can occasionally cause disruptions. In such cases, the API may return temporary errors. Implementing reliable error handling ensures that your application can recover from these issues without crashing.

When This API Is Not the Right Choice

While our API is powerful for text generation, it is not suitable for every use case. One major limitation is that it is text-only. If your application requires image generation, audio synthesis, or video creation, this API will not meet your needs. You would need to integrate with other services that specialize in those modalities.

Another limitation is the lack of fine-tuning capabilities. Our API serves a single uncensored model, and you cannot fine-tune it with your own data. If you need a model that is specialized for a specific domain or has been trained on your proprietary data, you might need to look for a different provider. The model is fixed, and its capabilities are determined by its training data.

Additionally, if you need embeddings for semantic search or clustering, this API does not provide them. You would need to use a separate embedding service. Similarly, if you require OCR for extracting text from images, you would need an OCR service. The API is focused on text generation, so it does not include these additional features.

Finally, if you need on-premises deployment for data privacy or compliance reasons, this hosted API might not be the best fit. Our service is hosted, meaning your data is processed on our servers. If you need to keep your data entirely within your own infrastructure, you might need to consider a different solution. However, for most developers who need a reliable uncensored text API, this service offers a simple and effective solution.

Addressing Community Questions on Model Selection

Developers often discuss model selection on platforms like r/StableDiffusion and r/LocalLLaMA. In these threads, users frequently ask about the best uncensored models for specific hardware configurations, such as 12GB or 16GB VRAM. Some users mention models like Z image turbo or Flux.2 Klein 9B for image generation, while others discuss local models like Qwen3.6-35B-A3B-Uncensored-HauhauCS-Aggressive-IQ3_M for text and vision tasks.

When it comes to text-only APIs, the conversation often shifts to ease of use and performance. Users on r/Chub_AI note that using an API can be significantly better than running a local model on limited hardware, such as a 6GB VRAM GPU. They suggest that even free API models can outperform local setups in terms of consistency and quality. This highlights the value of hosted APIs for developers who do not want to manage hardware.

Another common topic is the balance between model size and performance. Users running models on 16GB VRAM + 64GB RAM discuss quantization techniques to fit larger models into memory. However, for those who do not want to deal with quantization, an API provides a consistent experience regardless of the underlying model size. This is particularly useful for applications that need to scale without worrying about hardware constraints.

Overall, the community values reliability and ease of integration. While local models offer control, APIs offer convenience. Our API addresses this by providing a simple interface for accessing an uncensored model. Developers do not need to worry about model versioning or hardware compatibility. They can focus on building their application while relying on our infrastructure to handle the heavy lifting. This makes it an attractive option for indie builders and developers who want to move quickly.

Frequently asked questions

How do I set up the OpenAI SDK for the Abliterated Model API?

Configure the SDK with the base URL https://api.abliteratedmodel.cc/v1 and your API key. Set the model ID to uncensored in your requests. This allows you to use standard OpenAI SDK methods to send and receive text.

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 or large documents to be processed in a single request.

Does the API support image generation?

No, this is a text-only API. It does not support image, audio, or video generation. If you need multimodal capabilities, you will need to integrate with other services.

How much does it cost to use the API?

The pricing is $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. There is no monthly fee, and prepaid credit never expires. Errors and refusals are free.