Discord किंवा Telegram बॉटसाठी मोफत AI API
Chat बॉट प्रत्येक संदेशासाठी एक मॉडेल विनंती पाठवतो. व्यस्त सर्व्हरमध्ये एक मोफत टियर काही मिनिटांत मर्यादेवर पोहोचतो. हे मार्गदर्शक Discord बॉट आणि Telegram बॉट FreeLLMAPI शी जोडते. FreeLLMAPI एका OpenAI-सुसंगत कीमागे 45 मोफत प्रदाता टियर एकत्र ठेवते आणि मर्यादेमुळे विनंती थांबली की पुढच्या प्रदात्याकडे जाते. कोड Python मध्ये आहे आणि पूर्ण आहे.
कोड, मॉडेलची नावे आणि थेट कॅटलॉग लेबल इंग्रजीत दाखवले जातात.
आधी मर्यादांचे नियोजन करा
मोफत टियर प्रति मिनिट आणि प्रति दिवस विनंत्या मर्यादित करतात. 200 सक्रिय वापरकर्ते असलेल्या सर्व्हरमधील बॉट दिवसाला हजारो विनंत्या पाठवू शकतो. Failover या विनंत्या तुमच्या सर्व कींमध्ये वाटते, पण एकूण संख्या अजूनही मोफत मर्यादांची बेरीज आहे.
- विचारल्यावरच उत्तर द्या. Discord मध्ये फक्त mentions ला उत्तर द्या. Telegram गटांमध्ये फक्त commands किंवा replies ला उत्तर द्या.
- प्रत्येक वापरकर्त्याला मर्यादा घाला. प्रत्येक काही सेकंदांनी प्रति वापरकर्ता एक विनंती द्या.
- इतिहास लहान ठेवा. संपूर्ण channel इतिहास नव्हे, तर शेवटचे 10 संदेश पाठवा.
- जलद मार्ग वापरा.
auto:fastमॉडेलची क्रमवारी वेगानुसार लावते. Chat वापरकर्त्यांना कमी वाट पाहावी लागते. - सौजन्याने अपयश हाताळा. सर्व की मर्यादेवर असतील, तेव्हा वापरकर्त्याला नंतर पुन्हा प्रयत्न करण्यास सांगा.
या मोफत मॉडेलचा आज मोजलेला वेग सर्वात जास्त आहे. त्यातील अनेकांवर उच्च विनंती मर्यादा आहेत:
| मॉडेल | मोफत उपलब्ध | संदर्भ | मोफत मर्यादा (सर्वोत्तम ऑफर) | साधने | व्हिजन |
|---|---|---|---|---|---|
| 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). मोफत मर्यादा वारंवार बदलतात. कॅटलॉग दररोज तपासले जाते.
सामायिक कोड: मॉडेल कॉल
दोन्ही बॉट एकच मॉडेल वापरतात. ते प्रत्येक chat साठी लहान इतिहास ठेवते, प्रत्येक chat साठी एक session ID पाठवते आणि रेट मर्यादा हाताळते. आधी FreeLLMAPI इन्स्टॉल करा आणि डॅशबोर्डच्या Keys पेजवरून एकत्रित की कॉपी करा.
इन्स्टॉल करा
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 हेडर एका chat ला 30 मिनिटे एका मॉडेलवर ठेवते. त्यामुळे बॉट संभाषणात एकच शैली ठेवतो. ते मॉडेल मर्यादेवर पोहोचले, तर राउटर दुसऱ्या मॉडेलकडे जातो, जे तोच इतिहास मिळवते.
इतिहास आणि cooldowns स्मृतीत ठेवले जातात. बॉट रीस्टार्ट झाल्यावर ते हरवतात. लांब संभाषणे लक्षात ठेवणाऱ्या बॉटसाठी इतिहास SQLite किंवा Redis सारख्या database मध्ये साठवा.
discord.py सह Discord बॉट
- Discord Developer Portal उघडा आणि application बनवा. Bot जोडा आणि त्याचा token कॉपी करा.
- Bot टॅबवर Privileged Gateway Intents वर जा. Message Content चालू करा.
botscope आणि Send Messages परवानगीसह बॉटला तुमच्या सर्व्हरवर आमंत्रित करा.DISCORD_TOKENenvironment variable मध्ये token सेट करा आणि स्क्रिप्ट चालवा.
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 बॉट
- Telegram मध्ये @BotFather उघडा आणि
/newbotपाठवा. token कॉपी करा. TELEGRAM_TOKENenvironment variable मध्ये token सेट करा.- स्क्रिप्ट चालवा. तुमच्या बॉटला संदेश पाठवा.
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 सेकंद किंवा कमी काळ राहते. संथ मॉडेलसाठी लांब विनंत्यांदरम्यान chat action पुन्हा पाठवा. कोड python-telegram-bot आवृत्ती 22 वापरतो, जी पूर्णपणे async आहे.
तयार बॉट agents
बॉट लिहायचा नसेल, तर दोन agents Discord आणि Telegram वर उत्तर देऊ शकतात आणि त्यांचे मॉडेल म्हणून FreeLLMAPI वापरू शकतात. FreeLLMAPI प्रत्येकासाठी एक सेटअप आदेश देते. प्रत्येक आदेश --dry-run ला सपोर्ट करतो आणि आधी कॉन्फिगरेशनचा बॅकअप घेतो.
| Agent | सेटअप आदेश | तो काय लिहितो |
|---|---|---|
| OpenClaw | npx freellmapi setup-openclaw --url http://localhost:3001 --api-key <unified-key> | freellmapi प्रदाता ~/.openclaw/openclaw.json मध्ये, डिफॉल्ट मॉडेल freellmapi/auto |
| Hermes Agent | npx freellmapi setup-hermes --url http://localhost:3001 --api-key <unified-key> | ~/.hermes/config.yaml मध्ये custom मॉडेल ब्लॉक |
सुरू असलेल्या OpenClaw किंवा Hermes gateway ला सेटअप आदेशानंतर रीस्टार्ट करणे आवश्यक आहे.
बॉट आणि FreeLLMAPI एकाच संगणकावर किंवा सर्व्हरवर चालवा. मग बॉट localhost वर gateway गाठतो, आणि gateway पोर्ट इंटरनेटसाठी बंद राहतो. दोन्हीसाठी एक छोटा सर्व्हर किंवा Raspberry Pi पुरेसा आहे.
समस्यानिवारण
| समस्या | कारण | उपाय |
|---|---|---|
| Discord बॉट रिकामे संदेश वाचतो | Message Content intent बंद आहे | portal मध्ये आणि intents.message_content मध्ये ते चालू करा |
| बॉट स्वतःच्या संदेशांना उत्तर देतो | बॉट लेखकांसाठी तपासणी नाही | message.author.bot खरे असल्यास परत या |
| लांब उत्तरांवर Discord त्रुटी 50035 | संदेश 2000 अक्षरांपेक्षा लांब आहे | वरील कोडप्रमाणे उत्तर विभागा |
| संध्याकाळी "All free models are busy" (सर्व मोफत मॉडेल व्यस्त आहेत) | साखळीतील सर्व की त्यांच्या दैनिक मर्यादेवर आहेत | आणखी प्रदात्यांच्या की जोडा. अनेक दैनिक मर्यादा मध्यरात्री UTC ला रीसेट होतात. |
| संथ उत्तरे | संथ मॉडेल किंवा लांब इतिहास | auto:fast वापरा आणि 10 संदेश किंवा कमी ठेवा |
बॉटकडून Connection refused | बॉट Docker मध्ये चालतो आणि localhost वापरतो | host.docker.internal किंवा सामायिक Docker network वापरा |
वारंवार विचारले जाणारे प्रश्न
Discord बॉटसाठी मोफत AI API आहे का?
होय. openai Python पॅकेजसोबत काम करणाऱ्या मोफत टियर असलेले अनेक प्रदाते आहेत. FreeLLMAPI त्यांना एका कीमागे एकत्र ठेवते, त्यामुळे व्यस्त बॉट अनेक प्रदात्यांच्या मर्यादा वापरू शकतो.
मोफत AI Telegram बॉट बनवता येतो का?
होय. बॉटसाठी python-telegram-bot आणि उत्तरांसाठी OpenAI-सुसंगत मोफत API वापरा. या पानावरील कोड पूर्ण आहे.
माझ्या AI बॉटला रेट मर्यादा लागू नये म्हणून काय करू?
फक्त mentions किंवा commands ला उत्तर द्या, प्रत्येक वापरकर्त्याला प्रत्येक काही सेकंदांनी एक विनंती मर्यादित करा, इतिहास लहान ठेवा आणि आणखी प्रदात्यांच्या की जोडा.
माझ्या Discord बॉटला रिकामा संदेश मजकूर का मिळतो?
Message Content intent बंद आहे. Developer Portal मध्ये bot टॅबवर ते चालू करा, आणि कोडमध्ये intents.message_content = True सेट करा.
सर्व मोफत मॉडेल मर्यादेवर असतील तेव्हा काय होते?
FreeLLMAPI Retry-After हेडरसह त्रुटी 429 परत करते. बॉट कोड ती पकडतो आणि वापरकर्त्याला नंतर पुन्हा प्रयत्न करण्यास सांगतो.
संबंधित मार्गदर्शक
- Python मध्ये मोफत LLM API
- मोफत LLM API रेट मर्यादा
- मोफत OpenAI-सुसंगत API बेस 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)