Discord या Telegram bot के लिए मुफ़्त AI API
Chat bot हर message के लिए एक model request भेजता है। व्यस्त server में एक मुफ़्त tier कुछ ही मिनटों में अपनी limit तक पहुँच जाता है। यह guide Discord bot और Telegram bot को FreeLLMAPI से जोड़ती है। FreeLLMAPI एक OpenAI-compatible key के पीछे 45 मुफ़्त provider tiers इकट्ठा करता है और जब कोई limit request रोकती है, तो अगले provider पर चला जाता है। Code Python में है और पूरा है।
कोड, मॉडल नाम और लाइव कैटलॉग लेबल अंग्रेज़ी में दिखाए गए हैं।
पहले limits की योजना बनाएँ
मुफ़्त tiers प्रति मिनट और प्रति दिन requests सीमित करते हैं। 200 सक्रिय उपयोगकर्ताओं वाले server में एक bot प्रति दिन हज़ारों requests भेज सकता है। Failover इन requests को आपकी सभी keys पर बाँटता है, लेकिन कुल संख्या अब भी मुफ़्त limits का योग ही रहती है।
- सिर्फ पूछे जाने पर जवाब दें। Discord में सिर्फ mentions का जवाब दें। Telegram groups में सिर्फ commands या replies का जवाब दें।
- हर उपयोगकर्ता को सीमित करें। हर कुछ सेकंड में एक उपयोगकर्ता को एक request दें।
- History छोटी रखें। पूरी channel history नहीं, बल्कि आखिरी 10 messages भेजें।
- तेज़ route इस्तेमाल करें।
auto:fastmodels को गति के हिसाब से क्रम में लगाता है। Chat उपयोगकर्ताओं को कम इंतज़ार करना पड़ता है। - विनम्रता से विफल हों। जब हर key अपनी limit पर हो, तो उपयोगकर्ता से बाद में फिर कोशिश करने को कहें।
इन मुफ़्त models की आज मापी गई गति सबसे तेज़ है। इनमें से कई की request limits ऊँची हैं:
| मॉडल | मुफ़्त उपलब्ध | कॉन्टेक्स्ट | मुफ़्त सीमाएँ (सबसे अच्छा विकल्प) | टूल | विज़न |
|---|---|---|---|---|---|
| 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: model call
दोनों bots एक ही module इस्तेमाल करते हैं। यह हर chat के लिए छोटी history रखता है, हर chat के लिए एक session ID भेजता है और rate limits संभालता है। पहले FreeLLMAPI इंस्टॉल करें और dashboard के Keys page से 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 मिनट तक एक ही model पर रखता है। तब bot एक बातचीत में एक जैसी शैली रखता है। अगर वह model अपनी limit तक पहुँचता है, तो router दूसरे model पर चला जाता है, जो वही history पाता है।
History और cooldowns memory में रखे जाते हैं। Bot के restart होने पर वे खो जाते हैं। ऐसे bot के लिए जिसे लंबी बातचीत याद रखनी हो, history को SQLite या Redis जैसे database में सेव करें।
discord.py के साथ Discord bot
- Discord Developer Portal खोलें और एक application बनाएँ। एक bot जोड़ें और उसका token कॉपी करें।
- Bot tab पर Privileged Gateway Intents पर जाएँ। Message Content चालू करें।
botscope और Send Messages permission के साथ bot को अपने server में आमंत्रित करें।- Token को
DISCORD_TOKENenvironment variable में सेट करें और 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 कॉपी करें। - Token को
TELEGRAM_TOKENenvironment variable में सेट करें। - Script चलाएँ। अपने bot को एक message भेजें।
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 status 5 सेकंड या उससे कम रहता है। धीमे models के लिए, लंबी requests के दौरान chat action फिर से भेजें। Code python-telegram-bot version 22 इस्तेमाल करता है, जो पूरी तरह async है।
तैयार bot agents
अगर आप bot नहीं लिखना चाहते, तो दो agents Discord और Telegram पर जवाब दे सकते हैं और FreeLLMAPI को अपने model के रूप में इस्तेमाल कर सकते हैं। FreeLLMAPI हर एक के लिए एक setup command देता है। हर command --dry-run सपोर्ट करता है और पहले configuration का backup बनाता है।
| Agent | Setup command | यह क्या लिखता है |
|---|---|---|
| OpenClaw | npx freellmapi setup-openclaw --url http://localhost:3001 --api-key <unified-key> | freellmapi provider, जो ~/.openclaw/openclaw.json में है, डिफ़ॉल्ट model 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 command के बाद restart की ज़रूरत है।
Bot और FreeLLMAPI एक ही computer या server पर चलाएँ। तब bot localhost पर gateway तक पहुँचता है, और gateway port इंटरनेट के लिए बंद रहता है। दोनों के लिए एक छोटा server या Raspberry Pi काफ़ी है।
समस्या निवारण
| समस्या | कारण | समाधान |
|---|---|---|
| Discord bot खाली messages पढ़ता है | Message Content intent बंद है | इसे portal में और intents.message_content में चालू करें |
| Bot अपने ही messages का जवाब देता है | Bot authors की जाँच नहीं है | message.author.bot true होने पर return करें |
| लंबे जवाबों पर Discord error 50035 | Message 2000 characters से लंबा है | जवाब को बाँटें, जैसा ऊपर के code में है |
| "सभी मुफ़्त models व्यस्त हैं" शाम को | Chain की सभी keys अपनी दैनिक limit पर हैं | और providers की keys जोड़ें। कई दैनिक limits आधी रात UTC पर reset होती हैं। |
| धीमे जवाब | धीमा model या लंबी history | auto:fast इस्तेमाल करें और 10 messages या कम रखें |
Bot से Connection refused | Bot Docker में चलता है और localhost इस्तेमाल करता है | host.docker.internal इस्तेमाल करें, या एक साझा Docker network |
अक्सर पूछे जाने वाले प्रश्न
क्या Discord bot के लिए कोई मुफ़्त AI API है?
हाँ। कई providers के मुफ़्त tiers हैं जो openai Python package के साथ काम करते हैं। FreeLLMAPI उन्हें एक key के पीछे जोड़ता है, इसलिए एक व्यस्त bot कई providers की limits इस्तेमाल कर सकता है।
क्या मैं मुफ़्त AI Telegram bot बना सकता हूँ?
हाँ। Bot के लिए python-telegram-bot और जवाबों के लिए एक OpenAI-compatible मुफ़्त API इस्तेमाल करें। इस पेज का code पूरा है।
मैं अपने AI bot को rate limits तक पहुँचने से कैसे रोकूँ?
सिर्फ mentions या commands का जवाब दें, हर उपयोगकर्ता को हर कुछ सेकंड में एक request तक सीमित करें, history छोटी रखें और और providers की keys जोड़ें।
मेरे Discord bot को खाली message content क्यों मिलता है?
Message Content intent बंद है। इसे Developer Portal में bot tab पर चालू करें, और code में intents.message_content = True सेट करें।
जब सभी मुफ़्त models अपनी limit पर होते हैं, तो क्या होता है?
FreeLLMAPI Retry-After header के साथ error 429 लौटाता है। Bot का code इसे पकड़ता है और उपयोगकर्ता को बाद में फिर कोशिश करने के लिए कहता है।
संबंधित गाइड
- Python में मुफ़्त LLM API
- मुफ़्त LLM API रेट सीमाएँ
- मुफ़्त OpenAI-compatible API base URLs
- AI एजेंट्स के लिए मुफ़्त LLM API
- बिना credit card के मुफ़्त 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)