Skip to main content

Step 1: Get an AppKey

Log in at the dashboard, navigate to API Keys, and create a new AppKey. Your key looks like sk-mm-xxxxxxxxxxxxxxxx.
Keep your AppKey secret. Never commit it to version control or expose it in client-side code.

Step 2: Generate a track

Call the generate endpoint with your prompt:
curl -X POST https://api.example.com/api/v1/music/generate \
  -H "Authorization: Bearer sk-mm-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "An upbeat electronic track with synth arpeggios and driving bass",
    "title": "My First Track"
  }'
Response:
{
  "code": 0,
  "message": "ok",
  "request_id": "req-1710000000000",
  "data": {
    "task_id": "64f3a1b2c8d9e0f1a2b3c4d5",
    "status": "queuing"
  }
}

Step 3: Poll for the result

Music generation is asynchronous and typically takes 30–120 seconds. Poll the task endpoint:
curl -X POST https://api.example.com/api/v1/task/64f3a1b2c8d9e0f1a2b3c4d5 \
  -H "Authorization: Bearer sk-mm-your-key" \
  -H "Content-Type: application/json" \
  -d '{}'
When status is completed, the response includes results with audio URLs:
{
  "code": 0,
  "message": "ok",
  "request_id": "req-1710000000001",
  "data": {
    "id": "64f3a1b2c8d9e0f1a2b3c4d5",
    "status": "completed",
    "created_at": 1710000000000,
    "results": [
      {
        "id": "clip-abc123",
        "audio_url": "https://cdn.example.com/tob/gen/abc123.mp3",
        "image_url": "https://cdn.example.com/tob/gen/abc123.jpg",
        "title": "My First Track",
        "duration": 87.4,
        "tags": "electronic synth",
        "expire_at": 1710604800000
      }
    ]
  }
}

Step 4 (optional): Set a Webhook

Instead of polling, provide callback_url in your request. The server will POST the task result to your URL when generation completes.
{
  "prompt": "...",
  "callback_url": "https://yourserver.com/webhooks/music"
}
See authentication in the API reference for how to verify webhook signatures.