Free AI APIs
Free AI API for a Discord bot
A ChatGPT Plus or Claude Pro plan doesn't include API access, so a Discord bot can't use it directly; Plan2API Free turns that plan into a $0 OpenAI-compatible key with no daily request cap, and your bot runs on GPT-6.1 Sol or Claude Sonnet 5. No paid plan? Groq's free tier gives a bot 30 requests a minute, and Ollama runs it on your own machine with no key at all.
- Best on a plan you have
- Plan2API Free
- Groq free tier
- 30 requests a minute
- No key at all
- Ollama
- Message Content intent
- Not needed for mentions
Updated
Free AI APIs for Discord bots compared
A Discord bot sends lots of short requests in bursts, so per-minute limits matter more than monthly totals.
| Option | Free limits | Fit for a bot |
|---|---|---|
| Plan2API Free | No daily request cap; 1 request per second, bursts of 20, 4 at once | Best if you already pay for ChatGPT, Claude, Google AI Pro or Kimi |
| Groq | 30 requests a minute, 1,000 a day and 200,000 tokens a day on openai/ | Good for busy servers |
| Gemini API free tier | Gemini 3.8 Flash and Flash-Lite models at $0, daily quotas per project | Good for small servers |
| OpenRouter free models | 20 a minute; 50 a day, or 1,000 after buying 10 credits | Fine for a test server |
| Cloudflare Workers AI | 10,000 Neurons a day | Good if the bot runs on Workers |
| Ollama | Free and local, no key | Good if your machine stays on |
| Hugging Face Inference Providers | No monthly credits on free accounts | Not free anymore |
| Cerebras | $5 trial for 30 days, 5 requests a minute on gpt-oss-120b | Too tight for a bot |
| GitHub Models | Retired on July 30, 2026 | No longer available |
Can a Discord bot use your ChatGPT subscription?
Not on its own. ChatGPT Plus is billed separately from the OpenAI API and isn't eligible for OpenAI's API credits benefit, and the Claude API runs on prepaid usage credits that Claude Pro doesn't include.
Plan2API bridges that. It turns the plans you already pay for (Claude Pro, Max or Ultra, ChatGPT Plus or Pro through Codex, Google AI Pro or Ultra, and Kimi memberships through Kimi Code) into one OpenAI-compatible key starting with p2a_. Your bot calls https://api.plan2api.com/v1 with streaming and tool calls, and every request runs on your plan's own usage limits instead of per-token billing.
Build the bot with discord.js and Plan2API
This bot answers only when someone mentions it, so it skips Discord's privileged Message Content intent: Discord still delivers the text of messages that mention your app. Replies are trimmed to Discord's 2,000-character limit.
- Create an application in the Discord Developer Portal, add a bot and copy its token.
- Invite the bot to your server with permission to read and send messages.
- Sign up at plan2api.com/connect, connect your ChatGPT or Claude plan and copy your
p2a_key. - Run
npm install discord.js openai, save the code asbot.mjsand start it withDISCORD_TOKEN=... PLAN2API_KEY=... node bot.mjs.
import { Client, Events, GatewayIntentBits } from "discord.js";
import OpenAI from "openai";
const ai = new OpenAI({ baseURL: "https://api.plan2api.com/v1", apiKey: process.env.PLAN2API_KEY });
const model = "openai/gpt-6.1-sol";
const bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
bot.on(Events.MessageCreate, async (message) => {
if (message.author.bot) return;
if (!message.mentions.has(bot.user, { ignoreEveryone: true, ignoreRoles: true })) return;
const prompt = message.content.replace(/<@!?\d+>/g, "").trim();
if (!prompt) return;
await message.channel.sendTyping();
try {
const completion = await ai.chat.completions.create({
model,
messages: [
{ role: "system", content: "You are a helpful Discord bot. Keep answers short." },
{ role: "user", content: prompt },
],
});
const text = completion.choices[0].message.content || "No reply this time.";
await message.reply(text.slice(0, 2000));
} catch (error) {
console.error(error);
await message.reply("Busy right now, try again in a minute.");
}
});
bot.once(Events.ClientReady, () => console.log(`Logged in as ${bot.user.tag}`));
bot.login(process.env.DISCORD_TOKEN);Run the bot free on your own machine with Ollama
Ollama is free software that runs open models on your computer and serves an OpenAI-compatible API at http://localhost:11434/v1. Run ollama pull gpt-oss:20b, then swap two lines in the bot: the client and the model name.
The OpenAI library still wants an API key, which Ollama ignores, so pass any placeholder. The bot stays online as long as your machine does.
const ai = new OpenAI({ baseURL: "http://localhost:11434/v1", apiKey: "ollama" });
const model = "gpt-oss:20b";Keep a busy server under the limits
- Answer only on mention, like the code above.
- Add a short per-user cooldown so one person can't drain your quota.
- Send only the last few messages as history, not the whole channel.
- On a 429, wait for the
Retry-Afterheader before trying again. - Outgrowing Plan2API Free? Pro is $12 a month or $99 a year: 10 requests per second with bursts of 600, 16 at once and up to 3 connected subscriptions pooled behind one key.
Running the bot on GPT models? The ChatGPT subscription API guide covers every model id your plan unlocks.
Use the AI subscriptions you already pay for as one OpenAI-compatible API key.
- Free: 1 subscription, no daily cap, no card
- Pro: $12 a month
Get an email when a new model drops
Free alerts for new models from OpenAI, Anthropic, Google and Moonshot AI. How it works
Check your inbox
We sent a link to . Open it to turn on alerts.
FAQ
Is there a free AI API for Discord bots?
Yes. Groq's free tier allows 30 requests a minute and 1,000 a day on gpt-oss-120b, and the Gemini API free tier offers Gemini 3.8 Flash at $0. If you already pay for ChatGPT, Claude, Google AI Pro or Kimi, Plan2API Free turns that plan into an OpenAI-compatible key for $0 extra.
Can I use my ChatGPT subscription in a Discord bot?
Not directly, because ChatGPT Plus doesn't include API access. Plan2API Free connects your ChatGPT Plus or Pro plan through Codex and gives your bot an OpenAI-compatible key for $0 extra, with no daily request cap.
Can a Discord bot use Ollama?
Yes. Point the OpenAI client at Ollama's local server, pass any placeholder key since Ollama ignores it, and use a model you've pulled. The bot runs as long as your machine stays on.
How many messages can a free AI Discord bot handle?
Groq's free tier allows 1,000 requests a day, OpenRouter's free models 50 a day until you buy 10 credits, and Plan2API Free has no daily request cap at 1 request per second with bursts of 20.
Does my AI Discord bot need the Message Content intent?
Not if it only answers when mentioned. Discord sends your bot the text of messages that mention it, and of DMs with it, without the privileged Message Content intent.
Sources
- Discord Developer Docs: Gateway intentsdocs.discord.com
- Discord Developer Docs: Messagesdocs.discord.com
- Groq: Rate limitsconsole.groq.com
- Gemini API pricingai.google.dev
- OpenRouter: API limitsopenrouter.ai
- Cloudflare Workers AI pricingdevelopers.cloudflare.com
- Ollama: OpenAI compatibilitydocs.ollama.com
- Hugging Face Inference Providers pricinghuggingface.co
- Cerebras: Rate limitsinference-docs.cerebras.ai
- GitHub Changelog: GitHub Models is now retiredgithub.blog
- ChatGPT Help: API credits benefit for eligible ChatGPT subscriptionshelp.openai.com
- Claude Help Center: How do I pay for my Claude API usagesupport.claude.com