Generate Music

Create an original song from a prompt and optional lyrics.
curl --request POST \
  --url https://geoff.ai/api/v1/music_generation \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "magma",
    "prompt": "Indie folk, melancholic, introspective, longing",
    "lyrics": "[verse]\nStreetlights flicker, the night breeze flows\nShadows dance where nobody goes",
    "audio_setting": {
      "sample_rate": 44100,
      "bitrate": 256000,
      "format": "mp3"
    }
  }'

Response

{
  "data": {
    "audio": "hex-encoded audio data",
    "status": 2
  },
  "trace_id": "04ede0ab069fb1ba8be5156a24b1e081",
  "extra_info": {
    "music_duration": 25364,
    "music_sample_rate": 44100,
    "music_channel": 2,
    "bitrate": 256000,
    "music_size": 813651
  }
}

Generate Lyrics First

Use the lyrics endpoint to generate lyrics, then pass them to music generation:
import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
}

# Step 1: Generate lyrics
lyrics_response = requests.post(
    "https://geoff.ai/api/v1/lyrics_generation",
    headers=headers,
    json={
        "prompt": "A song about coding late at night",
        "style": "indie rock",
    },
)
lyrics = lyrics_response.json()["data"]["lyrics"]

# Step 2: Generate music with lyrics
music_response = requests.post(
    "https://geoff.ai/api/v1/music_generation",
    headers=headers,
    json={
        "model": "magma",
        "prompt": "Indie rock, energetic, upbeat",
        "lyrics": lyrics,
        "audio_setting": {
            "sample_rate": 44100,
            "bitrate": 256000,
            "format": "mp3",
        },
    },
)

# Save the audio
audio_hex = music_response.json()["data"]["audio"]
audio_bytes = bytes.fromhex(audio_hex)
with open("song.mp3", "wb") as f:
    f.write(audio_bytes)