Discord bot that queries a serverless inference API with a chosen LLM.
- Node.js 18+
- Discord application and bot token
- Guild (server) where you can register slash commands
- Clone and install
npm install- Configure environment
Copy
.env.exampleto.envand fill values:
DISCORD_BOT_TOKEN=your-discord-bot-token
DISCORD_CLIENT_ID=your-app-client-id
DISCORD_GUILD_ID=your-guild-id
LLM_API_KEY=your-llm-api-key
LLM_API_BASE=https://api.your-inference-platform.com/v1
- Register slash commands (guild-scoped)
npm run register- Start the bot
npm start- In your Discord server, use
/askllm. - Choose a model and provide the question.
- The bot posts "Thinking…", then replaces it with the model used and the answer.
- The LLM API is assumed OpenAI-compatible at
POST {LLM_API_BASE}/chat/completionswithAuthorization: Bearerheader. - Increase timeouts or add retries in
src/llmClient.jsif needed.