fr ▾
Claim trial key

API Documentation

This page documents the OpenAI-compatible API for uncensored coding and text generation, providing the base URL, endpoints, and SDK examples needed to integrate immediately.

https://api.claudecodeapikeys.com/v1uncensored

Base URL and Authentication

The base URL for all requests is https://api.claudecodeapikeys.com/v1. Authentication relies on a single API key passed via the Authorization header. You obtain this key by signing in with Google or an email address on the Get API key page. The key appears immediately and replaces any previous key upon generation. Use this key for all subsequent requests to the uncensored AI models.

Chat Completions Endpoint

Send your prompts to POST /v1/chat/completions. This endpoint accepts standard OpenAI JSON structures and returns text responses. You must specify the model ID as uncensored. The system processes your input and generates a completion within the context window limits. Use the following example to verify connectivity and response formatting:

curl https://api.claudecodeapikeys.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "what is the current release date of the library"}]
  }'

This request demonstrates the basic structure required for successful API interaction.

Models Endpoint

Retrieve available models using GET /v1/models. This endpoint returns a list of supported models, including the primary uncensored model. You can verify the model ID before sending completion requests. The response confirms the model is active and ready for use. This endpoint helps you ensure your client code targets the correct model identifier.

Streaming and SSE

Enable streaming by setting stream: true in your request body. The API returns Server-Sent Events (SSE) containing partial tokens. Token usage statistics appear in the final chunk of the stream. This approach reduces perceived latency for long coding outputs. Implement an event listener to process each token as it arrives:

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)

Streaming is ideal for real-time coding assistance where immediate feedback matters more than batch processing.

Function Calling and Tools

The API supports function calling via the tools and tool_choice parameters. Define your function schemas in the request body to enable structured tool usage. The model returns tool calls when appropriate, allowing you to execute external logic. This feature works seamlessly with the uncensored model for code generation tasks.

from openai import OpenAI

client = OpenAI(base_url="https://api.claudecodeapikeys.com/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)

Use this Python snippet to integrate tool calling into your application logic efficiently.

Rate Limits, Errors, and Constraints

Each API key is limited to 300 requests per minute and 8 concurrent requests. The maximum request body size is 8 MB. You may receive a 401 error if the key is invalid, a 402 error if credit is exhausted, or a 429 error for rate limiting. The context window supports 100,000 tokens total, with a maximum output of 16,000 tokens per request. Errors and refusals do not consume credit, so you can experiment freely.

Node.js

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.claudecodeapikeys.com/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);
#07

Common questions

What is the context window size for the uncensored coding AI?

The context window supports 100,000 tokens for both prompt and completion combined. You can generate up to 16,000 tokens per request, or 2,048 tokens if you do not set the <code>max_tokens</code> parameter. This allows for extensive code generation within a single request.

How do I handle authentication errors with the openai compatible API?

A <code>401</code> status code indicates an invalid or expired API key. Ensure you are using the correct key from the <strong>Get API key</strong> page. If you generated a new key, the old one becomes invalid immediately. Use the new key for all subsequent requests to resolve this error.

What happens when I run out of credit?

You will receive a <code>402</code> status code when your prepaid credit is exhausted. Errors and refusals do not consume credit, so you can still test the API without charge. Top up your account with crypto to continue using the service immediately.

Access your key

Register, retrieve your key, and update the base URL. That covers the entire configuration.