Skip to content

ディスコードUse · Discord bots

Anime images in a Discord bot for $0.003 each.

One POST request from your bot returns a finished anime illustration in about 4 seconds. It costs $0.003 per image, so $5 buys 1,666 images and a bot that draws 50 a day costs $4.50 per 30 days. There is no subscription and no rate limit on a key; the prepaid balance is the only cap. A new account has 3 free images and needs no card.
$0.003
per image, any shape
1,666
images for $5
~4s
per image
3
free images, no card

01What the bot costs to run

A bot for friends

20 images a day

$0.06 a day · $1.80 per 30 days

An active community server

50 images a day

$0.15 a day · $4.50 per 30 days

A busy server

500 images a day

$1.50 a day · $45.00 per 30 days

A public bot in many servers

3,000 images a day

$9.00 a day · $270.00 per 30 days

The bill cannot pass what you loaded. When the balance runs out the API answers 402 with a message the bot can show its owner, and nothing is charged. Failed generations are refunded.

02The shortest working bot

The starter is a complete bot with one slash command. Clone it, add two values, run it:

terminal
git clone https://github.com/animeapi-ai/discord-bot-starter
cd discord-bot-starter
cp .env.example .env    # paste DISCORD_TOKEN and ANIMEAPI_KEY
npm install && npm start

If you already have a bot, this is the whole of the AnimeAPI part:

anime-image.mjs
// anime-image.mjs · the part of the bot that talks to AnimeAPI
export async function animeImage(prompt, orientation = "square") {
  const res = await fetch("https://animeapi.ai/api/generate", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.ANIMEAPI_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ prompt, model: "anime", orientation }),
  });
  const data = await res.json();
  // 402: the balance is empty. 400: the prompt was refused. Neither is charged.
  if (!res.ok) throw new Error(data.error);
  // Download it: an uploaded file stays in the channel, the link is not storage.
  const file = await fetch(data.image_url);
  return Buffer.from(await file.arrayBuffer());
}
in your command handler
// inside the /anime slash-command handler (discord.js v14)
await interaction.deferReply(); // Discord allows 3 seconds; an image takes about 4
try {
  const image = await animeImage(interaction.options.getString("prompt", true));
  await interaction.editReply({ files: [{ attachment: image, name: "anime.webp" }] });
} catch (err) {
  await interaction.editReply(`Couldn't draw that: ${err.message}`);
}

The Discord guide has the full walk-through, including registering the command.

03Things specific to Discord

04What comes back

Made through the API for this page with the prompts shown, unedited.

05Limits to know first

06Questions

What is the cheapest way to add anime image generation to a Discord bot?
One of the cheapest is AnimeAPI at $0.003 per image with no subscription. A bot that makes 50 images a day costs $0.15 a day, $4.50 per 30 days. $5 buys 1,666 images and a new account has 3 free ones.
Discord needs a reply within 3 seconds. Is an image fast enough?
An image takes about 4 seconds, so the bot must acknowledge first with interaction.deferReply() and then edit the reply when the image arrives. Discord allows 15 minutes after a deferral.
Can someone run up a bill by spamming the command?
No further than the balance you loaded. AnimeAPI is prepaid: when the balance is empty the API answers 402 and nothing is charged. The starter bot also has a per-user cooldown, 30 seconds by default.
Is the output safe for a public server?
AnimeAPI does not generate adult content. Explicit prompts are refused and not charged, and every image passes a safety check before it is returned.