Start now
  1. API AI Cheapest
  2. Quickstart: Integrate the Uncensored LLM API

Quickstart: Integrate the Uncensored LLM API

Integrate our uncensored LLM API using standard OpenAI-compatible endpoints. This quickstart guides you from API key retrieval to streaming responses and function calling.

Prerequisites: SDK and API Key

Start by creating an account to receive your unique API key. Sign in with Google or an email password to generate a key instantly without phone verification. Install your preferred SDK package, such as openai for Python, and configure it with the base URL https://api.apiaicheapest.com/v1. Authenticate every request by setting the Authorization header to Bearer YOUR_API_KEY. You can test connectivity immediately using the provided examples.

Basic Chat Completion Request

Send a standard chat completion request to generate text responses. The API accepts a list of messages and returns the model's output. Use the model ID uncensored to access our open-weight model without content refusals. Every response includes token usage details for accurate billing tracking. Errors like insufficient credit or invalid keys are returned with clear HTTP status codes.

curl https://api.apiaicheapest.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Convert this Python list to a JSON array"}]
  }'

Streaming Responses (SSE)

Enable streaming to receive tokens in real-time as they are generated. Set the stream parameter to true in your request body. The server returns a sequence of Server-Sent Events (SSE) containing partial completions. Read the final chunk to get the total token count and cost. This approach reduces perceived latency for end-users significantly.

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)

Function Calling (Tools)

Define tools to allow the model to call external functions dynamically. Pass a list of tool definitions in the tools parameter and specify tool_choice as auto. The model returns function arguments in JSON format when appropriate. Parse these arguments in your code to execute the required logic. This feature enables complex agent workflows and data extraction tasks.

import OpenAI from "openai";

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

JSON Mode and Parameters

Force structured output by setting response_format to {"type": "json_object"}. This ensures the model returns valid JSON, which is crucial for programmatic consumption. You can also control randomness with temperature and top_p, or stop sequences. Adjust these parameters to balance creativity and precision. The model supports a context window of 100,000 tokens for long documents.

Handling Limits and Errors

Monitor rate limits and error responses to maintain smooth integration. The API allows 300 requests per minute per key with a concurrency limit of 8 simultaneous requests. Handle HTTP 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. Increase your prepaid credit via crypto top-ups to avoid service interruptions. Always check the usage field in responses to track token consumption accurately.

Python

from openai import OpenAI

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

Frequently asked questions

What is the cheapest AI API for basic text generation?

Our API offers transparent pricing at $0.15 per 1M input tokens and $0.50 per 1M output tokens. There is no minimum spend, and prepaid credit never expires, making it cost-effective for variable usage patterns.

Does the uncensored LLM support function calling?

Yes, the model supports function calling with standard tool definitions. You can pass tools and set tool_choice to auto for dynamic function invocation. This allows for complex workflows and data extraction tasks.

How do I handle rate limits on the cheapest LLM API?

The API limits requests to 300 per minute per key with a maximum of 8 concurrent requests. If you exceed these limits, you will receive a 429 status code. Implement exponential backoff in your client to handle retries gracefully.

Get your key in seconds

Sign up, retrieve your key, update the base URL. That’s it.