Documentation

unchain-ai API

An OpenAI-compatible API for the same model as in the bot. Any OpenAI client works: the official SDKs, LangChain, coding agents. Just swap in the address and the key.

Base URL
https://unchain-ai.com/v1
Model
unchain-ai
Authorization
Authorization: Bearer sk-…
OpenAPI
/en/openapi.json

Quick start

  1. Open the bot (t.me/unchain_uncensored_ai_bot) and go to its “API for code” section (the bot's menus are in Russian for now).
  2. Tap “Issue token” and save the token: it is shown in full only once.
  3. Top up your balance in the bot: API requests are paid from the balance only; a subscription does not cover them.
  4. Send your first request:
bash
curl https://unchain-ai.com/v1/chat/completions \
  -H "Authorization: Bearer $UNCHAIN_AI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "unchain-ai",
    "messages": [{"role": "user", "content": "Hi! What can you do?"}]
  }'

Token

The token starts with sk- and goes in the Authorization: Bearer header. An account has one active token: “Reissue token” in the bot revokes the old one at once. Never publish the token in repositories or put it in your website's code: anyone who has it can spend your balance.

Examples

Python

python
# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://unchain-ai.com/v1", api_key=os.environ["UNCHAIN_AI_API_KEY"])

reply = client.chat.completions.create(
    model="unchain-ai",
    messages=[{"role": "user", "content": "Write a sorting function in Python"}],
)
print(reply.choices[0].message.content)

Node.js, streaming

javascript
// npm i openai
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://unchain-ai.com/v1", apiKey: process.env.UNCHAIN_AI_API_KEY });

const stream = await client.chat.completions.create({
  model: "unchain-ai",
  messages: [{ role: "user", content: "Explain what a closure is" }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");

stream, tools / tool_choice, temperature, max_tokens, response_format and the other Chat Completions parameters are supported. You can leave the model field as it is: every request is served by unchain-ai. When streaming, the last chunk before [DONE] carries usage.

Balance and usage

GET /me is free. It returns your balance, whether it covers a request, your limits and your usage over the last 24 hours and 30 days: a quick check before a big task.

bash
curl https://unchain-ai.com/v1/me -H "Authorization: Bearer $UNCHAIN_AI_API_KEY"
json
{
  "object": "account",
  "balance_usd": 4.2531,
  "min_balance_usd": 0.1,
  "can_request": true,
  "model": "unchain-ai",
  "max_concurrent_requests": 3,
  "token": { "last4": "a1b2", "created": 1760000000 },
  "usage": {
    "last_24h": { "requests": 42, "spent_usd": 0.318, "input_tokens": 512000, "output_tokens": 38000 },
    "last_30d": { "requests": 610, "spent_usd": 4.91, "input_tokens": 7800000, "output_tokens": 560000 }
  }
}

Code editors and agents

OpenCode, Cline, Cursor, Aider, Zed, JetBrains AI and others connect as an “OpenAI Compatible” provider with the address and model above. Step-by-step guides with ready-made configs are in the bot: “API for code” → “Agent guides”. OpenCode and Cline have video guides there too.

Pricing and limits

Token typeUSD per 1M tokens
Input$0.2975
Cached input$0.223125
Output$0.8925
  • Each request is charged to your USD balance based on the number of tokens of each type.
  • If your balance is below the minimum, the request is rejected with 402 and nothing is charged.
  • The number of concurrent requests is limited: extra ones get 429 with a Retry-After header.
  • If the model does not respond (502), the request is not charged.

Errors

Errors follow the OpenAI format, with the message in Russian and English:

json
{"error": {"message": "…", "type": "authentication_error", "code": "invalid_api_key"}}
HTTPcodeWhat to do
400invalid_requestThe body is not a JSON object or has no messages field
401invalid_api_keyThe token is missing, wrong or has been reissued
402insufficient_balanceThe balance is below the minimum: top it up in the bot
413request_too_largeThe request is too large
429concurrency_limitToo many concurrent requests: retry after the Retry-After delay
502upstream_errorThe model is temporarily unavailable: retry later
503maintenanceMaintenance