Discord bots

A music generation API for Discord bots

Let your bot make a new song on command. A /song command sends the prompt to BlueMetal and posts the MP3 in the channel about 75 seconds later. Each song costs $0.0095.

The whole command

// discord.js v14: /song <prompt> posts a new song
client.on('interactionCreate', async (i) => {
  if (!i.isChatInputCommand() || i.commandName !== 'song') return
  await i.deferReply()
  const api = 'https://api.bluemetal.ai/v1/music/generations'
  const headers = { Authorization: `Bearer ${process.env.BLUEMETAL_API_KEY}`, 'Content-Type': 'application/json' }
  const prompt = i.options.getString('prompt', true)
  let song = await (await fetch(api, { method: 'POST', headers, body: JSON.stringify({ prompt }) })).json()
  while (song.status === 'queued' || song.status === 'running') {
    await new Promise((r) => setTimeout(r, 5000))
    song = await (await fetch(`${api}/${song.id}`, { headers })).json()
  }
  if (song.status !== 'succeeded') return i.editReply('No song this time. Try again.')
  await i.editReply({ content: prompt, files: [{ attachment: song.audio.url, name: 'song.mp3' }] })
})

BlueMetal at a glance

Price
$0.0095 per song, flat. No subscription.
Song length
About 3 minutes (most run 2 to 4). Songs end naturally.
Speed
75 seconds on average from request to finished song. 93% are ready within 90 seconds.
Vocals
Vocals with lyrics written for you, or instrumental. Say which in the prompt.
Formats
MP3, WAV or FLAC, 48 kHz stereo.
Rights
BlueMetal claims no ownership of your songs. No royalties.
Free to try
$0.10 of credit on sign-up, about 10 songs. No card.

Questions

How long does a song take?

75 seconds on average. Discord gives a deferred reply 15 minutes, so the bot answers in the same message.

Will the file fit in Discord?

Yes. A 3-minute MP3 is about 5 MB, under Discord’s 10 MB upload limit.

What does it cost to run?

$0.0095 per song. 1,000 songs cost $9.50. New accounts get about 10 songs free.

Can the bot make instrumentals?

Yes. Add "instrumental, no vocals" to the prompt.

Related