EN ▾
Create key

Quickstart: integrate the uncensored api

Migrate your code to our uncensored LLM API by updating the base URL and API key. This quickstart guides you through integration using standard OpenAI-compatible clients.

Prerequisites: SDK and environment variables

Start by installing your preferred SDK and setting your credentials in environment variables. Our service uses standard OpenAI-compatible endpoints, so existing client libraries work without modification. You only need an API key from our dashboard and the base URL for your requests. No complex wrappers or custom headers are required for basic integration.

curl https://api.claudecostpermilliontokens.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 cost per million tokens for the Pro model?"}]
  }'

Ensure your environment variables are exported correctly before running your scripts. This approach keeps your authentication secure and your code portable across different deployment environments.

Instantiating the client with base URL

Configure your client library to point to our base URL instead of the default provider endpoint. Use the provided base URL and your API key to initialize the connection. This simple change directs all traffic to our uncensored model while maintaining compatibility with standard SDK methods.

from openai import OpenAI

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

Verify the connection by listing available models. This step confirms that your client is correctly routed to our infrastructure before you send any actual prompts or data.

Sending your first chat completion request

Send a standard chat completion request using the model ID uncensored. This model handles text input and output without content refusals for lawful adult use. You can pass messages, set temperature, and define other parameters just as you would with any other OpenAI-compatible endpoint.

import OpenAI from "openai";

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

Check the response for the generated text and token usage. This confirms that your integration is working correctly and that the model is responding as expected to your prompts.

Handling streaming responses and tokens

Enable streaming by setting the stream parameter to true in your request. The API returns chunks of text as they are generated, allowing you to display output in real time. Each chunk includes token usage data in the final chunk, helping you track consumption accurately.

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)

Process each chunk efficiently to maintain low latency. This method is ideal for applications where immediate feedback is crucial, such as chat interfaces or real-time code generation tools.

Using function calling and JSON mode

Leverage function calling and JSON mode for structured outputs. Set the response format to JSON to ensure consistent parsing in your application. You can also define tools and specify tool choices to guide the model’s output behavior.

Parameters like temperature, top_p, and stop sequences allow fine-tuning of the response style. Use these features to integrate the model seamlessly into your existing workflow.

Managing authentication and limits

Your API key authenticates all requests, with errors like 401 indicating an invalid key and 402 signaling insufficient credit. Rate limits cap you at 300 requests per minute and 8 concurrent requests per key. The context window supports up to 100,000 tokens, with a max output of 16,000 tokens per request.

Monitor your usage to avoid interruptions. Errors during processing are free, so you can retry requests without worrying about token consumption. Keep your key secure and replace it if needed through the dashboard.

Common questions

What is the claude cost per million tokens for this API?

Our pricing is $0.15 per million input tokens and $0.50 per million output tokens. This transparent model ensures you only pay for what you use, with no hidden fees or monthly subscriptions.

How do I handle rate limits and errors?

You are limited to 300 requests per minute and 8 concurrent requests per key. A 401 error means your key is invalid, while a 402 error indicates you need to add credit. Errors during processing do not consume tokens.

Is the uncensored model compatible with OpenAI SDKs?

Yes, our API is fully OpenAI-compatible. You can use standard SDKs by updating the base URL and API key. This allows for immediate code migration without complex wrappers or custom implementations.

Get your key in minutes

Sign up, copy your key, point your API to the new base URL. Simple.

Create key