Tools

Telegram Bot

Telegram bot. Answers users through ApiMira models on a single key.

The simplest bot is grammY: it takes messages from Telegram and answers through the official OpenAI SDK pointed at the gateway.

What you need

Base URL
https://apimira.com/v1
API key
am-YOUR_KEYCreated in the dashboard, the API keys section. The full value is shown once.
Model ID
google/gemini-3.7-flashCopy it from the catalogue in full, including the prefix before the slash.

How to connect

  1. 1Get a bot token from @BotFather.
  2. 2Install grammy and openai, then paste the code below.
  3. 3Put BOT_TOKEN and APIMIRA_API_KEY into the environment and start the bot.
// npm i grammy openai
import { Bot } from "grammy";
import OpenAI from "openai";

const ai = new OpenAI({
  apiKey: process.env.APIMIRA_API_KEY,
  baseURL: "https://apimira.com/v1",
});
const bot = new Bot(process.env.BOT_TOKEN);

bot.on("message:text", async (ctx) => {
  const answer = await ai.chat.completions.create({
    model: "google/gemini-3.7-flash",
    messages: [{ role: "user", content: ctx.message.text }],
  });
  await ctx.reply(answer.choices[0].message.content ?? "");
});

bot.start();

For long answers turn on streaming and edit the already sent message as text arrives — otherwise the user stares at an empty chat for tens of seconds.

Function calling is supported, so agentic modes work. Strict JSON mode (response_format) and the retired functions format are rejected with an unsupported_parameter error — the parameter is never silently dropped. Image input is accepted by models marked "Sees images" on the Models page: a content part of type image_url with a data:image/png;base64,… URL (PNG, JPEG or WebP, up to 5 MB each, up to 50 per request). Remote URLs are not fetched, and a model without that mark answers with unsupported_capability — both errors name the reason outright.