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
- 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).
- Tap “Issue token” and save the token: it is shown in full only once.
- Top up your balance in the bot: API requests are paid from the balance only; a subscription does not cover them.
- Send your first request:
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
# 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
// 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.
curl https://unchain-ai.com/v1/me -H "Authorization: Bearer $UNCHAIN_AI_API_KEY"{
"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 type | USD 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-Afterheader. - 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:
{"error": {"message": "…", "type": "authentication_error", "code": "invalid_api_key"}}| HTTP | code | What to do |
|---|---|---|
| 400 | invalid_request | The body is not a JSON object or has no messages field |
| 401 | invalid_api_key | The token is missing, wrong or has been reissued |
| 402 | insufficient_balance | The balance is below the minimum: top it up in the bot |
| 413 | request_too_large | The request is too large |
| 429 | concurrency_limit | Too many concurrent requests: retry after the Retry-After delay |
| 502 | upstream_error | The model is temporarily unavailable: retry later |
| 503 | maintenance | Maintenance |