Integrating the Unrestricted API with Python
Developers often look for a straightforward way to integrate uncensored language models into their Python applications. This guide walks you through the specific steps required to connect to our API, handle streaming responses, and manage parameters like temperature and top_p. We focus on practical code examples that work with the /v1/chat/completions endpoint.

Setting Up Your Environment
To begin integrating our API, you need a Python environment with the requests library installed. This library handles HTTP connections efficiently and is widely used in the developer community. You will need your API key, which is displayed immediately after signing up with Google or an email and password. Ensure you store this key securely, as it is the only credential required for authentication.
Our API operates on a prepaid credit system, so you must have funds in your account before making requests. You can top up using USDT on TRC20 or USDC on Base, with amounts ranging from $20 to $500. There is no monthly subscription fee, and your paid credit never expires. Errors and refusals do not consume credit, which helps in testing your integration without cost.
Initialize your client by setting the base URL to https://api.unrestrictedgpt.cc/v1. This URL is the entry point for all your API interactions. You do not need to configure complex endpoints for embeddings or image generation, as our service focuses solely on text-in and text-out capabilities. This simplicity reduces the overhead in your Python code.
Always verify your key before making heavy requests. A 401 error indicates an invalid key, while a 402 error means you have no credit. A 429 error signals that you have hit the rate limit of 300 requests per minute. Handling these errors gracefully in your code ensures a smooth user experience when the model is processing your input.
Making Your First Request
The core interaction with our API involves sending a POST request to the /v1/chat/completions endpoint. You must include the model identifier uncensored in your request body. This model is an open-weight text model that does not refuse lawful adult, fictional, or controversial topics. It provides a text response based on the text input you provide.
Structure your request payload with a list of messages. Each message should have a role, such as user or assistant, and content. The API supports a context window of 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.
When you send the request, the API processes the input and returns a JSON response. The response contains the generated text, which you can extract and display to your users. Since this is a text-only API, you do not need to handle image or audio data. The focus is on pure text generation, making it ideal for chatbots, content generators, and research tools.
Remember that the model refuses requests involving sexual content with minors. This is a hard limit enforced by the service. Other controversial topics are generally allowed, providing flexibility for developers building uncensored applications. Always test your prompts to ensure they align with your application's specific needs and content guidelines.
Implementing Streaming Responses
Streaming is a critical feature for improving the user experience in chat applications. Our API supports streaming over Server-Sent Events (SSE). This allows you to receive the model's output token by token, rather than waiting for the entire response to complete. This reduces perceived latency and makes the interaction feel more responsive.
To enable streaming, set the stream parameter to true in your request. The API will then send a series of chunks. Each chunk contains a partial response. The final chunk includes the usage data, which tells you how many tokens were consumed. This is useful for tracking costs and monitoring API usage in real-time.
In your Python code, you can iterate over the streaming response. Process each chunk as it arrives and append it to your output buffer. This approach allows you to display the text as it is generated. It is particularly effective for long-form content generation or complex reasoning tasks where users benefit from seeing progress.
Be aware that streaming does not change the pricing model. You are still charged $0.15 per million input tokens and $0.50 per million output tokens. The streaming feature is purely a delivery mechanism. It does not affect the token count or the cost of the request. Use it to enhance the feel of your application without incurring additional fees.
Configuring Model Parameters
Our API offers several parameters to control the behavior of the model. The temperature parameter adjusts the randomness of the output. A higher temperature results in more creative and varied responses, while a lower temperature produces more deterministic and focused outputs. This is useful for tasks requiring precision versus those needing creativity.
The top_p parameter controls the diversity of the output by filtering the vocabulary. It works in conjunction with temperature to shape the response. You can also set stop sequences to halt the generation when a specific string is encountered. This is helpful for formatting output or stopping the model after a certain point.
Additionally, you can use the seed parameter to ensure reproducibility. If you set a specific seed, the model will produce the same output for the same input. This is valuable for testing and debugging your integration. The penalties parameter allows you to adjust the frequency and presence penalties, giving you finer control over the style of the text.
JSON mode is another important feature. You can instruct the model to output valid JSON, which is essential for integrating with other systems or databases. This ensures that your application can parse the response reliably. Combine this with the other parameters to create a reliable and flexible integration that meets your specific requirements.
Handling Errors and Limits
Understanding error codes is important for a stable integration. A 401 error means your API key is invalid or missing. A 402 error indicates that you have run out of credit. A 429 error signifies that you have exceeded the rate limit of 300 requests per minute. Your code should handle these errors gracefully, perhaps by retrying after a delay or prompting the user to top up.
The rate limit is per key, so if you have multiple keys, you can distribute the load. However, each key is subject to the same 300 requests per minute limit. This is a hard limit to prevent abuse and ensure fair usage. Monitor your usage to avoid hitting this limit unexpectedly, especially in high-traffic applications.
Errors and refusals do not consume credit. This is a significant advantage for testing. You can send many test requests without worrying about depleting your balance. This allows you to thoroughly test your integration and edge cases before deploying to production. It also reduces the risk of unexpected charges during development.
When an error occurs, log the details for debugging. Include the status code, the request payload, and the response body. This information is invaluable when troubleshooting issues with the API. Keep your code clean and modular, so you can easily update error handling logic as the API evolves. Regular testing ensures your integration remains reliable over time.
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 service does not offer those capabilities. It is a text-only API, so projects requiring multimodal outputs should look elsewhere.
Similarly, if you need embeddings for vector search, our API does not provide this feature. You would need to use a different service for embedding generation. The same applies to OCR, fine-tuning, and model routing. Our service focuses on uncensored text completion, so projects requiring these advanced features should consider other vendors.
Also, if you require a Service Level Agreement (SLA) with specific uptime guarantees, this service does not offer one. We are an independent service and do not claim SLA percentages or certifications like SOC2 or HIPAA. For enterprises requiring strict compliance and uptime guarantees, a different provider might be more suitable.
Finally, if you need to interact with multiple models or route requests dynamically, our API serves only one uncensored model. There is no model routing. If your application requires switching between different models based on the task, you would need to build that logic yourself or use a platform that supports multi-model routing. Evaluate your specific needs before committing to this integration.
Addressing Common Developer Questions
Developers often ask about the reliability of the uncensored model and how it handles controversial topics. The model does not refuse lawful adult, fictional, or security-research topics. This makes it ideal for applications where censorship is a concern. However, it does refuse sexual content involving minors, which is a hard limit. This balance allows for broad creative freedom while maintaining a basic content standard.
Another common question is about the cost structure. Users want to know how pricing works with streaming and long contexts. The price is $0.15 per million input tokens and $0.50 per million output tokens. Streaming does not change this. The context window is 100,000 tokens, which is quite large. This allows for extensive conversations without frequent resets. Users appreciate the prepaid model with no monthly fees.
Developers also inquire about the ease of integration. The API is OpenAI-compatible, which means existing code can often be adapted with minimal changes. The base URL is straightforward, and the endpoints are standard. This reduces the learning curve for developers familiar with other major LLM providers. The availability of a trial credit of $0.50 allows for easy testing without financial commitment.
Finally, users ask about the top-up process. The service accepts only crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up is $20, and the maximum is $500. Bonuses are available for top-ups of $50 or more. This crypto-only approach simplifies the payment process but requires users to have a crypto wallet. It is a niche but efficient method for funding accounts.
Frequently asked questions
How do I get an API key?
You can sign up using Google or an email and password. Your API key is displayed immediately after registration. Store it securely and use it for authentication in your requests.
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.
How much does the API cost?
The price is $0.15 per million input tokens and $0.50 per million output tokens. You pay for real token usage, and errors are free. There is no monthly subscription fee.
Can I use streaming for better UX?
Yes, the API supports streaming over Server-Sent Events. You can receive the model's output token by token, which reduces perceived latency. The final chunk includes usage data for tracking costs.