EN ▾
Get API key

Integrating Uncensored GPT API with Python SDK

Developers often look for a reliable method to connect to an uncensored GPT API using standard OpenAI-compatible SDKs. This guide provides clear instructions for setting up authentication, configuring base URLs, and testing the connection to ensure your integration works correctly.

Developer workspace with laptop and neural network graphic

Setting Up Your Environment

Before you can make any requests, you need to install the necessary Python packages. The most common library for interacting with OpenAI-compatible APIs is the openai package. You can install it using pip by running pip install openai in your terminal. This library provides the client object that handles the HTTP requests and response parsing for you.

Once installed, you will need to obtain your API key from our platform. When you sign up using Google or email, your key is shown immediately. Copy this key and store it securely. You should avoid hardcoding it directly into your source files if possible, using environment variables instead for better security practices.

Next, define the base URL for our service. This is https://api.uncensoredgpt.cc/v1. By setting this URL, you tell the SDK where to send your requests. This base URL is critical because it points to our specific uncensored model endpoint rather than the default OpenAI servers.

Initialize the client object in your Python script. Pass your API key and the base URL to the client constructor. This setup ensures that all subsequent calls are routed through our uncensored infrastructure. Make sure to verify that the URL is correct to avoid connection errors later in the process.

Configuring Authentication

Authentication is handled via an API key sent in the header of your requests. Our API expects the key to be passed as a Bearer token. The Python SDK handles this automatically when you provide the key during client initialization. You do not need to manually construct the header string unless you are making raw HTTP requests.

Ensure that your key is valid and has not been revoked. If you encounter a 401 error, it means your key is invalid. Check that you copied the key exactly as it appeared during signup. Typos are common, so double-check the string before proceeding with your integration.

If you receive a 402 error, it indicates that you have no credit left. Our service uses prepaid credit, so you must top up before making requests. You can add credit using USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. Credit never expires, so you can use it whenever you need it.

Keep your API key secure and do not share it publicly. If you suspect your key has been compromised, you can generate a new one from your dashboard. The old key will stop working immediately. This ensures that unauthorized users cannot consume your credit while you resolve the security issue.

Making Your First Request

Now that your client is configured, you can send your first request. Use the chat.completions.create method to interact with the model. Specify the model ID as uncensored. This tells the API which model to use for generating the response. Our API serves one uncensored open-weight text model, so this ID is the only option available.

Provide a list of messages in the request. Each message should have a role, such as user or assistant, and content. The model responds with text based on the context you provide. You can send multiple messages to create a conversation history. The model maintains context up to 100,000 tokens.

Check the response for the generated text. The SDK returns a structured object containing the response details. You can access the text content from the response object. If the request fails, check the error code. A 429 error means you have hit the rate limit of 300 requests per minute. Wait a moment and retry your request.

Test different types of prompts to see how the model responds. You can ask for creative writing, technical explanations, or role-playing scenarios. The model does not refuse lawful adult, fictional, or controversial topics. This makes it suitable for applications where standard filters might be too restrictive.

Handling Parameters and Features

Our API supports several parameters to customize the model's behavior. You can set the temperature to control randomness, with higher values producing more creative outputs. The top_p parameter limits the nucleus sampling, while stop sequences can halt generation at specific points. You can also set a seed for reproducible results.

Function calling is supported, allowing you to define tools that the model can use. This is useful for building agents that interact with external systems. You can also enable JSON mode to force the model to output valid JSON. This is helpful for parsing structured data from the model's responses.

Streaming is available over Server-Sent Events (SSE). This allows you to receive tokens as they are generated, providing a smoother user experience for real-time applications. The SDK supports streaming, so you can iterate over the response chunks as they arrive. This is particularly useful for chat interfaces where users expect immediate feedback.

Penalties can be applied to discourage repetitive or unwanted patterns in the output. You can adjust these penalties to fine-tune the model's style. Experiment with different parameter combinations to find the best settings for your specific use case. The API charges based on token usage, so efficient prompting can help manage costs.

When This API Is Not the Right Choice

While our API is powerful for text generation, it may not be the right choice for all projects. If you need image, audio, or video generation, this service does not support those capabilities. It is strictly a text-in, text-out API. You would need to integrate with other services for multimodal outputs.

If you require embeddings for semantic search, our API does not provide this feature. You would need to use a separate embedding model or service. Similarly, if you need OCR to extract text from images, this API will not handle that for you. Stick to tasks that involve pure text processing.

Fine-tuning is not available on this platform. If you need to train the model on your specific dataset, you would need to look for a service that supports fine-tuning. Our API serves a single uncensored model, so you cannot train custom versions. Check the documentation of other providers if you need this capability.

Model routing is also not supported. You cannot switch between different models dynamically within a single request. The API always uses the uncensored model. If your application requires switching between models based on performance or cost, this service may not fit your needs. Evaluate your requirements carefully before integrating.

Addressing Common Community Questions

Developers often ask about setting up uncensored GPT on local hardware, such as a converted Chromebox running Linux Mint. While our API is hosted, you can still use it from any device with internet access. You do not need to store data locally if you prefer a cloud-based solution. This simplifies the setup process significantly.

Another common question is whether the service is shut down or offline. Our API is active and available for use. You can verify this by making a simple request. If you experience connectivity issues, check your internet connection and API key. The service is hosted and managed, so you do not need to worry about server maintenance.

Users also inquire about the difference between local LLMs and our hosted API. Local models require significant VRAM and computational power. Our API handles the heavy lifting on our servers, allowing you to run complex models on lighter hardware. This is ideal for developers who want to focus on application logic rather than infrastructure management.

Some users discuss the quality of uncensored models compared to standard ones. Our model is designed to be less restrictive, allowing for more creative and diverse outputs. However, the quality may vary depending on the specific task. It is always a good idea to test the model with your specific prompts to ensure it meets your expectations.

Troubleshooting and Best Practices

If you encounter errors, check the status codes returned by the API. A 401 error means your key is invalid. A 402 error indicates insufficient credit. A 429 error means you have exceeded the rate limit. Use these codes to diagnose issues quickly. You can also check the response body for more detailed error messages.

Always handle errors gracefully in your code. Catch exceptions and provide meaningful feedback to your users. If the API is down or rate-limited, inform the user and suggest retrying later. This improves the user experience and reduces frustration. Avoid crashing your application when the API returns an error.

Monitor your token usage to manage costs effectively. Our API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. Keep track of your usage to avoid unexpected charges. You can top up your credit anytime using crypto. The prepaid credit never expires, so you can use it whenever you need it.

Finally, keep your code organized and modular. Separate the API interaction logic from your application logic. This makes it easier to switch providers or update the API version in the future. Use environment variables for sensitive data like API keys. This ensures your code is secure and portable across different environments.

Frequently asked questions

How do I set up the base URL for the uncensored API?

Set the base URL to https://api.uncensoredgpt.cc/v1 in your Python SDK client configuration. This ensures all requests are routed to our uncensored endpoint.

What happens if I run out of credit?

You will receive a 402 error. You can top up your credit using USDT on TRC20 or USDC on Base. The minimum top-up is $20.

Does the API support image generation?

No, this API is text-only. It does not support image, audio, or video generation. You need to use other services for multimodal outputs.

How can I handle rate limits?

If you hit the 300 requests per minute limit, wait a moment and retry. You can also implement exponential backoff in your code to handle retries automatically.