> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Telegram bot without code: GPT, Claude, DeepSeek

> How to build your own AI Telegram bot on free Cloudflare Workers hosting: the ChatGPT-Telegram-Workers project, a RuAPI key and every bot command

Your own Telegram bot that answers with GPT, Claude, DeepSeek and other RuAPI models. We use the open-source project [ChatGPT-Telegram-Workers](https://github.com/TBXark/ChatGPT-Telegram-Workers) (MIT license): it runs on the free Cloudflare Workers plan, so you don't need a server or a domain. By default only the owner can talk to the bot, so strangers can't spend your balance.

Instructions checked on 9 Nov 2026 against the current version of the project. No programming needed. Want to write the bot yourself in Python? See the [Telegram bot recipe](https://docs.ruapi.ai/en/recipes/telegram-bot.md).

## What you need

* **A RuAPI key.** Console → **API Keys** → create an `sk-...` key. New users usually get a trial balance right away; it works with `deepseek-flash`, `claude-haiku-5-5` and `gpt-6-luna`. For other models, top up — see [Top up](https://docs.ruapi.ai/en/topup.md).
* **A Cloudflare account** (free).
* **A GitHub or GitLab account.** Cloudflare copies the bot's code into it. A separate empty account is best — see below.
* **Telegram** on your phone or computer.

## Step 1. Create the bot and get your ID

**1. Bot from @BotFather**

Open [@BotFather](https://t.me/BotFather), send `/newbot`, pick a name and a username ending in `_bot`. BotFather replies with a **token** — save it and keep it private.

**2. Your Telegram ID**

Open [@userinfobot](https://t.me/userinfobot) and send `/start`. It replies with your `Id`, a number — that's your **ADMIN\_ID**.

## Step 2. Deploy the bot to Cloudflare

**1. Open the deploy link**

[deploy.workers.cloudflare.com/?url=https://github.com/TBXark/ChatGPT-Telegram-Workers](https://deploy.workers.cloudflare.com/?url=https://github.com/TBXark/ChatGPT-Telegram-Workers) — sign in to Cloudflare.

**2. Connect a Git account**

The deploy won't start until you connect GitHub or GitLab (**Connect a Git account to continue**). Click the GitHub connection button and grant access.

> [!WARNING]
>
> On GitHub's "Install & Authorize" screen, don't grant access to **all repositories** of your main account that holds work code: Cloudflare would be able to read and change them. The safest option is a separate empty GitHub account — there you can pick **All repositories** without worry.

**3. Fill in the form**

| Field | Value |
| - | - |
| Create a dedicated Git repository (checkbox) | on |
| Project name | anything, e.g. `my-ai-bot` |
| KV namespace | create a new one, any name |
| **TELEGRAM\_TOKEN** | token from @BotFather |
| **ADMIN\_ID** | number from @userinfobot |
| **ADMIN\_PASSWORD** | a long random password |

> [!NOTE]
>
> **ADMIN\_PASSWORD** is labelled optional, but the form won't submit without it. Use a long random password (20+ characters) and keep it: it opens the bot's admin panel, which stores your RuAPI key.

Leave the build and deploy commands as they are. **Don't turn on Cloudflare Access** — it would block Telegram from delivering messages to the bot.

**4. Start the deploy**

The build takes about a minute. Wait until every stage is green.

## Step 3. Turn on the workers.dev address

In new projects the `*.workers.dev` address can be off, and then Telegram can't reach the bot. Open the project → the Domains tab → switch on the Production address. The Preview line may turn on with it — that's fine. Copy the Production address — you'll need it next.

Don't worry about "anyone with this URL can access it": only ADMIN\_ID can talk to the bot, and the admin panel is password-protected.

## Step 4. Log in to the admin panel and bind the webhook

**1. Log in**

Open `https://<your-project>.<your-subdomain>.workers.dev/admin` and log in with **ADMIN\_PASSWORD**.

**2. Bind the webhook**

In the same browser, open `https://<your-project>.<your-subdomain>.workers.dev/init`. You should see **Webhook bound successfully**.

![The /init page: Webhook bound successfully](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/init-success.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=ddf933369c4bba986cc475b4773e4d6b)

If you see `Unauthorized. Open /admin, log in, then retry.`, you're not logged in yet. Go back to the previous step, then click **Retry**.

![The /init page: Unauthorized. Open /admin, log in, then retry.](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/init-unauthorized.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=ec0db7571a63dba6ebd3563800b1194b)

## Step 5. Connect RuAPI

In the admin panel, on the **Chat** tab, click **Add Provider**:

| Field | Value |
| - | - |
| **Name** | `RuAPI` |
| **API Format** | `OpenAI Chat Completions` |
| **Base URL** | `https://www.ruapi.ai/v1`  — **with** `/v1`, without `/chat/completions` |
| **API Key** | `sk-your-key` |
| **API Key Header** | leave empty (only for Azure) |

![Bot admin panel: the Add Provider form with the API Format list](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/add-provider.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=c47f282279fea3e8cccbe859dcba1ce7)

**1. Models**

Click **Fetch Models** to load the RuAPI model list. Click **+** next to the ones you want, e.g. `deepseek-flash`, `claude-haiku-5-5`, `gpt-6-luna`. If the list doesn't load, add models by hand with **Add Model** — exact IDs are on the [pricing page](https://www.ruapi.ai/pricing?utm_source=docs\&utm_campaign=en-telegram-bot).

![Bot admin panel: Fetch Models loaded the RuAPI model list](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/fetch-models.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=c5ec6919f34bca3a10906a3af276d5e8)

**2. Default model**

Click a model in the **Models** list — the checkmark marks the default. `deepseek-flash` is a good start — one of the most affordable models, see [prices](https://www.ruapi.ai/pricing?utm_source=docs\&utm_campaign=en-telegram-bot).

**3. Make RuAPI the default and save**

Click **Set as Default**, then **Save**. RuAPI should get a checkmark in the provider list. If you have several providers, without this the bot may answer through a provider other than RuAPI.

![Bot admin panel: RuAPI models and the Set as Default button](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/set-default.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=4302b9e3381aa8a65e871f78ff98594e)

![Bot admin panel: RuAPI checked in the provider list](https://mintcdn.com/no-d0cfaf14/Roh7O5xGZZfXpuRd/images/telegram-bot/providers-list.webp?fit=max\&auto=format\&n=Roh7O5xGZZfXpuRd\&q=85\&s=fa3ee6932dea7a918b21c53ea8a19f3e)

## Step 6. Test it

Open your bot in Telegram:

1. `/setenv settings.language=en` — the bot's service messages are in Chinese by default, so switch them to English. To switch the **/** command menu to English too, open `/init` in your browser once more. This doesn't affect the model: it answers in the language of your question.
2. `/start` — the bot says a new conversation has started.
3. Send "Hi, introduce yourself in one sentence" — the answer appears gradually as it's generated.
4. `/models` → **RuAPI** → pick another model, send `/new` and ask something else.
5. Send a photo with "what's in this picture?". `deepseek-flash` can't see images — for photos switch to, say, `claude-haiku-5-5`. To see which models understand images, see [Image input](https://docs.ruapi.ai/en/vision.md).

> [!WARNING]
>
> **Switched models? Send `/new`.** `/models` changes only the model; the conversation goes on. The bot resends the whole previous chat to the new model, and it takes the earlier answers as its own. For example, after a `deepseek-flash` answer, Claude may introduce itself as DeepSeek and repeat the other model's style and mistakes. The old history is also paid for again every time. `/new` clears the history so the new model starts fresh.

The bot's requests show up in the RuAPI console → **Usage Logs**.

## All bot commands

Commands in the Telegram menu (the **/** button next to the input field):

| Command | What it does |
| - | - |
| `/new` | New conversation: the bot forgets the chat history |
| `/redo` | Regenerate the last answer. `/redo text` replaces your last question with new text and answers again |
| `/models` | Pick a provider and model with buttons. Send `/new` after switching |
| `/img description` | Generate an image. Works only if an image provider is added on the admin panel's **Image** tab |
| `/admin` | Open the admin panel right inside Telegram (Mini App) |
| `/help` | List of commands |

Commands not in the menu that still work:

| Command | What it does |
| - | - |
| `/start` | Same as `/new`, and also shows the chat ID |
| `/system` | Current provider and model |
| `/version` | Bot version and whether an update is available |
| `/setenv KEY=VALUE` | Change one setting |
| `/setenvs {"settings":{"language":"en","maxHistoryLength":10}}` | Change several settings with one JSON (nested JSON, no dotted keys) |
| `/delenv KEY` | Reset a `settings.*` setting to its default |

In a private chat, `/admin`, `/system`, `/setenv`, `/setenvs` and `/delenv` work only for ADMIN\_ID. Plain JSON sent without a command goes to the model as text — it doesn't change settings.

## Useful settings

Change them on the admin panel's **Settings** tab or with `/setenv`:

| What | Command |
| - | - |
| Language of the menu and service messages: `en`, `zh-cn` (default), `zh-hant`, `pt`; no Russian. The model answers in the language of your question regardless | `/setenv settings.language=en` |
| System prompt — the bot's role and style | `/setenv settings.systemInitMessage=You are a concise assistant` |
| How many recent messages to send to the model (default 20) | `/setenv settings.maxHistoryLength=10` |
| Send photos to the model at full size. By default the bot takes a smaller copy: cheaper, but the model may not read small text in the photo | `/setenv settings.telegramPhotoSizeOffset=-1` |

Reset a setting: `/delenv settings.systemInitMessage`.

To let friends use the bot, add their Telegram IDs to the allowed users on the **Settings** tab. All their requests are charged to your RuAPI balance. Note that friends can also switch the model with `/models`, and it changes for everyone. Keep only affordable models in the Models list.

## Costs

* Cloudflare: the free Workers plan is usually enough for a personal bot.
* RuAPI: you pay per token at the [prices](https://www.ruapi.ai/pricing?utm_source=docs\&utm_campaign=en-telegram-bot). With every message the bot resends the conversation history to the model, so each answer in a long chat costs more. Send `/new` when you change the topic.
* For Claude, RuAPI automatically caches the repeated start of the conversation: if you don't pause for more than 5 minutes, the resent history is cheaper — see [Prompt caching](https://docs.ruapi.ai/en/prompt-caching.md).

## Troubleshooting

> [accordion] Connect a Git account to continue
>
> Cloudflare's deploy requires a connected GitHub or GitLab account — this step can't be skipped. Connect a separate empty account (see step 2).

> [accordion] The form won't submit: ADMIN\_PASSWORD is required
>
> The field is effectively required. Enter a long random password.

> [accordion] /init says Unauthorized
>
> Open `/admin` and log in with ADMIN\_PASSWORD first, then open `/init` again and click **Retry**.

> [accordion] The bot doesn't reply
>
> * Check that the workers.dev address is on (step 3) and `/init` reported success.
> * Cloudflare Access must be off.
> * ADMIN\_ID is your numeric ID from @userinfobot, not your username.

> [accordion] The model claims to be a different model
>
> After `/models` the bot keeps the old conversation, and the new model sees what "it" wrote before. For example, Claude after a DeepSeek answer may call itself DeepSeek. Send `/new` after switching models.

> [accordion] Error about starting with a trial model
>
> Until you top up, only `deepseek-flash`, `claude-haiku-5-5` and `gpt-6-luna` work. Pick one of them in `/models` or [top up](https://docs.ruapi.ai/en/topup.md).

> [accordion] The admin panel doesn't open
>
> The admin panel and `/init` open via the `*.workers.dev` address. If it doesn't open in your region or loads very slowly, try another network. Chatting with the bot goes through Telegram and isn't affected.

> [accordion] 401 / invalid key
>
> * API Key must be a RuAPI key `sk-...`.
> * Base URL must be exactly `https://www.ruapi.ai/v1`.

## Security

* Your RuAPI key and bot token are stored in your Cloudflare account and don't end up in the Git repository.
* You can create a separate RuAPI key for the bot with a spending limit, so at worst the bot spends no more than that limit.
* When you no longer need the bot: delete the Worker in Cloudflare, the bot with `/deletebot` in @BotFather, the key in the RuAPI console, and the created repository in GitHub. Revoke Cloudflare's access in GitHub (**Settings → Applications**).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.