Skip to main content
Poll this endpoint to check the status of your music generation task.
If the create response included poll_url, prefer calling that exact URL for polling. /v1/tasks/{id} is the canonical fixed status endpoint for music jobs, and id / task_id should be treated as the same async task identity.If the task no longer exists or is no longer available in the public task record, TokenLab returns async_task_not_found with the message Task not found or no longer available.

Path Parameters

id
string
required
The music generation task ID.

Response

id
string
Task ID.
task_id
string
Async task identifier alias when provided.
poll_url
string
Preferred polling URL when the create response supplies one.
status
string
Task status: pending, processing, completed, or failed.
progress
integer
Optional progress value. Returned only when a real progress value is available; use status to determine completion.
audio_url
string
URL to download the audio file (when completed).
video_url
string
URL to the video version with visualizer (when completed).
title
string
Generated song title.
lyrics
string
Generated or provided lyrics.
error
string
Error message (when failed).
curl "https://api.tokenlab.sh/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
  -H "Authorization: Bearer sk-your-api-key"
import requests
import time

task_id = "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
poll_url = f"/v1/tasks/{task_id}"

while True:
    response = requests.get(
        f"https://api.tokenlab.sh{poll_url}",
        headers={"Authorization": "Bearer sk-your-api-key"}
    )
    result = response.json()

    if result["status"] == "completed":
        print(f"Audio URL: {result['audio_url']}")
        break
    elif result["status"] == "failed":
        print(f"Error: {result['error']}")
        break

    time.sleep(5)  # Poll every 5 seconds
const taskId = 'ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
const pollUrl = `/v1/tasks/${taskId}`;

async function pollForMusic() {
  while (true) {
    const response = await fetch(
      `https://api.tokenlab.sh${pollUrl}`,
      { headers: { 'Authorization': 'Bearer sk-your-api-key' } }
    );

    const result = await response.json();

    if (result.status === 'completed') {
      console.log(`Audio URL: ${result.audio_url}`);
      return result.audio_url;
    } else if (result.status === 'failed') {
      throw new Error(result.error);
    }

    await new Promise(r => setTimeout(r, 5000));
  }
}
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
    "time"
)

func main() {
    taskID := "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    pollURL := fmt.Sprintf("https://api.tokenlab.sh/v1/tasks/%s", taskID)

    for {
        req, _ := http.NewRequest("GET",
            pollURL, nil)
        req.Header.Set("Authorization", "Bearer sk-your-api-key")

        client := &http.Client{}
        resp, _ := client.Do(req)

        var result map[string]interface{}
        json.NewDecoder(resp.Body).Decode(&result)
        resp.Body.Close()

        if result["status"] == "completed" {
            fmt.Printf("Audio URL: %s\n", result["audio_url"])
            break
        } else if result["status"] == "failed" {
            fmt.Printf("Error: %s\n", result["error"])
            break
        }

        time.Sleep(5 * time.Second)
    }
}
<?php
$taskId = 'ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
$pollUrl = "https://api.tokenlab.sh/v1/tasks/{$taskId}";

while (true) {
    $ch = curl_init($pollUrl);

    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer sk-your-api-key'
        ]
    ]);

    $response = curl_exec($ch);
    curl_close($ch);

    $result = json_decode($response, true);

    if ($result['status'] === 'completed') {
        echo "Audio URL: {$result['audio_url']}\n";
        break;
    } elseif ($result['status'] === 'failed') {
        echo "Error: {$result['error']}\n";
        break;
    }

    sleep(5);
}
{
  "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "completed",
  "audio_url": "https://cdn.example.com/music/abc123.mp3",
  "video_url": "https://cdn.example.com/music/abc123.mp4",
  "title": "Night Drive",
  "lyrics": "[Verse 1]\nDriving through the night..."
}