Grok Discord Bot: Add One or Build Your Own
How to bring Grok into your Discord server safely, what it costs, and how to wire the Grok API yourself.
A Grok Discord bot answers questions inside your server using Grok, the AI model from xAI. It replies to mentions, slash commands, or chat messages like a teammate.
There is no official Grok bot from xAI for Discord. Every working option today is either a community bot or one you build yourself with the Grok API.
This guide covers both paths. You will learn how to add an existing bot, how to build your own, what it costs, and how to keep it safe.
Is there an official Grok Discord bot?
No, xAI does not publish an official Grok bot for Discord as of 2026. Every Grok Discord bot you find is a third-party project.
Third-party bots connect to Grok through the public Grok API. The bot handles Discord events, and the API generates each reply.
Treat any listing that claims to be the official Grok Discord bot with caution. It is community-built and not endorsed by xAI.
- Official xAI Discord bot: does not exist.
- Community Discord bots: real, and they call the Grok API.
- Your own bot: fully supported through the documented Grok API.
Need help shipping a Grok Discord bot for your server or team? Layer3 Labs builds and hosts custom AI chatbots end to end.
Book a ConsultationHow to add a Grok-powered bot to your Discord server
To add an existing Grok bot, open its invite link and authorize it for your server. You need the Manage Server permission on that server.
Discord shows a permission screen during the invite. Review every permission before you click Authorize.
Grant only what the bot needs. A chat bot needs Read Messages, Send Messages, and often Read Message History.
Be careful with third-party bots that ask for broad admin rights. A bot with admin access can read, move, and delete almost anything.
- Open the bot invite link from its official page or GitHub repo.
- Pick your server from the dropdown (needs Manage Server).
- Uncheck permissions the bot does not need.
- Skip any bot that demands Administrator for basic chat.
- Test it in a private channel before a public rollout.
How to build your own Grok Discord bot
Building your own bot gives you full control over data, prompts, and cost. You wire two pieces together: a Discord app and the Grok API.
Start by creating a Discord application in the Discord Developer Portal. Add a bot user and copy its token.
Enable the Message Content Intent under Privileged Gateway Intents. Without it, your bot cannot read message text.
Next, get a Grok API key from the xAI developer console. Store both secrets in environment variables, never in code.
The Grok API is OpenAI-compatible, so most SDKs work with a changed base URL. Point requests at the xAI endpoint and pass a Grok model name.
In our work building AI chatbots and automation systems for clients, we keep every API key in server-side environment variables and never expose it to the client.
Here is a minimal Python bot using discord.py and the OpenAI SDK pointed at Grok:
from openai import OpenAI import discord, os client = OpenAI(api_key=os.environ['XAI_API_KEY'], base_url='https://api.x.ai/v1') intents = discord.Intents.default(); intents.message_content = True bot = discord.Client(intents=intents) @bot.event async def on_message(m): if m.author == bot.user: return if bot.user in m.mentions: r = client.chat.completions.create(model='grok-4', messages=[{'role':'user','content':m.content}]) await m.reply(r.choices[0].message.content) bot.run(os.environ['DISCORD_TOKEN'])
Run the script on any always-on host. A small cloud VM, a container platform, or a hobby server all work.
- Create the app and bot user in the Discord Developer Portal.
- Enable Message Content Intent for text access.
- Get a Grok API key from the xAI console.
- Store XAI_API_KEY and DISCORD_TOKEN as environment variables.
- Point the SDK base URL at the xAI endpoint.
- Deploy to an always-on host so the bot stays online.
What a Grok Discord bot costs to run
A self-hosted Grok Discord bot has two costs: the Grok API and hosting. The Discord bot itself is free to create.
The Grok API bills per token, with input tokens cheaper than output tokens. You pay only for what your bot processes.
xAI publishes rates per million tokens and offers lower-cost Fast model variants for high-volume, latency-sensitive use. Confirm the exact figures before you commit, and verify current rates on x.ai.
Hosting adds a small fixed cost. A basic cloud instance to keep the bot online often runs a few dollars per month.
Busy servers cost more because every mention and reply consumes tokens. Set spend limits in the xAI console to avoid surprises.
- Discord app: free to create and invite.
- Grok API: pay-per-token, input cheaper than output.
- Fast Grok variants: lower price for high-volume chat.
- Hosting: a few dollars per month for a small always-on host.
- Cost driver: message volume and reply length.
Safety, rate limits, and moderation
Protecting your Grok API key is the single most important safety step. Anyone with the key can spend your money.
Keep the key server-side and out of your public repository. Add your environment file to gitignore before the first commit.
Respect Grok API rate limits so your bot does not get throttled. Queue requests and add retries with backoff for busy channels.
Add your own moderation layer on top of the model. Filter user input, cap message length, and block abusive prompts.
Give members a clear notice that an AI bot reads channel messages. That transparency builds trust and helps with compliance.
- Never hardcode the API key; use environment variables.
- Add the env file to gitignore to avoid a leak.
- Handle rate limits with a queue and backoff.
- Filter and length-cap user input before sending it to Grok.
- Restrict the bot to specific channels or roles.
- Log usage so you can spot abuse fast.
Grok vs other AI Discord bots
Grok competes with bots built on ChatGPT, Claude, and Gemini for the Discord AI slot. The right choice depends on your goal.
Grok fits servers that want a fast, current, casual voice. Other models fit different needs like long documents or tight budgets.
The table below maps each approach to the job it suits best. Match the bot to how your community actually chats.
- Grok-powered bot | Fast, casual replies and current-events chat
- ChatGPT-based bot | General knowledge and broad plugin ecosystems
- Claude-based bot | Long context, careful reasoning, safer moderation help
- Gemini-based bot | Google-ecosystem tasks and multimodal prompts
- Prebuilt community bot | Quick setup with zero coding
- Self-built API bot | Full control over data, prompts, and cost
Frequently Asked Questions
- No, xAI does not offer an official Grok Discord bot as of 2026. All available options are third-party bots or ones you build with the Grok API.
- Open the bot's invite link, choose your server, and authorize it. You need the Manage Server permission and should grant only the permissions the bot needs.
- You can build the bot for free, but the Grok API charges per token. Creating the Discord app costs nothing, and open-source templates on GitHub give you a starting point.
- You pay the Grok API per token plus a small hosting fee. Input tokens cost less than output tokens, and cost scales with message volume. Verify current rates on x.ai.
- It depends on the bot's owner and permissions. A hosted third-party bot sends your members' messages to an outside server, so review its privacy terms and limit its permissions.
- Use a Fast Grok variant for high-volume, casual chat to keep costs low. Use a flagship Grok model when replies need deeper reasoning.
Want a custom AI bot for your community or business?
Layer3 Labs builds and deploys AI chatbots and automation systems that fit your exact workflow. We handle the API wiring, hosting, and moderation so you do not have to.
Book a Consultation