> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Musik erstellen

> Erstellt eine Musikgenerierungsaufgabe mit Suno

Generieren Sie Musik und Songtexte mithilfe von KI. Dies ist eine asynchrone API. Die Create-Response gibt eine Task-ID zurück und kann, wenn verfügbar, auch eine bevorzugte `poll_url` enthalten.

## Anfrage-Body

<ParamField body="model" type="string" default="suno_music">
  Zu verwendendes Modell: `suno_music` für die Musikgenerierung, `suno_lyrics` nur für Songtexte.
</ParamField>

<ParamField body="prompt" type="string">
  Musikbeschreibung. Erforderlich für music-, lyrics-, upload-cover- und upload-extend-Anfragen; bei add-instrumental weglassen.
</ParamField>

<ParamField body="title" type="string">
  Titel für den generierten Song.
</ParamField>

<ParamField body="tags" type="string">
  Stil-Tags (z. B. „pop, upbeat, electronic“).
</ParamField>

<ParamField body="negative_tags" type="string">
  Zu vermeidende Stile. Erforderlich, wenn `audio_operation` `add-instrumental` ist.
</ParamField>

<ParamField body="action" type="string">
  Generierungstyp: `MUSIC` (Standard) oder `LYRICS`.
</ParamField>

<ParamField body="mv" type="string">
  Offizielle Suno-Modellversion. Erforderlich für die Musikgenerierung (wenn `action` fehlt oder `MUSIC` ist); bei Nur-Text-Anfragen weglassen. Unterstützte Werte: `chirp-v3-5`, `chirp-v4`, `chirp-v4-5`, `chirp-v4.5`, `chirp-v4-5plus`, `chirp-v4.5plus`, `chirp-v4-5all`, `chirp-v4.5all`, `chirp-v5`, `chirp-v5-5`, `chirp-v5.5`.
</ParamField>

<ParamField body="make_instrumental" type="boolean">
  Auf `true` setzen, um ein instrumentales Ergebnis ohne Gesang zu erzeugen.
</ParamField>

<ParamField body="audio_url" type="string">
  Öffentlich erreichbare Referenz- oder Upload-Audio-URL. Ohne `audio_operation` verwendet TokenLab den upload-cover-Flow.
</ParamField>

<ParamField body="audio_operation" type="string">
  Upload-Audio-Modus: `upload-cover`, `upload-extend` oder `add-instrumental`. `upload-extend` erfordert `continue_at`; `add-instrumental` erfordert `audio_url`, `title`, `tags` und `negative_tags`.
</ParamField>

<ParamField body="continue_clip_id" type="string">
  ID eines vorherigen Clips, an dem fortgesetzt werden soll.
</ParamField>

<ParamField body="continue_at" type="number">
  Zeitstempel in Sekunden, ab dem fortgesetzt wird. Erforderlich, wenn `audio_operation` `upload-extend` ist.
</ParamField>

## Antwort

<ResponseField name="id" type="string">
  Task-ID für die Statusabfrage.
</ResponseField>

<ResponseField name="task_id" type="string">
  Alias der asynchronen Task-ID, wenn vom Adapter zurückgegeben.
</ResponseField>

<ResponseField name="poll_url" type="string">
  Bevorzugte Polling-URL, wenn verfügbar.
</ResponseField>

<ResponseField name="status" type="string">
  Task-Status: `pending`, `processing`, `completed` oder `failed`.
</ResponseField>

<ResponseField name="created" type="integer">
  Unix-Zeitstempel der Task-Erstellung.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tokenlab.sh/v1/music/generations" \
    -H "Authorization: Bearer sk-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "suno_music",
      "mv": "chirp-v4",
      "prompt": "An upbeat electronic dance track with heavy bass",
      "title": "Night Drive",
      "tags": "electronic, EDM, energetic"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.tokenlab.sh/v1/music/generations",
      headers={"Authorization": "Bearer sk-your-api-key"},
      json={
          "model": "suno_music",
          "mv": "chirp-v4",
          "prompt": "An upbeat electronic dance track with heavy bass",
          "title": "Night Drive",
          "tags": "electronic, EDM, energetic"
      }
  )

  task_id = response.json()["id"]
  print(f"Task ID: {task_id}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.tokenlab.sh/v1/music/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk-your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'suno_music',
      mv: 'chirp-v4',
      prompt: 'An upbeat electronic dance track with heavy bass',
      title: 'Night Drive',
      tags: 'electronic, EDM, energetic'
    })
  });

  const data = await response.json();
  console.log(`Task ID: ${data.id}`);
  ```

  ```go Go theme={null}
  package main

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

  func main() {
      payload := map[string]interface{}{
          "model":  "suno_music",
          "mv":     "chirp-v4",
          "prompt": "An upbeat electronic dance track with heavy bass",
          "title":  "Night Drive",
          "tags":   "electronic, EDM, energetic",
      }
      body, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/music/generations", bytes.NewBuffer(body))
      req.Header.Set("Authorization", "Bearer sk-your-api-key")
      req.Header.Set("Content-Type", "application/json")

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

      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("Task ID: %s\n", result["id"])
  }
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.tokenlab.sh/v1/music/generations');

  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => [
          'Content-Type: application/json',
          'Authorization: Bearer sk-your-api-key'
      ],
      CURLOPT_POSTFIELDS => json_encode([
          'model' => 'suno_music',
          'mv' => 'chirp-v4',
          'prompt' => 'An upbeat electronic dance track with heavy bass',
          'title' => 'Night Drive',
          'tags' => 'electronic, EDM, energetic'
      ])
  ]);

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

  $data = json_decode($response, true);
  echo "Task ID: " . $data['id'];
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "status": "pending",
    "created": 1706000000,
    "model": "suno_music"
  }
  ```
</ResponseExample>
