Telegram Bot · Gatelum
A bot is easiest to build with grammY: Telegram delivers messages, and the gateway answers through the official OpenAI SDK.
Connection values · not an app screenshot
Example setup
ApplicationTelegram Bot
GatelumAPI gateway
Model IDgoogle/gemini-3.8-flash
- Base URL
https://api.gatelum.com/v1- Your API key
glt_YOUR_KEY
Connection steps
Create a bot in @BotFather and copy the token it issues.
Install the two packages named in the first line of the snippet, then run it.
Set BOT_TOKEN and GATELUM_API_KEY and start the bot.
bot.js
// npm i openai grammy
import { Bot } from "grammy";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.GATELUM_API_KEY,
baseURL: "https://api.gatelum.com/v1",
});
const telegram = new Bot(process.env.BOT_TOKEN);
telegram.on("message", async (ctx) => {
const text = ctx.message.text;
if (!text) return;
const completion = await client.chat.completions.create({
model: "google/gemini-3.8-flash",
messages: [{ role: "user", content: text }],
});
const reply = completion.choices[0]?.message.content;
await ctx.reply(reply || "No answer");
});
await telegram.start();Connection check
Send one short request: it checks the key, the address and the chosen model.
curl
curl https://api.gatelum.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer glt_YOUR_KEY" \
-d '{"model":"google/gemini-3.8-flash","messages":[{"role":"user","content":"ping"}]}'A normal answer means the setup is correct. 401 points to the key, 404 to the address or model, 400 to the request format.
Good to knowSwitch streaming on for a long answer and keep editing the message you sent as text comes in; without that, whoever is reading faces an empty chat.
Gateway capabilities and limitsAgentic modes work because the gateway can call
functions. JSON output (response_format) is accepted on OpenAI-compatible routes, while a model reachable only through a direct Anthropic or Google connection answers unsupported_capability. The retired functions format behaves differently: it returns parameter_not_supported, so no parameter disappears without an explanation. Only models the catalog tags "Understands images" may accept pictures — they travel as an image_url part holding a data:image/png;base64,… address (PNG, JPEG and WebP are allowed, a file may weigh up to 5 MB, and a request carries at most 50). Remote addresses are never downloaded, while a model lacking the tag answers bad_request. Each error, bad_request as well as parameter_not_supported, states the reason plainly.