1. Get a bot token and an API key
In Telegram, open @BotFather, send /newbot, pick a name and a username, and copy the token it returns. Then create a Model.sale account, open API keys and create a key; new accounts that sign in with Google or Telegram get $0.50 of test credit, enough for hundreds of short replies on a cheap model.
2. The bot: about 20 lines of Python
The bot uses aiogram for Telegram and the official OpenAI SDK pointed at Model.sale, so switching the model is a one-word change: gpt-6.1-terra is the cheapest strong option ($0.15 per 1M charged tokens), claude-sonnet-5-5 and claude-opus-5-5 answer better on hard questions.
# bot.py — a Telegram bot that answers with an AI model via Model.sale
import asyncio, os
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from openai import AsyncOpenAI
bot = Bot(os.environ["BOT_TOKEN"])
dp = Dispatcher()
ai = AsyncOpenAI(base_url="https://api.model.sale/v1", api_key=os.environ["MODEL_SALE_API_KEY"])
@dp.message()
async def answer(message: Message) -> None:
reply = await ai.chat.completions.create(
model=os.environ.get("MODEL", "gpt-6.1-terra"),
messages=[{"role": "user", "content": message.text or ""}],
)
await message.answer(reply.choices[0].message.content or "…")
asyncio.run(dp.start_polling(bot))3. Dependencies and settings
Put the dependencies next to bot.py. Keep the token and the key in environment variables, never in the code or the repository.
# requirements.txt
aiogram>=3
openai>=1
# environment variables
BOT_TOKEN=123456:ABC... # from @BotFather
MODEL_SALE_API_KEY=ms_live_... # from model.sale/dashboard/keys
MODEL=gpt-6.1-terra # optional: claude-sonnet-5-5, claude-opus-5-5, gpt-6.1-sol4. Host it free on Deployka
On Deployka, upload the folder as a ZIP or connect the GitHub repository. It detects Python, installs the requirements and starts bot.py; add BOT_TOKEN and MODEL_SALE_API_KEY in the project's environment variables. The Free Nano plan costs nothing and needs no card; it runs a small bot like this one for up to 30 days and reclaims the slot after 7 idle days. A paid Nano slot ($1.09 per 30 days) keeps it running without that limit.
Deploy Doctor checks the environment variables and the start command before the build, so a missing key shows up before the first crash. Logs and a restart button are in the dashboard. Deployka also has ready Telegram Bot and AI Chatbot templates if you prefer to start from one.
5. What it costs to run
A short exchange is roughly 300 input and 300 output tokens. On gpt-6.1-terra that is about $0.0001 per reply, so $5 covers tens of thousands of replies; on claude-opus-5-5 ($1.40 per 1M charged tokens) about $0.001 per reply. Put a daily spend limit on the key in the dashboard, and connect @modelsale_bot to get a message when the balance runs low or spending jumps.
6. Next steps
Keep the conversation history per chat to give the model context, add a system prompt for your bot's role, and use streaming for long answers. The model pages on Model.sale have ready code in Python, Node.js and cURL for every model.