EN ▾
Get API key

Integrating Uncensored API with Python SDK

Many developers seek a reliable way to connect their applications to an uncensored text endpoint without dealing with complex filtering layers. This guide walks you through the integration process with specific SDK settings, a tested checklist for successful requests, and tips for handling text-in, text-out workflows.

Server rack connected to laptop representing API integration

Setting Up Your Environment

Before writing any code, you need to prepare your Python environment. The API uses standard OpenAI-compatible endpoints, which means you can use the widely adopted openai Python package. This compatibility reduces the learning curve significantly for developers already familiar with major language model providers. You will need to install the package using pip or your preferred package manager to ensure all dependencies are met.

Once installed, you must obtain your API key. The signup process is straightforward: you can continue with Google or use an email and password combination. Upon registration, the key is shown immediately, so copy it securely. This key is your primary authentication method for all subsequent requests. Without a valid key, the API will return a 401 error, indicating an invalid or missing key.

Next, you should configure your base URL. For this service, the base URL is https://api.unfilteredsearch.cc/v1. This URL directs your requests to the correct infrastructure. It is important to use this specific endpoint to ensure compatibility with the model and response formats. The API supports standard chat completions, responses, and model listing endpoints.

Finally, verify your environment by making a simple test request. This step confirms that your key is valid and your network connection is stable. A successful test request will return a valid response object. This initial setup phase is critical for a smooth integration process. It ensures that you are ready to send more complex requests without facing basic connectivity issues.

Configuring Request Parameters

After setting up your environment, you need to configure the parameters for your requests. The API supports several parameters that allow you to control the behavior of the model. These include temperature, top_p, stop, seed, and various penalties. Understanding these parameters is essential for achieving the desired output quality.

The temperature parameter controls the randomness of the output. A higher value makes the output more creative, while a lower value makes it more deterministic. The top_p parameter controls the diversity of the output by limiting the probability mass of the next token. Adjusting these values allows you to fine-tune the model's responses for specific use cases.

You can also use the stop parameter to define sequences where the API should stop generating text. This is useful for controlling the length of the output or ensuring that the response ends at a specific point. The seed parameter allows for reproducible results by fixing the random number generator. This is particularly useful for debugging and testing.

Penalties can be used to discourage the model from repeating certain words or phrases. This helps in generating more diverse and natural-sounding text. By carefully configuring these parameters, you can tailor the API's behavior to meet the specific needs of your application. It is important to experiment with different settings to find the optimal configuration for your use case.

Making Your First Request

With your environment set up and parameters configured, you are ready to make your first request. The API uses the POST /v1/chat/completions endpoint for sending messages. You need to provide the model ID, which is uncensored, along with your messages and the configured parameters. The model ID is a required field for all requests.

Your messages should be formatted as a list of dictionaries, each containing a role and content. The role can be system, user, or assistant. The content is the text of the message. This format is standard across many language model APIs, making it easy to adapt existing code.

Once you send the request, the API will process it and return a response. The response includes the generated text, as well as metadata such as token usage. You can parse this response to extract the generated text and use it in your application. It is important to handle the response correctly to ensure that your application functions as expected.

If the request fails, the API will return an error code. Common errors include 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. You should implement error handling in your code to manage these cases gracefully. This ensures that your application remains reliable even when encountering issues.

Handling Streaming and Responses

The API supports streaming over Server-Sent Events (SSE), which allows you to receive the response in chunks as it is generated. This is useful for applications that require real-time updates or for improving the perceived performance of the application. Streaming allows you to start displaying text to the user before the entire response is generated.

To enable streaming, you need to set the stream parameter to true in your request. The API will then send a series of events, each containing a portion of the response. The final event includes the usage information, such as the number of tokens consumed. This allows you to track the cost of the request in real-time.

When handling streaming responses, you need to process each event as it arrives. This can be done using a loop that iterates over the events and extracts the text. It is important to handle the events correctly to ensure that the text is displayed in the correct order. You may also want to handle any errors that occur during streaming.

Streaming is particularly useful for chat applications where the user expects immediate feedback. It provides a smoother user experience by reducing the wait time for the full response. However, it requires more complex error handling and state management compared to non-streaming responses. You should consider the trade-offs before deciding whether to use streaming.

When This API Is Not the Right Choice

While this API is powerful for text generation, it may not be the right choice for every use case. The API serves only one uncensored open-weight text model. It does not support embeddings, image, audio, or video generation, OCR, fine-tuning, or model routing. If your application requires these features, you may need to look for a different solution.

For example, if you need to generate images or process audio, this API will not meet your needs. Similarly, if you require fine-tuning on a specific dataset, this API does not offer that capability. The API is designed for text-in, text-out workflows, so it is best suited for applications that primarily involve natural language processing.

Additionally, the API has a context window of 100,000 tokens. While this is quite large, it may not be sufficient for applications that require processing extremely long documents or conversations. If you need to handle larger contexts, you may need to implement chunking strategies or use a different model.

Finally, the pricing model is based on token usage. If your application involves a high volume of requests with large token counts, the costs can add up quickly. It is important to monitor your usage and budget accordingly. If you are looking for a free unlimited tier or a subscription-based model, this API may not be the best fit.

Addressing Common Developer Questions

Developers often ask about finding cheap LLM API alternatives for side projects and budget-friendly options. Many users are looking for a reliable, uncensored LLM API that does not require fighting filters. The community discussions on platforms like r/startup and r/LocalLLaMA highlight the demand for straightforward integration and cost-effective solutions.

Users also inquire about the ease of integration with Python SDKs. The compatibility with standard OpenAI endpoints makes it easy for developers to switch from other providers. This reduces the barrier to entry for those who are already familiar with the OpenAI ecosystem. It allows for quick prototyping and deployment of applications.

Another common question is about the reliability of the API. Users want to ensure that the API can handle high volumes of requests without downtime. The rate limit of 300 requests per minute per key provides a good balance between performance and resource usage. Developers should monitor their usage to stay within these limits.

Finally, users often ask about the pricing structure. The prepaid credit model with no monthly fees is appealing to many developers. The ability to top up with crypto and the absence of hidden costs make it a transparent option. Developers should review the pricing details carefully to understand the costs associated with their usage.

Best Practices for Integration

To ensure a smooth integration, it is important to follow best practices for API usage. First, always handle errors gracefully. Implement retry logic for transient errors such as rate limits. This helps to maintain the stability of your application. You should also log errors for debugging purposes.

Second, monitor your token usage closely. The API charges based on token consumption, so it is important to track your usage to avoid unexpected costs. You can use the usage information provided in the response to monitor your spending. Setting up alerts for high usage can help you stay within your budget.

Third, optimize your prompts for efficiency. Use clear and concise prompts to reduce the number of tokens required. This can help lower your costs and improve the performance of your application. You should also experiment with different prompt structures to find the most effective approach.

Finally, keep your SDK and dependencies up to date. Regular updates can provide new features and bug fixes. This ensures that your application remains compatible with the API. You should also review the API documentation periodically to stay informed about any changes or updates.

Frequently asked questions

How do I get an API key?

You can sign up using Google or email and password. The key is shown immediately after registration. Copy it securely to use in your requests.

What is the cost of using the API?

The API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens. Credits are prepaid and never expire.

Can I stream responses?

Yes, the API supports streaming over SSE. Set the stream parameter to true to receive responses in chunks.

What happens if I run out of credit?

If you have no credit, the API returns a 402 error. You can top up with crypto to continue using the service.