EN ▾
Start now

apiinference.com/Integration

Quickstart: Integrate the inference api

Integrate our uncensored inference API in minutes using standard OpenAI-compatible clients. Get your API key, set your base URL, and start sending text without refusals.

Get your uncensored inference API key

Authentication requires a single API key generated from your account dashboard. Sign up using Google or email and password; no phone number is required. Your key appears immediately on the screen and is valid for all requests. Each account holds only one active key; generating a new one invalidates the previous key. Keep this key secure, as it controls your prepaid credit.

Configure your base URL

Point your OpenAI-compatible SDK to our endpoint. Use https://api.apiinference.com/v1 as the base URL. This standard path works with official libraries and third-party clients. Set your API key in the OPENAI_API_KEY environment variable or pass it directly in the client configuration. No extra headers are required for basic text generation.

curl https://api.apiinference.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Fix the syntax error in this Python function"}]
  }'

Send your first chat completion

Make a POST /v1/chat/completions request with the model ID uncensored. The API accepts standard message arrays and returns text responses. Input costs $0.15 per 1M tokens, and output costs $0.50 per 1M tokens. Errors do not consume credit. Refusals for lawful content also do not charge tokens. Use JSON mode for structured data extraction.

from openai import OpenAI

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

Handle streaming responses

Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) containing incremental tokens. Token usage and metadata appear in the final chunk of the stream. This reduces perceived latency for your users. Read the stream until the done event or empty content indicates completion.

import OpenAI from "openai";

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

Use function calling and JSON mode

Define tools in the tools array to enable function calling. The model responds with tool calls instead of direct text. You can also force JSON output using response_format: {"type": "json_object"}. This ensures predictable parsing for your SaaS pipelines. Adjust temperature and top_p to control randomness. Use stop sequences to truncate outputs early.

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)

Understand limits and errors

Your key allows 300 requests per minute and 8 concurrent requests. The maximum request body size is 8 MB. The context window supports 100,000 tokens total. A 401 error means your key is invalid. A 402 error indicates insufficient prepaid credit. A 429 error signals rate limit exhaustion. Errors are free; you are only charged for successful token generation.

01

Common questions

What is the context window for the uncensored inference API?

The model supports a 100,000-token context window for both prompt and completion combined. You can generate up to 16,000 tokens per request. If you do not set <code>max_tokens</code>, the default output limit is 2,048 tokens.

Why is my API key returning a 404 status?

A 404 status typically indicates that the requested endpoint or resource does not exist, often due to an incorrect base URL or model ID. Ensure you are using <code>https://api.apiinference.com/v1</code> and the model ID <code>uncensored</code>. Check that your API key is active and correctly formatted.

How does billing work for the inference API?

You pay only for tokens used. Input costs <code>$0.15</code> per 1M tokens, and output costs <code>$0.50</code> per 1M tokens. Errors and refusals are free. You top up with crypto (USDT or USDC). Credit never expires, and no monthly subscription is required.

Generate your key now

Sign up, copy the key, update your base URL. That is the entire configuration.