Updated
No Filter AI Discord Bot: Build One in Python
An AI girlfriend API provides a dedicated interface for chat applications that simulate romantic or companion-like interactions using large language models. This guide compares technical approaches, focusing on uncensored models that handle roleplay context without standard content refusals.

What you are building
A bot like this is an ordinary Discord bot whose replies come from a language model that does not refuse lawful adult requests. The bot listens for mentions or a slash command, sends the conversation to a chat-completions endpoint, and posts the answer back to the channel. Nothing about the Discord side changes. The only difference from a typical tutorial is where the text comes from.
This API is OpenAI-compatible, so you do not need a special client. Any OpenAI SDK works once you change the base URL and the key. The model ID is uncensored. It is a single open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. It is text only, so the bot will chat, write fiction, run text games and act out characters, but it will not generate images or audio.
One rule stays fixed no matter how you configure the bot: no sexual content involving minors. Beyond that, Discord has its own terms and community guidelines, and they apply to your bot and your server. Plan on putting adult-themed bots in age-restricted channels and telling users what the bot is for.
Before you start
You need four things: a Discord account, Python 3.10 or newer, an API key, and a server where you have permission to add a bot.
- Open the Discord developer portal, create an application, add a bot user and copy its token. Treat that token like a password.
- On the bot page, switch on the Message Content intent. Without it your bot receives messages with empty text.
- Invite the bot to your server with the
botscope and permission to read and send messages. - Create an API key on the API key page. New users can claim $0.50 of trial credit with one click after sign-up. It is valid for 7 days and works for a first test of everything below.
Install the two libraries:
pip install discord.py openai
export DISCORD_TOKEN="your-discord-bot-token"
export NOFILTER_API_KEY="your-api-key"
Keep both values in environment variables or a secrets manager. Never paste them into a file that goes to a public repository.
The minimal bot
The first version answers whenever someone mentions the bot. It uses the async OpenAI client so the Discord event loop never blocks while the model is writing.
import os
import discord
from openai import AsyncOpenAI
ai = AsyncOpenAI(
base_url="https://api.nofilterai.top/v1",
api_key=os.environ["NOFILTER_API_KEY"],
)
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Client(intents=intents)
SYSTEM = (
"You are a witty companion in a Discord server for adults. "
"Stay in character, keep replies under 1500 characters."
)
@bot.event
async def on_message(message: discord.Message):
if message.author.bot or bot.user not in message.mentions:
return
text = message.clean_content.replace(f"@{bot.user.name}", "").strip()
async with message.channel.typing():
resp = await ai.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": SYSTEM},
{"role": "user", "content": text},
],
temperature=0.9,
max_tokens=500,
)
await message.reply(resp.choices[0].message.content[:1900])
bot.run(os.environ["DISCORD_TOKEN"])
Two details matter here. Discord rejects messages longer than 2,000 characters, so the code both asks for a short reply in the system prompt and slices the text at 1,900 as a safety net. And max_tokens is optional on this API, but setting it keeps a runaway answer from costing more than you planned.
Add memory per channel
A bot with no memory feels broken after two messages. The fix is to keep a short list of recent turns for each channel and send it with every request. The API is stateless, so the history is entirely yours to manage.
from collections import defaultdict, deque
MAX_TURNS = 16
history = defaultdict(lambda: deque(maxlen=MAX_TURNS))
async def reply_with_memory(message, text):
h = history[message.channel.id]
h.append({"role": "user", "content": f"{message.author.display_name}: {text}"})
resp = await ai.chat.completions.create(
model="uncensored",
messages=[{"role": "system", "content": SYSTEM}, *h],
temperature=0.9,
max_tokens=500,
)
answer = resp.choices[0].message.content
h.append({"role": "assistant", "content": answer})
return answer
Prefixing each user line with the display name lets the model tell speakers apart in a busy channel. A deque with maxlen drops the oldest turns on its own. Sixteen turns is a sensible start. The context window is 100,000 tokens, so you could keep far more, but every extra turn is billed as input on every later request. Longer memory is a product decision, not a technical limit.
Longer-running characters
If a character has to remember facts over weeks, store a short summary per channel in a file or database and add it to the system prompt. Ask the model itself to refresh the summary every 30 or so turns. This keeps the prompt small while the character still remembers names, running jokes and plot points.
Stay inside the rate limits
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent requests and 60 per minute. A single quiet server will never touch those numbers, but a popular channel can fire several mentions in the same second.
The simplest guard is a semaphore that caps parallel calls below the concurrency limit, plus a retry for the occasional 429. The API signals problems with HTTP 429 and an error code: rate_limited means too many requests per minute, concurrency means too many at once. On temporary overload it also sends Retry-After: 5.
import asyncio
from openai import RateLimitError
gate = asyncio.Semaphore(6)
async def ask(messages):
async with gate:
for attempt in range(4):
try:
r = await ai.chat.completions.create(
model="uncensored", messages=messages, max_tokens=500
)
return r.choices[0].message.content
except RateLimitError:
await asyncio.sleep(5 * (attempt + 1))
return "I am busy right now, try again in a moment."
If you stream replies and edit the Discord message as tokens arrive, remember that a streamed request holds its concurrency slot until the stream ends. Streaming feels faster, but Discord limits how often you can edit a message, so update the text every second or so rather than on every token. For most bots, a plain non-streamed reply plus the typing indicator is simpler and works fine.
Slash commands, personas and server rules
Mentions are the quickest way to start, but slash commands give users a cleaner interface. With discord.app_commands you can add /persona to switch the system prompt, /reset to clear the channel history and /summary to print the saved summary. Each command only edits the dictionary of prompts and histories shown above.
A few practical habits keep a server healthy:
- Run adult-themed bots only in channels marked age-restricted, and say so in the channel topic.
- Put the character brief and the boundaries in the system prompt, and keep it short. Models follow a clear 150-word brief better than a long rulebook.
- Log request IDs. Every response carries an
X-Request-Idheader, which helps when you need to trace a single odd reply. - Add a hard rule in your own code that refuses any request sexualising minors, even though the model is also bound by that rule. The API will not serve it, and your bot should not try.
Prompts sent to the API are not used for training, which is worth saying in your server rules if your members chat about personal things. Your bot also stores whatever you put in the history, so decide how long to keep it and tell people.
What it costs to run
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit with no subscription. Failed or refused requests are not charged, and credit never expires. Here is a realistic chat turn: 16 turns of history plus the system prompt come to about 1,500 input tokens, and the reply is about 300 tokens.
| Part | Tokens | Rate | Cost |
|---|---|---|---|
| Input | 1,500 | $0.15 per 1M | $0.000225 |
| Output | 300 | $0.50 per 1M | $0.000150 |
| One reply | $0.000375 |
A thousand replies cost $0.375. Ten thousand cost $3.75. A $20 top-up, the smallest amount, covers a little over 53,000 replies at that size. Top-ups run from $20 to $500 in whole dollars, with a 5% bonus from $50, 10% from $100 and 15% from $200. This site accepts crypto only: USDT on TRC20 or USDC on Base. See the pricing page for the details.
The biggest lever on cost is history length. If you double the turns kept, input tokens roughly double too. Cap them, and watch the X-Balance-USD response header, which reports your remaining balance after each call. You can log it and have the bot post a warning in an admin channel when it drops under a threshold.
Troubleshooting
The bot is online but never answers: the Message Content intent is almost always the cause. Enable it in the developer portal and also in the code, as shown above.
You see 429 errors under load: lower the semaphore, check which error code came back, and back off. If the code is rate_limited, you are sending too many requests per minute. If it is concurrency, too many are in flight at once.
Replies feel flat: raise temperature toward 1.0, add two or three example lines of the character's speech to the system prompt, and try a small frequency_penalty to stop repeated phrases. These parameters are passed through to the model.
Replies get cut off: Discord's 2,000 character limit is the usual reason. Split long answers into several messages, or ask for shorter ones. For a deeper look at the request options, read the API quickstart, and if you are building a character-driven bot, the AI companion API page covers persona design in more detail.
More guides
Questions and answers
Do I need a special library for an unfiltered Discord bot?
No. Use discord.py (or discord.js) for Discord and the normal OpenAI SDK for the model. Only the base URL, the key and the model ID uncensored change.
Can the bot generate images or voice replies?
No. The API is text only, with no image, audio or video generation and no embeddings.
How many users can chat with the bot at once?
A full key allows 8 concurrent requests and 300 requests per minute. Queue extra requests in your bot and retry on HTTP 429.
Is there a free way to test it?
Yes. After sign-up you can claim $0.50 of trial credit with one click on the API key page. It is valid for 7 days, one per person.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.
Get API key