Introduction
Venice AI has become a powerhouse for advanced AI-powered responses, providing Llama 3.1 405B and other powerful models. Previously, we covered the Telegram bot integration, but now it’s time to bring Venice AI to Discord. This guide will walk you through everything, from setting up your bot to running advanced AI-powered slash commands in Discord.
If you’re looking to build a smart, interactive AI chatbot using Venice AI on Discord, this is the guide for you! I will continue adding features such as image & code generation as I flesh it out. Stay tuned! 🚀
1️⃣ Setting Up Your Venice AI Discord Bot
Step 1: Create a Discord Bot
- Go to the Discord Developer Portal → Click Here

- Click “New Application” and give it a name (e.g., Ven-Bot).

- Go to the “Bot” tab (left sidebar).

- Click Reset Token → Copy and save it (you won’t see it again).
Step 2: Invite Your Bot to a Server
- Go to the OAuth2 > URL Generator tab.
- Under Scopes, check “bot” and “applications.commands”.

- Under Bot Permissions, select:
- ✅ Read Messages / View Channels
- ✅ Send Messages
- ✅ Use Slash Commands

- Copy the generated URL at the bottom.

- Open the link, select your server, and click Authorize.

Your bot is now inside your server, but we need to code it!
2️⃣ Writing the Code for the Venice AI Discord Bot
Step 1: Install Dependencies
Open a terminal or command prompt and run:
pip install discord.py requests python-dotenv
Step 2: Create the .env
File
To store your bot secrets securely, create a file called .env
in your project directory and add:
DISCORD_TOKEN=your-discord-bot-token
VENICE_API_KEY=your-venice-api-key
Replace:
your-discord-bot-token
→ The token from Step 1.your-venice-api-key
→ Your Venice AI API key.
Step 3: Write the Bot Code
Create a file bot.py
and paste this:
import os
import requests
import logging
from dotenv import load_dotenv
import discord
from discord import app_commands
from discord.ext import commands
# Load environment variables
load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
VENICE_API_KEY = os.getenv('VENICE_API_KEY')
# Set up logging
logging.basicConfig(level=logging.INFO)
# Initialize Discord Bot
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='/', intents=intents)
# Use the bot's built-in command tree
tree = bot.tree
# Venice AI API Configuration
VENICE_API_BASE = "https://api.venice.ai/api/v1"
HEADERS = {"Authorization": f"Bearer {VENICE_API_KEY}", "Content-Type": "application/json"}
# System prompts
SYSTEM_PROMPT_CHAT = "You are a highly intelligent AI assistant. Provide clear, concise, and insightful responses."
SYSTEM_PROMPT_CHAIN = "You iteratively refine your responses to provide the best possible answer."
# Event: Bot is Ready
@bot.event
async def on_ready():
await tree.sync() # Sync slash commands
logging.info(f"✅ Logged in as {bot.user} - Slash Commands Registered!")
# Slash Command: AI Chat (/chat)
@tree.command(name="chat", description="Chat with Venice AI")
async def chat(interaction: discord.Interaction, prompt: str):
await interaction.response.defer() # Acknowledge the command
payload = {
"model": "llama-3.1-405b",
"messages": [
{"role": "system", "content": SYSTEM_PROMPT_CHAT},
{"role": "user", "content": prompt}
]
}
response = requests.post(f"{VENICE_API_BASE}/chat/completions", json=payload, headers=HEADERS)
if response.status_code == 200:
data = response.json()
if 'choices' in data and len(data['choices']) > 0:
await interaction.followup.send(data['choices'][0]['message']['content'])
else:
await interaction.followup.send("❌ AI failed to generate a response.")
else:
await interaction.followup.send(f"❌ Error {response.status_code}: Failed to reach Venice AI.")
# Slash Command: Iterative AI Reasoning (/chain)
@tree.command(name="chain", description="Iteratively refine AI responses")
async def chain(interaction: discord.Interaction, prompt: str):
await interaction.response.defer()
iteration_count = 3
refined_prompt = prompt
for i in range(iteration_count):
payload = {
"model": "llama-3.1-405b",
"messages": [
{"role": "system", "content": SYSTEM_PROMPT_CHAIN},
{"role": "user", "content": refined_prompt}
]
}
response = requests.post(f"{VENICE_API_BASE}/chat/completions", json=payload, headers=HEADERS)
if response.status_code == 200:
data = response.json()
if 'choices' in data and len(data['choices']) > 0:
refined_prompt = data['choices'][0]['message']['content']
else:
await interaction.followup.send("❌ AI failed to refine response.")
return
else:
await interaction.followup.send(f"❌ Error {response.status_code}: Venice AI issue.")
return
await interaction.followup.send(f"✅ Final Response:\n\n{refined_prompt}")
# Run the bot
bot.run(DISCORD_TOKEN)
3️⃣ Running the Bot
Now that the bot is fully coded, start it by running:
python3 bot.py
If successful, you’ll see:
✅ Logged in as Ven-Bot - Slash Commands Registered!
4️⃣ Using the Bot in Discord
🔹 Chat With the AI
In any text channel, type:
/chat What is quantum mechanics?
📌 Venice AI will reply instantly.
🔹 Chain-of-Thought Reasoning
Use:
/chain Explain the importance of AI in medicine.
📌 The bot will refine the response three times to create the best possible explanation.

5️⃣ Troubleshooting Common Issues
🔸 Slash Commands Not Showing Up?
- Check if commands are registered:
- Restart the bot and wait a few minutes.
- Slash commands take up to 1 hour to globally propagate.
- Force Register Commands Add this inside
on_ready() await tree.sync(guild=discord.Object(id=YOUR_SERVER_ID))
ReplaceYOUR_SERVER_ID
with your actual Discord Server ID. - Make sure “Use Application Commands” is enabled:
- Go to Server Settings > Roles > @everyone.
- Enable “Use Application Commands”.
6️⃣ Final Thoughts
✅ Brings Venice AI to Discord
✅ Supports /chat
and /chain
slash commands
✅ Uses Llama 3.1 405B for advanced AI responses model can easily be changed
✅ Easily customizable
🚀 Now, you can chat with Venice AI inside Discord just like in Telegram. Enjoy your AI-powered Discord bot! 🎉 Stay tuned for more developments with VVV and Venice AI as well as more features like image and code generation. Be sure to check out Bobbie Beach’s space to get all sorts of neat tips, tricks, and knowledge to make life go smoother!