EN ▾
Get API key

uncensored.chat API: Troubleshooting Guide

When building AI applications with the uncensored.chat api, developers often encounter specific hurdles around streaming, tool usage, and token management. This guide provides concrete troubleshooting steps for the uncensored llm api to help you resolve common integration errors quickly.

uncensored.chat API: Troubleshooting Guide

Updated

Key points

  • The uncensored.ai api strictly enforces a 100k context window and 16k max output limit, requiring careful token management.
  • Streaming responses via SSE deliver token usage statistics only in the final chunk, not each one.
  • Function calling requires explicit tool definitions and often needs multiple rounds of conversation to execute complex tools.
  • JSON mode failures usually stem from the model breaking schema rules; using a schema validator helps debug the output.

Understanding the uncensored.chat api Endpoint

The uncensored.chat api follows the standard OpenAI-compatible chat.completions structure. You interact with it by sending POST requests to https://api.unfilteredchat.cc/v1/chat/completions. Unlike some platforms that offer a vast array of endpoints for embeddings or audio, this API is focused entirely on text generation. The base URL is consistent, and you can use any standard OpenAI SDK by simply updating the base URL and providing your API key.

It is important to remember that this is a single-model service. The model ID you send is uncensored. It is an open-weight model tuned for minimal content refusals, but it is not GPT, Claude, or any other vendor's model. Because it is a single model, you do not need to manage routing logic between different providers. This simplifies your codebase significantly.

The API only supports text input and text output. If your application requires image generation or audio transcription, you will need to handle those steps separately. The endpoint is designed for direct, raw text responses, making it ideal for applications that need unfiltered creative writing, roleplay, or data extraction without content filters interfering with the output.

Common Authentication Errors

Authentication errors are the most frequent hurdle when starting with the uncensored ai api. The most common error is a 401 Unauthorized response, which indicates that your API key is missing, invalid, or expired. Ensure you are passing the key in the Authorization header as a Bearer token: Authorization: Bearer YOUR_API_KEY.

If you receive a 403 Forbidden error, it usually means your account lacks sufficient credit or your key has been deactivated. Unlike some services that offer free tiers, this API requires prepaid credit. You can check your balance and manage your key on the dashboard. Remember that each account is limited to one active key. If you generate a new key, the previous one is immediately invalidated.

Another common issue is using the wrong base URL. Ensure you are using https://api.unfilteredchat.cc/v1 and not a generic OpenAI URL. The endpoint structure is compatible, but the server is different. If you are using the official OpenAI SDK, you can override the base URL in your client configuration. Double-check that you are not accidentally using a development key in a production environment or vice versa.

Handling Streaming Responses

Streaming is supported via Server-Sent Events (SSE). When you set stream: true, the API returns a stream of chunks. Each chunk contains a partial delta of the response. This is useful for providing real-time feedback to users in a chat interface.

One critical detail is that token usage statistics are only included in the final chunk of the stream. If you are tracking usage for billing or analytics, you must parse the last chunk to get the total input and output tokens. Intermediate chunks do not contain usage data.

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

If you encounter issues with streaming, such as the connection dropping prematurely, ensure your client handles SSE errors gracefully. The uncensored llm api does not guarantee a specific SLA, so network interruptions can occur. Implement retry logic for your streaming connections if real-time performance is critical. Remember that streaming consumes the same tokens as a non-streamed request, so your billing will be identical.

Function Calling Pitfalls

Function calling allows the model to output structured data that your application can execute. To use this feature, you must provide a tools array with the function definitions. The model will then decide whether to call a function based on the user's input.

A common pitfall is not handling the multi-turn conversation correctly. When the model calls a function, it returns a response with a tool_calls field. Your application must execute the function, collect the result, and send it back to the API as a tool message in the next turn. If you skip this step, the model may get stuck or produce incorrect outputs.

Ensure that your function definitions are clear and well-documented. Ambiguous parameters can lead to the model calling the wrong function or providing incorrect arguments. Test your tools thoroughly before integrating them into your main application. The uncensored model is capable of complex tool usage, but it relies on clear instructions and well-structured schemas.

JSON Mode Validation

JSON mode ensures that the model's output is valid JSON. You can enable this by setting response_format: {"type": "json_object"}. This is useful for applications that require structured data, such as extracting information from text or generating configuration files.

However, JSON mode does not guarantee that the output matches your specific schema. The model may produce valid JSON that does not adhere to your expected structure. To mitigate this, use a JSON schema validator on the client side to check the output. If the output is invalid, you can retry the request with a more detailed prompt or adjust the model's parameters.

from openai import OpenAI

client = OpenAI(base_url="https://api.unfilteredchat.cc/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Debugging JSON mode issues often involves examining the model's raw output. If the JSON is malformed, check for syntax errors such as missing commas or quotes. Adjusting the temperature can also help; lower temperatures produce more deterministic outputs, which can improve JSON consistency. Remember that JSON mode consumes tokens just like regular text generation, so monitor your usage accordingly.

Token Limit Management

The uncensored api has a context window of 100,000 tokens, which includes both the prompt and the completion. There is no separate output cap. If you do not specify a max_tokens limit, the response can run to the end of the window.

To manage tokens effectively, keep track of the token count in your conversation history. Many SDKs provide token counting utilities. If you approach the limit, you may need to truncate older messages or summarize previous context. Sending too many tokens can lead to errors or increased latency.

Be aware that the 100k limit is a hard constraint. If your prompt exceeds this limit, the API will return an error. Plan your application's architecture to handle token overflow gracefully. For example, you might implement a sliding window mechanism that retains only the most recent relevant context. This ensures that your application remains responsive and within budget.

Rate Limiting and Retries

The API enforces a rate limit of 300 requests per minute per key. If you exceed this limit, you will receive a 429 Too Many Requests error. Additionally, you are limited to 8 concurrent requests per key. These limits are designed to ensure fair usage and maintain service stability.

To handle rate limiting, implement exponential backoff in your retry logic. When you receive a 429 error, wait for a short period before retrying. The longer you wait, the smaller the backoff multiplier should be. This prevents your application from overwhelming the API during peak usage times.

Monitor your request patterns to ensure you stay within the limits. If you have multiple users or high traffic, consider distributing requests across multiple API keys. Remember that each account is limited to one active key, so you may need to create multiple accounts if you need higher throughput. Keep an eye on your concurrent request limit as well, as exceeding it can also result in errors.

Optimizing Input Tokens

Optimizing input tokens can reduce costs and improve response times. One effective strategy is to condense your prompts. Remove unnecessary whitespace and redundant information. Use concise language to convey your instructions clearly.

Another approach is to use system messages to set the context once, rather than repeating it in every user message. This reduces the token count for each subsequent interaction. For example, you can define the model's persona and rules in the system message, and then send shorter user prompts.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.unfilteredchat.cc/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Consider using function calling to offload some of the logic to your application. Instead of including complex instructions in the prompt, you can pass structured data to the model. This not only saves tokens but also makes the model's responses more predictable. Regularly review your prompt structure to identify areas for optimization. Small changes can lead to significant savings in token usage over time.

Debugging Response Formats

When debugging response formats, start by examining the raw output from the API. Sometimes, the issue lies in how the SDK parses the response. Ensure that you are handling the response object correctly and accessing the necessary fields.

If the model is producing unexpected output, try adjusting the temperature and top_p parameters. Lower values make the output more deterministic, while higher values increase creativity. Experiment with these settings to find the right balance for your use case.

curl https://api.unfilteredchat.cc/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
  }'

Use logging to capture the full request and response cycle. This helps you identify any discrepancies between what you sent and what you received. If the model is refusing to answer a lawful adult topic, check if the refusal is due to a specific keyword or phrase. The uncensored model is designed to be minimal in its refusals, but it may still block certain content. Adjust your prompts to avoid triggering unnecessary refusals.

Questions and answers

Does the uncensored.ai api support image generation?

No, the uncensored chat api is a text-only service. It does not support image, audio, or video generation. You will need to use a separate service for those capabilities.

How do I top up my credit?

You can top up your credit by crypto (USDT on TRC20, USDC on Base). The minimum top-up amount is $20, and the maximum is $500.

Is there a free tier available?

We do not offer a free tier. However, new accounts receive $0.50 of trial credit valid for 7 days. Claim this credit with one click on your API key page. No credit card is needed to start.

What is the context window size?

The context window is 100,000 tokens, which includes both the prompt and the completion. There is no separate output cap per request.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.