Unrestricted AI API for your code and apps
The UNCHAIN AI API connects your code to the same model that answers in the Telegram bot. It speaks the OpenAI Chat Completions format, so any OpenAI client works: you change only the Base URL and the key. Streaming and tool calling are supported. Requests are paid from your balance by input and output tokens.
What is the UNCHAIN AI API?
An OpenAI-compatible API is programmatic access to a model in the same request and response format as OpenAI Chat Completions. Through the UNCHAIN API, your script or editor gets answers from the UNCHAIN model with no chat window and no copy-pasting. It is the same model that works in the Telegram bot.
A project built on the openai library for Python or Node.js needs no rewrite: the messages format, the request parameters and the parsing of choices in the response stay the same. Only the server address and the key change.
If you want a chat rather than programmatic access, the same model works as an AI without restrictions in Telegram and the browser.
How do I connect the API and send my first request?
Connecting to the UNCHAIN API takes four steps: issue a key, top up your balance, set the Base URL in your client and send a first request to POST /v1/chat/completions. The key is issued in the same account you chat from: in the Telegram bot or in the web app.
Issue a key
In the Telegram bot, open the “API for code” section and tap “Issue token”. In the web app, the key is issued in “Agent mode”. A key of the form
sk-…is shown in full only once, so save it right away.Top up your balance
API requests are charged to the balance only; a subscription plan doesn't cover them. You can top up in the bot or in the web app; the available methods are listed on the pricing and payment methods page.
Set the Base URL and the key
The bot shows the Base URL and the model name in the “API for code” section, with copy buttons; the address is also in the API docs. In an OpenAI client, put it in place of the server address and pass the key as
api_key. In a plain HTTP request, the key goes in theAuthorization: Bearer sk-…header.Send your first request
The example is in Python with the openai library. It takes the model name from
GET /v1/modelsand prints the answer and the number of tokens spent to the console.
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://<API address>/v1", # Base URL from the bot or the docs
api_key=os.environ["UNCHAIN_API_KEY"], # sk-… key from the bot or the web app
)
# The API serves a single model; its name comes from GET /v1/models
model = client.models.list().data[0].id
reply = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "Answer briefly and include a code example."},
{"role": "user", "content": "How do I read a CSV in pandas and skip the first two rows?"},
],
)
print(reply.choices[0].message.content)
print(reply.usage) # input and output tokens: the charge is based on themWhat does the OpenAI-compatible API support?
The UNCHAIN API runs on three endpoints: POST /v1/chat/completions returns the model's answers, GET /v1/models returns its name and GET /v1/me shows your balance and spending. An answer request supports streaming, tool calling and generation settings. The table shows what to send and what comes back.
| Feature | What to send | What comes back |
|---|---|---|
| Model answer | POST /v1/chat/completions with a messages array | a chat.completion object with a usage field |
| Streaming | stream: true | SSE chunks, usage in the last one before [DONE] |
| Tool calling | tools and tool_choice | tool_calls in the model's message |
| Generation settings | temperature, top_p, max_tokens, stop | an answer with those parameters |
| JSON output | response_format | an answer in the specified format |
| Model list | GET /v1/models | the name of the single model |
| Balance and spending | GET /v1/me | balance, limits, spending over 24 hours and 30 days |
Data: the API docs and the /openapi.json specification as of November 29, 2026. | ||
How is the API paid for, and what limits it?
Requests to the UNCHAIN API are paid from a dollar balance only. The bot's subscription and free requests don't apply to the API. Each request is charged by its number of input and output tokens, so a short question costs less than a long conversation with a big message history.
How does API billing differ from the bot?
The bot and the API share one model, but they are billed by different rules.
| Condition | Bot and web app | API |
|---|---|---|
| Subscription | covers answers within the limit | doesn't apply |
| Free requests | yes, text only | no |
| Balance | charged beyond the subscription | the only way to pay |
| Access | Telegram account or email | an sk-… key |
| No answer received | not charged | code 502, not charged |
| Data: service terms and the API docs as of November 29, 2026. | ||
What limits apply to requests?
- Balance below the minimum: the request is rejected with code 402, and nothing is charged.
- Too many parallel requests: the extra ones get code 429 with a
Retry-Afterheader. - Request body too large: the response is code 413.
- An account has one active key: issuing a new one revokes the old one at once.
The free GET /v1/me returns the current thresholds of your account. Its response shows whether your balance covers the next request, plus your spending over the last day and the last 30 days.
Which code editors and agents work with the API?
The UNCHAIN API plugs into code editors and coding agents as an OpenAI-compatible provider: OpenCode, Aider, Crush, Qwen Code, Goose, Cline, Kilo Code, Cursor, Zed and JetBrains AI Assistant. In the provider settings you enter the Base URL, the sk-… key and the model name from GET /v1/models.
A coding agent needs two API modes. Through tool calling (tools) it works with files and commands, and streaming (stream) prints the text as it is generated. The UNCHAIN API supports both.
Review the code the model writes before you run it: AI answers can contain inaccuracies and bugs. An agent's requests are paid from the same balance as the requests of your scripts.
API questions
How much does the UNCHAIN AI API cost?
The UNCHAIN AI API is pay-as-you-go: each request charges your balance by input and output tokens, with no monthly fee. For a request to go through, the balance must hold at least $0.10; otherwise the API returns code 402 and charges nothing. The balance can be topped up with $0.01 to $1,000. The bot's subscriptions, from $0.49 a day, don't apply to the API.
Is there a free AI API?
No, every UNCHAIN API request is paid from the balance. The 5 free text requests a day work only in the bot and the web app; they don't extend to the API, and neither does the subscription. GET /v1/me is free: it shows your balance and spending. A request the model didn't answer, which returned code 502, isn't charged either.
How do I get an AI API key?
An UNCHAIN API key is issued in the Telegram bot, in the “API for code” section, or in the web app, in “Agent mode”. The key starts with sk- and is shown in full only once, so save it right away. An account has one active key: issuing a new one instantly revokes the old one. Don't publish the key in repositories or in a website's code, since it spends your balance.
What limits does the API have?
The UNCHAIN API has two technical limits: up to 3 concurrent requests per user and a request body of up to 20 MB. Extra parallel requests get code 429 with a Retry-After header and can be retried after a pause. A request larger than 20 MB is rejected with code 413. The minimum balance for a request is $0.10, and GET /v1/me returns the current limits of your account.
Is this an AI API without restrictions?
On topics, yes: the API runs the same UNCHAIN model as the bot, answering directly and without lectures. The technical limits on parallel requests and request body size still apply. The name doesn't guarantee an answer to every question, and if the model declines, the refusal comes as ordinary text in the response. The service rules forbid using the API for illegal actions or to violate the rights of third parties.
Which model works through the API?
The API runs the UNCHAIN model, the same one that answers in the Telegram bot. The API serves a single model, so you can leave the model field of a request as it is. For clients that require a model name in their settings, GET /v1/models returns it. There is nothing to switch or pick from a list: UNCHAIN handles every request.
How is an OpenAI-compatible API different from the OpenAI API?
An OpenAI-compatible API repeats the request and response format of OpenAI Chat Completions, but a different service handles the requests. With UNCHAIN, requests go to the service's Base URL, the UNCHAIN model answers, the sk-… key is issued in its bot or web app, and payment comes from your UNCHAIN balance. You need no OpenAI account or key, and code built on the openai library needs just two lines changed.
Updated