EN ▾
Get API key

Integrating Qwen Abliterated via SDK

Developers often struggle with configuring the OpenAI-compatible endpoint for smooth integration. This guide provides a tested checklist of SDK settings to ensure your pipeline works reliably with our uncensored model. We cover streaming, function calling, and error handling in detail.

Developer desk with laptop showing code for API integration

Setting Up the Base Configuration

Integrating our API begins with establishing the correct base URL and model identifier. The endpoint for our chat completions is located at https://api.qwenabliterated.cc/v1. You must set your API key in the authorization header to authenticate your requests. Without a valid key, you will receive a 401 error, indicating an invalid or missing key.

The model identifier you need to send is simply uncensored. This tells the service which open-weight text model to use for generating responses. Our API serves only this one model, so there is no need to switch between different model versions or routing options. This simplicity reduces configuration errors and ensures consistent behavior across your application.

Authentication is handled via standard Bearer tokens. You can generate your key immediately after signing up with Google or an email and password. The key is shown to you right away, so make sure to copy it securely. Since we do not store your key after it is displayed, you must manage it yourself in your environment variables or secret manager.

It is important to note that our API is an independent service. It is not an official product of any other company, nor is it a reseller of their models. When you see references to OpenAI or other vendors in documentation, remember that they are separate entities. Always check the vendor's own documentation for their specific prices, limits, and features. Our API operates independently, offering a unique uncensored experience without claiming to be part of another ecosystem.

Configuring Parameters for Text Generation

Our API supports a range of parameters to fine-tune the text generation process. You can adjust the temperature to control the randomness of the output. A higher temperature leads to more creative and varied responses, while a lower temperature produces more deterministic and focused text. The default settings are usually sufficient for most use cases, but you can experiment to find the right balance for your specific needs.

Top-p sampling is another parameter that allows you to control the diversity of the output. By setting a top-p value, you limit the model to consider only the top tokens whose cumulative probability exceeds this threshold. This helps in generating more coherent and relevant text without getting stuck in repetitive patterns. You can also set a seed for reproducibility, which is useful for debugging and testing your integration.

Stop sequences allow you to define specific strings that signal the end of a response. This is particularly useful for structured data or when you want to prevent the model from generating unwanted content. For example, you might set a stop sequence to halt generation when a specific delimiter is encountered. This gives you more control over the output format and ensures that your application can parse the response correctly.

Penalties can be applied to discourage the model from repeating certain words or phrases. This is helpful for improving the fluency and readability of the generated text. By adjusting the penalty values, you can influence the model's tendency to reuse specific tokens. These parameters work together to give you precise control over the generation process, allowing you to tailor the output to your application's requirements.

Implementing Streaming and Function Calling

Streaming responses over Server-Sent Events (SSE) is a key feature for improving the user experience in chat applications. Our API supports streaming, allowing you to receive partial responses as they are generated. This reduces the perceived latency for users, making the interaction feel more responsive and natural. The usage information, such as token counts, is included in the last chunk of the stream, so you can track your credit usage accurately.

Function calling, or tool use, is another powerful feature that allows your application to interact with external services. You can define functions that the model can call, and the API will return structured data indicating which function to invoke and with what arguments. This enables complex workflows where the model can trigger actions in your application, such as fetching data from a database or sending an email.

JSON mode is available for applications that require structured output. By enabling JSON mode, the model is constrained to output valid JSON, which makes it easier to parse and process the response. This is particularly useful for applications that need to integrate with other systems that expect JSON data. You can also use JSON mode in combination with function calling to ensure that the output is always in the expected format.

When implementing streaming and function calling, it is important to handle the events correctly. You should listen for the different event types, such as message_start, message_delta, and message_end, to process the response appropriately. This ensures that your application can handle the response in real-time and update the user interface accordingly. Proper error handling is also important to ensure that the stream does not break unexpectedly.

Handling Errors and Rate Limits

Understanding error codes is essential for building a reliable integration with our API. A 401 error indicates an invalid or missing API key, which means you need to check your authentication setup. A 402 error signifies that you have run out of credit, 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.

Rate limits are enforced to ensure fair usage and prevent abuse. If you encounter a 429 error, you should implement exponential backoff in your retry logic to avoid overwhelming the API. This involves waiting for a short period before retrying the request, and increasing the wait time with each subsequent failure. This helps to prevent your application from being blocked due to excessive requests.

Errors and refusals are free, which means you are not charged for failed requests or responses that are refused due to content policies. This is a beneficial feature for testing and debugging, as you can experiment with different prompts without worrying about consuming your credit. However, it is important to note that the hard content limit applies, and requests involving sexual content with minors will be refused.

When handling errors, it is good practice to log them and provide feedback to the user. This helps in diagnosing issues and improving the user experience. You should also consider implementing a dashboard or monitoring system to track the health of your integration and identify any recurring issues. This proactive approach can help you stay ahead of potential problems and ensure a smooth user experience.

Pricing and Credit Management

Our API uses a prepaid credit system based on real token usage. The cost is $0.15 per 1 million input tokens and $0.50 per 1 million output tokens. This pricing model is transparent and allows you to pay only for what you use. There are no monthly fees or subscriptions, and your paid credit never expires. This makes it easy to budget for your API usage and avoid unexpected charges.

Top-ups can be made using cryptocurrency, specifically USDT on the TRC20 network or USDC on the Base network. You can top up with any whole amount between $20 and $500. Additionally, there is a bonus credit program for top-ups of $50 or more, which can give you an additional 5% to 15% bonus credit. This incentivizes larger top-ups and provides more value for your money.

It is important to note that we do not accept credit cards, PayPal, or bank transfers for top-ups. If you prefer to use traditional payment methods, you may need to use a crypto exchange or wallet to convert your funds into USDT or USDC. This is a trade-off that some users may find less convenient, but it offers privacy and speed for those who are comfortable with cryptocurrency.

New accounts receive $0.50 of trial credit, which allows you to test the API without any financial commitment. This trial credit is a great way to explore the features and capabilities of our API before deciding to top up. However, the trial credit is limited, so you will need to top up to continue using the service for more extensive testing or production use.

When Our API Is Not the Right Choice

While our API is excellent for uncensored text generation, it may not be the right choice for all projects. If you need features like image generation, audio processing, or video synthesis, our API does not support these capabilities. We focus solely on text-in, text-out interactions, so if your application requires multimodal outputs, you may need to look for a different solution.

Similarly, if you require embeddings, OCR, or fine-tuning capabilities, our API does not offer these features. Our service is designed for chat completions and function calling, so if you need to process images or fine-tune a model for a specific task, you will need to use a different provider. It is important to assess your project's requirements carefully to ensure that our API meets your needs.

Another consideration is the payment method. If you prefer to pay with credit cards or PayPal, our crypto-only top-up system may not be suitable for you. While we offer a convenient and private payment method, some users may find the process of converting fiat currency to cryptocurrency to be a barrier. In this case, you might want to consider a provider that accepts traditional payment methods.

Finally, if you need a service with a strong SLA or certifications like SOC2 or HIPAA, our API may not be the best fit. We do not claim to offer these guarantees, and our focus is on providing an uncensored and flexible text generation service. If your project requires strict compliance with industry standards, you should evaluate other providers that offer these certifications. Always check the vendor's documentation for current prices, limits, and features to make an informed decision.

Troubleshooting Common Integration Issues

One common issue developers face is incorrect configuration of the base URL or model ID. Ensure that you are using https://api.qwenabliterated.cc/v1 as your base URL and uncensored as your model ID. Double-check your API key to make sure it is valid and has not been revoked. If you are still experiencing issues, try making a simple request to the /v1/models endpoint to verify that your authentication is working correctly.

Another frequent problem is related to rate limits. If you are hitting the 300 requests per minute limit, you may need to implement backoff logic in your application. This involves waiting for a short period before retrying a request, and increasing the wait time with each failure. This helps to prevent your application from being blocked due to excessive requests. You can also monitor your usage to ensure that you are not exceeding the limit unexpectedly.

Errors in JSON mode or function calling can also cause integration issues. Make sure that your JSON output is valid and follows the expected schema. If you are using function calling, ensure that the function definitions are correct and that the model is returning the expected function calls. You can test your integration with a simple function call to verify that it is working as expected.

Finally, if you are experiencing issues with streaming, check that you are handling the SSE events correctly. Make sure that you are listening for the correct event types and processing them appropriately. If the stream is breaking unexpectedly, check your network connection and ensure that your application is handling errors gracefully. Proper error handling and logging can help you diagnose and resolve these issues quickly.

Frequently asked questions

How do I get my API key?

You can get your API key by signing up with Google or an email and password. The key is shown immediately after signup, so make sure to copy it securely. It is not stored after display, so you must manage it yourself.

What is the context window size?

Our API has a context window of 100,000 tokens, which includes both the prompt and the completion. This allows for long conversations and large inputs.

Can I use my own model?

No, our API serves only one uncensored open-weight text model with the ID 'uncensored'. You cannot upload or use your own model with this service.

What happens if I run out of credit?

If you run out of credit, you will receive a 402 error. You can top up your account with USDT on TRC20 or USDC on Base to continue using the service.