ഹോം / ഗൈഡുകൾ / Discord അല്ലെങ്കിൽ Telegram bot-നുള്ള സൗജന്യ AI API

Discord അല്ലെങ്കിൽ Telegram bot-നുള്ള സൗജന്യ AI API

ഒരു chat bot ഓരോ സന്ദേശത്തിനും ഒരു മോഡൽ request അയയ്ക്കുന്നു. തിരക്കുള്ള ഒരു server-ൽ ഒരു സൗജന്യ tier മിനിറ്റുകൾക്കുള്ളിൽ പരിധിയിൽ എത്തുന്നു. ഈ ഗൈഡ് ഒരു Discord bot-നെയും ഒരു Telegram bot-നെയും FreeLLMAPI-യുമായി ബന്ധിപ്പിക്കുന്നു. FreeLLMAPI ഒരു OpenAI-compatible key-ക്ക് പിന്നിൽ 45 സൗജന്യ provider tier-കൾ ചേർക്കുന്നു, ഒരു പരിധി request തടയുമ്പോൾ അടുത്ത provider-ലേക്ക് മാറുന്നു. Code Python ആണ്, അത് പൂർണ്ണമാണ്.

കോഡ്, മോഡൽ പേരുകളും തത്സമയ കാറ്റലോഗ് ലേബലുകളും ഇംഗ്ലീഷിൽ കാണിക്കുന്നു.

ആദ്യം പരിധികൾക്കായി ആസൂത്രണം ചെയ്യുക

സൗജന്യ tier-കൾ മിനിറ്റിലും ദിവസത്തിലും request-കൾ പരിമിതപ്പെടുത്തുന്നു. 200 സജീവ ഉപയോക്താക്കളുള്ള server-ലെ bot ഒരു ദിവസം ആയിരക്കണക്കിന് request-കൾ അയച്ചേക്കാം. Failover ഈ request-കൾ നിങ്ങളുടെ എല്ലാ key-കളിലും വിതരണം ചെയ്യുന്നു, എന്നാൽ ആകെ എണ്ണം സൗജന്യ പരിധികളുടെ ആകെത്തുക തന്നെയാണ്.

  • ചോദിച്ചാൽ മാത്രം മറുപടി നൽകുക. Discord-ൽ mentions-ന് മാത്രം മറുപടി നൽകുക. Telegram group-കളിൽ commands-നോ replies-നോ മാത്രം മറുപടി നൽകുക.
  • ഓരോ ഉപയോക്താവിനെയും പരിമിതപ്പെടുത്തുക. ഓരോ ഉപയോക്താവിനും ഓരോ കുറച്ച് സെക്കൻഡിലും ഒരു request മാത്രം അനുവദിക്കുക.
  • ചരിത്രം ചെറുതാക്കി നിർത്തുക. അവസാനത്തെ 10 സന്ദേശങ്ങൾ അയയ്ക്കുക, മുഴുവൻ channel ചരിത്രമല്ല.
  • വേഗമേറിയ route ഉപയോഗിക്കുക. auto:fast മോഡലുകളെ വേഗത അനുസരിച്ച് റാങ്ക് ചെയ്യുന്നു. Chat ഉപയോക്താക്കൾ കുറച്ച് സമയം കാത്തിരിക്കുന്നു.
  • മര്യാദയോടെ പരാജയപ്പെടുക. എല്ലാ key-കളും പരിധിയിൽ ആകുമ്പോൾ, പിന്നീട് വീണ്ടും ശ്രമിക്കാൻ ഉപയോക്താവിനോട് പറയുക.
സ്വകാര്യത: Bot ഉപയോക്തൃ സന്ദേശങ്ങൾ മറുപടി നൽകുന്ന provider-ലേക്ക് അയയ്ക്കുന്നു. ചില സൗജന്യ tier-കൾ അവയുടെ മോഡലുകൾ മെച്ചപ്പെടുത്താൻ prompts ഉപയോഗിച്ചേക്കാം. ഒരു AI സേവനം അവരുടെ സന്ദേശങ്ങൾ വായിക്കുന്നുണ്ടെന്ന് നിങ്ങളുടെ ഉപയോക്താക്കളോട് പറയുക. ഏത് സൗജന്യ LLM API-കൾ നിങ്ങളുടെ ഡാറ്റയിൽ പരിശീലിക്കുന്നു എന്ന് വായിക്കുകയും നിങ്ങൾ അംഗീകരിക്കാത്ത providers നിങ്ങളുടെ chain-ൽ നിന്ന് നീക്കുകയും ചെയ്യുക.

ഇന്ന് ഏറ്റവും വേഗത്തിൽ അളന്ന സൗജന്യ മോഡലുകൾ ഇവയാണ്. ഇവയിൽ പലതിനും ഉയർന്ന request പരിധിയുണ്ട്:

വേഗമേറിയ സൗജന്യ chat മോഡലുകൾ
മോഡൽസൗജന്യമായി ലഭ്യംകോൺടെക്സ്റ്റ്സൗജന്യ പരിധികൾ (ഏറ്റവും മികച്ച ഓഫർ)ടൂളുകൾദൃശ്യ ശേഷി
Qwen3.8 27BBlazeAPI, ElectronHub, Gizmo +3 കൂടി262K30 അഭ്യർഥന/മിനിറ്റ്
250 അഭ്യർഥന/ദിവസം
70,000 ടോക്കൺ/മിനിറ്റ്
~6M
അതെഅതെ
GPT-OSS 20BApi.Airforce, Cloudflare Workers AI, Groq +4 കൂടി131K30 അഭ്യർഥന/മിനിറ്റ്
1,000 അഭ്യർഥന/ദിവസം
8,000 ടോക്കൺ/മിനിറ്റ്
200,000 ടോക്കൺ/ദിവസം
~6M
അതെഇല്ല
Nemotron 3.5 LightningElectronHub, Gizmo, Kilo Gateway +2 കൂടി1M20 അഭ്യർഥന/മിനിറ്റ്
50 അഭ്യർഥന/ദിവസം
50 req/day account-wide (1,000 after a $10 purchase)
അതെഇല്ല
GPT-OSS 120BCloudflare Workers AI, ElectronHub, Groq +1 കൂടി131K30 അഭ്യർഥന/മിനിറ്റ്
1,000 അഭ്യർഥന/ദിവസം
8,000 ടോക്കൺ/മിനിറ്റ്
200,000 ടോക്കൺ/ദിവസം
~6M
അതെഇല്ല
GPT-OSS 20B (via Groq)DreamPrompting131K100 അഭ്യർഥന/മിനിറ്റ്
5,000 അഭ്യർഥന/ദിവസം
500,000 ടോക്കൺ/ദിവസം
500K tokens/day · 5,000 req/day
ഇല്ലഇല്ല
GPT-OSS Safeguard 20BGroq131K30 അഭ്യർഥന/മിനിറ്റ്
1,000 അഭ്യർഥന/ദിവസം
8,000 ടോക്കൺ/മിനിറ്റ്
200,000 ടോക്കൺ/ദിവസം
~6M
അതെഇല്ല
Groq Compound MiniDreamPrompting131K100 അഭ്യർഥന/മിനിറ്റ്
5,000 അഭ്യർഥന/ദിവസം
500,000 ടോക്കൺ/ദിവസം
500K tokens/day · 5,000 req/day
ഇല്ലഇല്ല
Gemini 3.5 Flash LiteElectronHub, Google AI Studio1M15 അഭ്യർഥന/മിനിറ്റ്
20 അഭ്യർഥന/ദിവസം
250,000 ടോക്കൺ/മിനിറ്റ്
~3M
അതെഅതെ
Step 3.7 FlashElectronHub256K$0.25/week shared recurring creditഅതെഅതെ
Gemini 3.1 Flash-LiteDreamPrompting, Google AI Studio1M100 അഭ്യർഥന/മിനിറ്റ്
5,000 അഭ്യർഥന/ദിവസം
500,000 ടോക്കൺ/ദിവസം
500K tokens/day · 5,000 req/day
അതെഅതെ

പൊരുത്തപ്പെടുന്ന 215 സൗജന്യ മോഡലുകളിൽ 10 എണ്ണം കാണിക്കുന്നു. എല്ലാ മോഡലുകളും കാണുക.

FreeLLMAPI കാറ്റലോഗിൽ നിന്നുള്ള തത്സമയ ഡാറ്റ (പതിപ്പ് 2026.11.19, 2026-11-19 ൽ പരിശോധിച്ചത്). സൗജന്യ പരിധികൾ പലപ്പോഴും മാറുന്നു. കാറ്റലോഗ് എല്ലാ ദിവസവും പരിശോധിക്കുന്നു.

പൊതു code: മോഡൽ call

രണ്ട് bot-കളും ഒരേ module ഉപയോഗിക്കുന്നു. ഇത് ഓരോ chat-നും ഒരു ചെറിയ ചരിത്രം സൂക്ഷിക്കുന്നു, ഓരോ chat-നും ഒരു session ID അയയ്ക്കുന്നു, rate limit-കൾ കൈകാര്യം ചെയ്യുന്നു. ആദ്യം FreeLLMAPI ഇൻസ്റ്റാൾ ചെയ്ത് ഡാഷ്ബോർഡിലെ Keys പേജിൽ നിന്ന് unified key പകർത്തുക.

ഇൻസ്റ്റാൾ ചെയ്യുക

curl -fsSL https://freellmapi.co/install.sh | bash

python3 -m pip install -U openai discord.py python-telegram-bot
export FREELLMAPI_API_KEY=<unified-key>

brain.py

import asyncio
import os
import time
from collections import defaultdict, deque

import openai
from openai import AsyncOpenAI

llm = AsyncOpenAI(
    base_url="http://localhost:3001/v1",
    api_key=os.environ["FREELLMAPI_API_KEY"],
    max_retries=2,
    timeout=60,
)

SYSTEM = "You are a helpful chat bot. Answer in short paragraphs."
history = defaultdict(lambda: deque(maxlen=10))  # chat id -> last 10 messages
last_call = {}  # user id -> time of the last request
COOLDOWN_S = 5

async def ask(chat_id: str, user_id: str, text: str) -> str:
    now = time.monotonic()
    if now - last_call.get(user_id, 0) < COOLDOWN_S:
        return "Please wait a few seconds before the next question."
    last_call[user_id] = now

    turns = history[chat_id]
    turns.append({"role": "user", "content": text[:4000]})
    messages = [{"role": "system", "content": SYSTEM}, *turns]

    for attempt in range(3):
        try:
            resp = await llm.chat.completions.create(
                model="auto:fast",
                messages=messages,
                max_tokens=800,
                extra_headers={"X-Session-Id": f"chat-{chat_id}"},
            )
            answer = resp.choices[0].message.content or "(no answer)"
            turns.append({"role": "assistant", "content": answer})
            return answer
        except openai.RateLimitError as err:
            header = err.response.headers.get("retry-after", "")
            wait = int(header) if header.isdigit() else 2 ** attempt
            if wait > 30:
                break
            await asyncio.sleep(wait)
        except openai.APIError:
            break
    turns.pop()  # forget the unanswered question
    return "All free models are busy now. Please try again later."

def split(text: str, size: int) -> list[str]:
    return [text[i:i + size] for i in range(0, len(text), size)] or [""]

X-Session-Id header ഒരു chat-നെ 30 മിനിറ്റ് ഒരേ മോഡലിൽ നിലനിർത്തുന്നു. അങ്ങനെ bot ഒരു സംഭാഷണത്തിൽ ഒരേ ശൈലി നിലനിർത്തുന്നു. ആ മോഡൽ പരിധിയിൽ എത്തിയാൽ, router മറ്റൊരു മോഡലിലേക്ക് മാറുന്നു, അത് അതേ ചരിത്രം ലഭിക്കുന്നു.

ചരിത്രവും cooldown-കളും memory-യിലാണ് സൂക്ഷിക്കുന്നത്. Bot restart ചെയ്യുമ്പോൾ അവ നഷ്ടപ്പെടുന്നു. നീണ്ട സംഭാഷണങ്ങൾ ഓർമ്മിക്കേണ്ട bot-ന്, SQLite അല്ലെങ്കിൽ Redis പോലുള്ള database-ൽ ചരിത്രം സൂക്ഷിക്കുക.

discord.py ഉപയോഗിച്ചുള്ള Discord bot

  1. Discord Developer Portal തുറന്ന് ഒരു application ഉണ്ടാക്കുക. ഒരു bot ചേർത്ത് അതിന്റെ token പകർത്തുക.
  2. Bot tab-ൽ Privileged Gateway Intents-ലേക്ക് പോകുക. Message Content ഓൺ ചെയ്യുക.
  3. bot scope-ഉം Send Messages അനുമതിയും ഉപയോഗിച്ച് bot-നെ നിങ്ങളുടെ server-ലേക്ക് ക്ഷണിക്കുക.
  4. DISCORD_TOKEN environment variable-ൽ token സജ്ജമാക്കി script പ്രവർത്തിപ്പിക്കുക.

discord_bot.py

import os

import discord

from brain import ask, split

intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f"Logged in as {client.user}")

@client.event
async def on_message(message: discord.Message):
    if message.author.bot or client.user not in message.mentions:
        return
    text = message.content
    for tag in (f"<@{client.user.id}>", f"<@!{client.user.id}>"):
        text = text.replace(tag, "")
    text = text.strip()
    if not text:
        return
    async with message.channel.typing():
        answer = await ask(str(message.channel.id), str(message.author.id), text)
    parts = split(answer, 2000)  # Discord limit: 2000 characters
    await message.reply(parts[0])
    for part in parts[1:]:
        await message.channel.send(part)

client.run(os.environ["DISCORD_TOKEN"])

python-telegram-bot ഉപയോഗിച്ചുള്ള Telegram bot

  1. Telegram-ൽ @BotFather തുറന്ന് /newbot അയയ്ക്കുക. Token പകർത്തുക.
  2. TELEGRAM_TOKEN environment variable-ൽ token സജ്ജമാക്കുക.
  3. Script പ്രവർത്തിപ്പിക്കുക. നിങ്ങളുടെ bot-ന് ഒരു സന്ദേശം അയയ്ക്കുക.

telegram_bot.py

import os

from telegram import Update
from telegram.constants import ChatAction
from telegram.ext import Application, ContextTypes, MessageHandler, filters

from brain import ask, split

async def on_text(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    chat_id = update.effective_chat.id
    await context.bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING)
    answer = await ask(str(chat_id), str(update.effective_user.id), update.message.text)
    for part in split(answer, 4096):  # Telegram limit: 4096 characters
        await update.message.reply_text(part)

def main() -> None:
    app = Application.builder().token(os.environ["TELEGRAM_TOKEN"]).build()
    app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, on_text))
    app.run_polling(allowed_updates=Update.ALL_TYPES)

if __name__ == "__main__":
    main()

Telegram-ലെ typing സ്റ്റാറ്റസ് 5 സെക്കൻഡോ അതിൽ കുറവോ നിലനിൽക്കുന്നു. മന്ദഗതിയിലുള്ള മോഡലുകൾക്ക്, നീണ്ട request-കളിൽ chat action വീണ്ടും അയയ്ക്കുക. Code python-telegram-bot പതിപ്പ് 22 ഉപയോഗിക്കുന്നു, അത് പൂർണ്ണമായി async ആണ്.

തയ്യാറായ bot agent-കൾ

Bot എഴുതാൻ താൽപ്പര്യമില്ലെങ്കിൽ, Discord-ലും Telegram-ലും മറുപടി നൽകാൻ രണ്ട് agent-കൾക്ക് കഴിയും, അവർ FreeLLMAPI അവരുടെ മോഡലായി ഉപയോഗിക്കുന്നു. FreeLLMAPI ഓരോന്നിനും ഒരു setup കമാൻഡ് നൽകുന്നു. ഓരോ കമാൻഡും --dry-run പിന്തുണയ്ക്കുന്നു, ആദ്യം ക്രമീകരണത്തിന്റെ ബാക്കപ്പ് എടുക്കുന്നു.

AgentSetup കമാൻഡ്ഇത് എഴുതുന്നത്
OpenClawnpx freellmapi setup-openclaw --url http://localhost:3001 --api-key <unified-key>freellmapi provider, ~/.openclaw/openclaw.json-ൽ, സ്ഥിരസ്ഥിതി മോഡൽ freellmapi/auto
Hermes Agentnpx freellmapi setup-hermes --url http://localhost:3001 --api-key <unified-key>~/.hermes/config.yaml-ൽ ഒരു custom model block

പ്രവർത്തിക്കുന്ന OpenClaw അല്ലെങ്കിൽ Hermes gateway setup കമാൻഡിന് ശേഷം restart ചെയ്യണം.

Bot-ഉം FreeLLMAPI-യും ഒരേ കമ്പ്യൂട്ടറിലോ server-ലോ പ്രവർത്തിപ്പിക്കുക. അപ്പോൾ bot localhost-ൽ gateway-യിൽ എത്തുന്നു, gateway port ഇന്റർനെറ്റിന് അടഞ്ഞുനിൽക്കുന്നു. ചെറിയ server അല്ലെങ്കിൽ Raspberry Pi രണ്ടിനും മതിയാകും.

പ്രശ്നപരിഹാരം

പ്രശ്നംകാരണംപരിഹാരം
Discord bot ശൂന്യമായ സന്ദേശങ്ങൾ വായിക്കുന്നുMessage Content intent ഓഫ് ആണ്Portal-ലും intents.message_content-ലും അത് ഓൺ ചെയ്യുക
Bot സ്വന്തം സന്ദേശങ്ങൾക്ക് മറുപടി നൽകുന്നുBot രചയിതാക്കളെ പരിശോധിക്കുന്നില്ലmessage.author.bot true ആകുമ്പോൾ മടങ്ങുക
നീണ്ട മറുപടികളിൽ Discord പിശക് 50035സന്ദേശം 2000 അക്ഷരങ്ങളിൽ കൂടുതലാണ്മുകളിലെ code-ലെ പോലെ മറുപടി വിഭജിക്കുക
വൈകുന്നേരം "All free models are busy"Chain-ലെ എല്ലാ key-കളും ദിവസത്തെ പരിധിയിലാണ്കൂടുതൽ providers-ൽ നിന്ന് key-കൾ ചേർക്കുക. പല ദിവസ പരിധികളും UTC അർധരാത്രിയിൽ പുനഃസജ്ജമാകുന്നു.
മന്ദഗതിയിലുള്ള മറുപടികൾമന്ദഗതിയിലുള്ള മോഡൽ അല്ലെങ്കിൽ നീണ്ട ചരിത്രംauto:fast ഉപയോഗിക്കുക, 10 സന്ദേശങ്ങളോ അതിൽ കുറവോ നിലനിർത്തുക
Bot-ൽ നിന്ന് Connection refusedBot Docker-ൽ പ്രവർത്തിക്കുന്നു, localhost ഉപയോഗിക്കുന്നുhost.docker.internal അല്ലെങ്കിൽ പങ്കിട്ട Docker network ഉപയോഗിക്കുക
ഇവയെല്ലാം ഒരൊറ്റ കീ വഴി ഉപയോഗിക്കുക. FreeLLMAPI ഒരു ഓപ്പൺ-സോഴ്സ്, സ്വയം ഹോസ്റ്റ് ചെയ്യാവുന്ന റൂട്ടറാണ്. ഇത് ഈ സൗജന്യ ടയറുകളെല്ലാം ഒരൊറ്റ OpenAI-അനുയോജ്യ എൻഡ്‌പോയിന്റിനു പിന്നിൽ വയ്ക്കുന്നു. ഒരു മോഡലിന്റെ നിരക്ക് പരിധി എത്തുമ്പോൾ മറ്റൊന്നിലേക്ക് മാറുന്നു. കാറ്റലോഗ് ബ്രൗസ് ചെയ്യുക അല്ലെങ്കിൽ തത്സമയമാക്കുക.

പതിവ് ചോദ്യങ്ങൾ

Discord bot-നുള്ള സൗജന്യ AI API ഉണ്ടോ?

ഉണ്ട്. openai Python പാക്കേജിനൊപ്പം പ്രവർത്തിക്കുന്ന സൗജന്യ tier-കൾ പല providers-നും ഉണ്ട്. FreeLLMAPI അവയെ ഒരു key-ക്ക് പിന്നിൽ ചേർക്കുന്നു, അതിനാൽ തിരക്കുള്ള bot-ന് പല providers-ന്റെ പരിധികൾ ഉപയോഗിക്കാം.

സൗജന്യ AI Telegram bot ഉണ്ടാക്കാമോ?

ഉണ്ടാക്കാം. Bot-ന് python-telegram-bot ഉപയോഗിക്കുക, മറുപടികൾക്ക് OpenAI-compatible സൗജന്യ API ഉപയോഗിക്കുക. ഈ പേജിലെ code പൂർണ്ണമാണ്.

എന്റെ AI bot rate limit-കളിൽ എത്തുന്നത് എങ്ങനെ തടയാം?

mentions അല്ലെങ്കിൽ commands-ന് മാത്രം മറുപടി നൽകുക, ഓരോ ഉപയോക്താവിനെയും ഓരോ കുറച്ച് സെക്കൻഡിലും ഒരു request ആയി പരിമിതപ്പെടുത്തുക, ചരിത്രം ചെറുതാക്കി നിർത്തുക, കൂടുതൽ providers-ൽ നിന്ന് key-കൾ ചേർക്കുക.

എന്റെ Discord bot-ന് സന്ദേശ ഉള്ളടക്കം ശൂന്യമായി കിട്ടുന്നത് എന്തുകൊണ്ട്?

Message Content intent ഓഫ് ആണ്. Developer Portal-ൽ bot tab-ൽ അത് ഓൺ ചെയ്യുക, code-ൽ intents.message_content = True സജ്ജമാക്കുക.

എല്ലാ സൗജന്യ മോഡലുകളും പരിധിയിൽ ആകുമ്പോൾ എന്ത് സംഭവിക്കും?

FreeLLMAPI Retry-After header-ഓടെ error 429 നൽകുന്നു. Bot code അത് പിടിച്ച്, പിന്നീട് വീണ്ടും ശ്രമിക്കാൻ ഉപയോക്താവിനോട് പറയുന്നു.

അനുബന്ധ ഗൈഡുകൾ

ഉറവിടങ്ങൾ

എല്ലാ ഗൈഡുകളും · എല്ലാ സൗജന്യ മോഡലുകളും കാണുക