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-കളും പരിധിയിൽ ആകുമ്പോൾ, പിന്നീട് വീണ്ടും ശ്രമിക്കാൻ ഉപയോക്താവിനോട് പറയുക.
ഇന്ന് ഏറ്റവും വേഗത്തിൽ അളന്ന സൗജന്യ മോഡലുകൾ ഇവയാണ്. ഇവയിൽ പലതിനും ഉയർന്ന request പരിധിയുണ്ട്:
| മോഡൽ | സൗജന്യമായി ലഭ്യം | കോൺടെക്സ്റ്റ് | സൗജന്യ പരിധികൾ (ഏറ്റവും മികച്ച ഓഫർ) | ടൂളുകൾ | ദൃശ്യ ശേഷി |
|---|---|---|---|---|---|
| Qwen3.8 27B | BlazeAPI, ElectronHub, Gizmo +3 കൂടി | 262K | 30 അഭ്യർഥന/മിനിറ്റ് 250 അഭ്യർഥന/ദിവസം 70,000 ടോക്കൺ/മിനിറ്റ് ~6M | അതെ | അതെ |
| GPT-OSS 20B | Api.Airforce, Cloudflare Workers AI, Groq +4 കൂടി | 131K | 30 അഭ്യർഥന/മിനിറ്റ് 1,000 അഭ്യർഥന/ദിവസം 8,000 ടോക്കൺ/മിനിറ്റ് 200,000 ടോക്കൺ/ദിവസം ~6M | അതെ | ഇല്ല |
| Nemotron 3.5 Lightning | ElectronHub, Gizmo, Kilo Gateway +2 കൂടി | 1M | 20 അഭ്യർഥന/മിനിറ്റ് 50 അഭ്യർഥന/ദിവസം 50 req/day account-wide (1,000 after a $10 purchase) | അതെ | ഇല്ല |
| GPT-OSS 120B | Cloudflare Workers AI, ElectronHub, Groq +1 കൂടി | 131K | 30 അഭ്യർഥന/മിനിറ്റ് 1,000 അഭ്യർഥന/ദിവസം 8,000 ടോക്കൺ/മിനിറ്റ് 200,000 ടോക്കൺ/ദിവസം ~6M | അതെ | ഇല്ല |
| GPT-OSS 20B (via Groq) | DreamPrompting | 131K | 100 അഭ്യർഥന/മിനിറ്റ് 5,000 അഭ്യർഥന/ദിവസം 500,000 ടോക്കൺ/ദിവസം 500K tokens/day · 5,000 req/day | ഇല്ല | ഇല്ല |
| GPT-OSS Safeguard 20B | Groq | 131K | 30 അഭ്യർഥന/മിനിറ്റ് 1,000 അഭ്യർഥന/ദിവസം 8,000 ടോക്കൺ/മിനിറ്റ് 200,000 ടോക്കൺ/ദിവസം ~6M | അതെ | ഇല്ല |
| Groq Compound Mini | DreamPrompting | 131K | 100 അഭ്യർഥന/മിനിറ്റ് 5,000 അഭ്യർഥന/ദിവസം 500,000 ടോക്കൺ/ദിവസം 500K tokens/day · 5,000 req/day | ഇല്ല | ഇല്ല |
| Gemini 3.5 Flash Lite | ElectronHub, Google AI Studio | 1M | 15 അഭ്യർഥന/മിനിറ്റ് 20 അഭ്യർഥന/ദിവസം 250,000 ടോക്കൺ/മിനിറ്റ് ~3M | അതെ | അതെ |
| Step 3.7 Flash | ElectronHub | 256K | $0.25/week shared recurring credit | അതെ | അതെ |
| Gemini 3.1 Flash-Lite | DreamPrompting, Google AI Studio | 1M | 100 അഭ്യർഥന/മിനിറ്റ് 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
- Discord Developer Portal തുറന്ന് ഒരു application ഉണ്ടാക്കുക. ഒരു bot ചേർത്ത് അതിന്റെ token പകർത്തുക.
- Bot tab-ൽ Privileged Gateway Intents-ലേക്ക് പോകുക. Message Content ഓൺ ചെയ്യുക.
botscope-ഉം Send Messages അനുമതിയും ഉപയോഗിച്ച് bot-നെ നിങ്ങളുടെ server-ലേക്ക് ക്ഷണിക്കുക.DISCORD_TOKENenvironment 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
- Telegram-ൽ @BotFather തുറന്ന്
/newbotഅയയ്ക്കുക. Token പകർത്തുക. TELEGRAM_TOKENenvironment variable-ൽ token സജ്ജമാക്കുക.- 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 പിന്തുണയ്ക്കുന്നു, ആദ്യം ക്രമീകരണത്തിന്റെ ബാക്കപ്പ് എടുക്കുന്നു.
| Agent | Setup കമാൻഡ് | ഇത് എഴുതുന്നത് |
|---|---|---|
| OpenClaw | npx freellmapi setup-openclaw --url http://localhost:3001 --api-key <unified-key> | freellmapi provider, ~/.openclaw/openclaw.json-ൽ, സ്ഥിരസ്ഥിതി മോഡൽ freellmapi/auto |
| Hermes Agent | npx 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 refused | Bot Docker-ൽ പ്രവർത്തിക്കുന്നു, localhost ഉപയോഗിക്കുന്നു | host.docker.internal അല്ലെങ്കിൽ പങ്കിട്ട Docker network ഉപയോഗിക്കുക |
പതിവ് ചോദ്യങ്ങൾ
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 അത് പിടിച്ച്, പിന്നീട് വീണ്ടും ശ്രമിക്കാൻ ഉപയോക്താവിനോട് പറയുന്നു.
അനുബന്ധ ഗൈഡുകൾ
- Python-ൽ സൗജന്യ LLM API
- സൗജന്യ LLM API റേറ്റ് പരിധികൾ
- സൗജന്യ OpenAI-compatible API base URL-കൾ
- AI ഏജന്റുകൾക്കുള്ള സൗജന്യ LLM API
- കാർഡ് ഇല്ലാതെ സൗജന്യ LLM API
ഉറവിടങ്ങൾ
- discord.py docs: quickstart (20 November 2026 ൽ പരിശോധിച്ചത്)
- discord.py docs: privileged intents (20 November 2026 ൽ പരിശോധിച്ചത്)
- Discord developer docs: message resource (2000 character content limit) (20 November 2026 ൽ പരിശോധിച്ചത്)
- python-telegram-bot v22 docs: echobot example (20 November 2026 ൽ പരിശോധിച്ചത്)
- Telegram Bot API: sendMessage and sendChatAction (20 November 2026 ൽ പരിശോധിച്ചത്)
- FreeLLMAPI docs: clients (OpenClaw, Hermes Agent, context handoff) (20 November 2026 ൽ പരിശോധിച്ചത്)