Integrazione e utilizzo di Producer Tasks API

La funzione principale di Producer Tasks API è verificare lo stato di esecuzione di un'attività inserendo l'ID dell'attività generato da Producer Audios Generation API.

Questo documento illustra in dettaglio le istruzioni per l'integrazione di Producer Tasks API, aiutandovi a integrarla facilmente e a sfruttarne appieno le potenti funzionalità. Con Producer Tasks API, potete verificare facilmente lo stato di esecuzione delle attività di Producer Audios Generation API.

Procedura di richiesta

Per utilizzare Producer Audios Generation API, recatevi prima nella console 零壹AI per ottenere il vostro API Token e conservarlo per l'uso successivo.

Se non avete ancora effettuato l'accesso o non siete registrati, verrete reindirizzati automaticamente alla pagina di accesso per registrarvi ed effettuare l'accesso; una volta completata la procedura, tornerete automaticamente alla pagina corrente.

L'API Key di un'applicazione generica può essere utilizzata per i servizi abilitati sull'account; la Key di un'applicazione dedicata va utilizzata nell'ambito dei servizi di tale applicazione. Verificate i permessi, la scadenza e i limiti della Key e assicuratevi che il saldo dell'applicazione sia sufficiente a pagare questa richiesta. Il credito di prova disponibile è quello mostrato nell'account; se il saldo è insufficiente, fate clic sul pulsante «Ricarica».

📘 Documentazione completa: Producer Audios Generation API →

Esempio di richiesta

Producer Tasks API può essere utilizzata per interrogare i risultati di Producer Audios Generation API. Per informazioni su come utilizzare Producer Audios Generation API, consultate la documentazione Producer Audios Generation API .

Prendiamo come esempio un ID di attività restituito dal servizio Producer Audios Generation API per mostrare come utilizzare questa API. Supponiamo di avere un ID di attività: 1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad; di seguito mostriamo come, passando un ID di attività.

Immagine di esempio dell'attività

Impostazione delle intestazioni e del corpo della richiesta

Le intestazioni della richiesta includono:

  • accept: specifica che la risposta deve essere ricevuta in formato JSON; qui si inserisce application/json.
  • authorization: la chiave per chiamare l'API; dopo averla richiesta, potete selezionarla direttamente dal menu a discesa.

Il corpo della richiesta include:

  • id: l'ID dell'attività inviato.
  • action: l'operazione da eseguire sull'attività.

Le impostazioni sono mostrate nell'immagine seguente:

Esempio di codice

Come si può vedere, sul lato destro della pagina è già stato generato automaticamente il codice in vari linguaggi, come mostrato nell'immagine:

Alcuni esempi di codice sono riportati di seguito:

CURL

curl -X POST 'https://api.01ai.cloud/producer/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
  "action": "retrieve"
}'

Esempio di risposta

Dopo una richiesta riuscita, l'API restituirà i dettagli dell'attività. Ad esempio:

{
  "_id": "69541b81ff2676299ccc3b29",
  "id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
  "api_id": "01d96900-9f8c-41d7-814c-95c7a885ba61",
  "application_id": "920ba772-867a-48ae-8efa-9b9f94136199",
  "created_at": 1767119745.524,
  "started_at": 1767119745.584,
  "finished_at": 1767119785.589,
  "elapsed": 40.005,
  "credential_id": "eeae817d-d6ff-493e-8f88-6c62391da7c6",
  "request": {
    "action": "generate",
    "model": "FUZZ-2.0 Pro",
    "instrumental": false,
    "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
    "custom": true,
    "callback_url": "https://webhook.site/0d73431d-f833-4be4-9276-b6e1690d55c1"
  },
  "trace_id": "1da03537-4eb8-410d-b849-43f03085a3bb",
  "type": "audios",
  "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
  "response": {
    "task_id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
    "data": [
      {
        "id": "1dd08826-478e-43a6-868f-aff5ababac2c",
        "title": "Woke up with the sun in my eyes",
        "image_url": "https://cdn.acedata.cloud/e724d7f13d.png",
        "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
        "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3",
        "video_url": null,
        "image_id": "1dd08826-478e-43a6-868f-aff5ababac2c",
        "topic": null,
        "seed": "1490770667",
        "sound": "",
        "created_at": "2025-12-30T18:36:00.994141Z",
        "model": "FUZZ-2.0 Pro",
        "progress": "100%",
        "state": "succeeded",
        "duration": "135.2330158730159"
      }
    ]
  }
}

Il risultato restituito contiene diversi campi: il campo request è il corpo della richiesta inviato all'avvio dell'attività, mentre il campo response è il corpo della risposta restituito al completamento dell'attività. I campi sono descritti di seguito.

  • id, l'ID dell'attività di generazione, utilizzato per identificare univocamente questa attività di generazione.
  • request, le informazioni sulla richiesta nell'attività.
  • response, le informazioni sulla risposta nell'attività.
  • created_at, l'ora di creazione dell'attività, timestamp Unix (secondi, numero decimale).
  • started_at, l'ora di inizio dell'esecuzione dell'attività, timestamp Unix (secondi, numero decimale).
  • finished_at, l'ora di completamento dell'attività, timestamp Unix (secondi, numero decimale). Questo campo non viene restituito se l'attività non è completata.
  • elapsed, il tempo di esecuzione dell'attività, in secondi (numero decimale, arrotondato a 3 cifre decimali). Questo campo non viene restituito se l'attività non è completata.

Operazione di consultazione in batch

Questa operazione consente di consultare i dettagli di più attività tramite i loro ID; a differenza dell'operazione precedente, è necessario selezionare retrieve_batch come action.

Corpo della richiesta include:

  • ids: l'array degli ID delle attività inviati.
  • action: l'operazione da eseguire sulle attività.

Impostare come mostrato nella figura seguente:

Esempio di codice

Si può notare che sul lato destro della pagina sono già stati generati automaticamente esempi di codice in vari linguaggi, come mostrato nella figura:

Alcuni esempi di codice sono riportati di seguito:

Esempio di risposta

Dopo che la richiesta è stata completata correttamente, l'API restituirà le informazioni dettagliate di tutte le attività del batch. Ad esempio:

  "items": [
    {
      "_id": "69541b81ff2676299ccc3b29",
      "id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
      "api_id": "01d96900-9f8c-41d7-814c-95c7a885ba61",
      "application_id": "920ba772-867a-48ae-8efa-9b9f94136199",
      "created_at": 1767119745.524,
      "started_at": 1767119745.584,
      "finished_at": 1767119785.589,
      "elapsed": 40.005,
      "credential_id": "eeae817d-d6ff-493e-8f88-6c62391da7c6",
      "request": {
        "action": "generate",
        "model": "FUZZ-2.0 Pro",
        "instrumental": false,
        "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
        "custom": true,
        "callback_url": "https://webhook.site/0d73431d-f833-4be4-9276-b6e1690d55c1"
      },
      "trace_id": "1da03537-4eb8-410d-b849-43f03085a3bb",
      "type": "audios",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "task_id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
        "data": [
          {
            "id": "1dd08826-478e-43a6-868f-aff5ababac2c",
            "title": "Woke up with the sun in my eyes",
            "image_url": "https://cdn.acedata.cloud/e724d7f13d.png",
            "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
            "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3",
            "video_url": null,
            "image_id": "1dd08826-478e-43a6-868f-aff5ababac2c",
            "topic": null,
            "seed": "1490770667",
            "sound": "",
            "created_at": "2025-12-30T18:36:00.994141Z",
            "model": "FUZZ-2.0 Pro",
            "progress": "100%",
            "state": "succeeded",
            "duration": "135.2330158730159"
          }
        ]
      }
    }, {
      "_id": "69541b81ff2676299ccc3b29",
      "id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
      "api_id": "01d96900-9f8c-41d7-814c-95c7a885ba61",
      "application_id": "920ba772-867a-48ae-8efa-9b9f94136199",
      "created_at": 1767119745.524,
      "started_at": 1767119745.584,
      "finished_at": 1767119785.589,
      "elapsed": 40.005,
      "credential_id": "eeae817d-d6ff-493e-8f88-6c62391da7c6",
      "request": {
        "action": "generate",
        "model": "FUZZ-2.0 Pro",
        "instrumental": false,
        "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
        "custom": true,
        "callback_url": "https://webhook.site/0d73431d-f833-4be4-9276-b6e1690d55c1"
      },
      "trace_id": "1da03537-4eb8-410d-b849-43f03085a3bb",
      "type": "audios",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response":
{
        "task_id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad",
        "data": [
          {
            "id": "1dd08826-478e-43a6-868f-aff5ababac2c",
            "title": "Woke up with the sun in my eyes",
            "image_url": "https://cdn.acedata.cloud/e724d7f13d.png",
            "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
            "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3",
            "video_url": null,
            "image_id": "1dd08826-478e-43a6-868f-aff5ababac2c",
            "topic": null,
            "seed": "1490770667",
            "sound": "",
            "created_at": "2025-12-30T18:36:00.994141Z",
            "model": "FUZZ-2.0 Pro",
            "progress": "100%",
            "state": "succeeded",
            "duration": "135.2330158730159"
          }
        ]
      }
    }
  ],
  "count": 2
}

Il risultato restituito contiene diversi campi, tra cui items, che contiene le informazioni dettagliate sui task del batch. Le informazioni specifiche di ciascun task corrispondono ai campi descritti sopra. I campi sono i seguenti.

  • items, tutte le informazioni dettagliate sui task del batch. È un array, e ogni suo elemento ha lo stesso formato del risultato restituito dalla query di un singolo task descritta sopra.
  • count, il numero di task interrogati in batch.

CURL

curl -X POST 'https://api.01ai.cloud/producer/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad","1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad"],
  "action": "retrieve_batch"
}'

Gestione degli errori

Quando si chiama l'API, se si verifica un errore, l'API restituisce il codice e il messaggio di errore corrispondenti. Ad esempio:

  • 400 token_mismatched: Richiesta non valida, probabilmente a causa di parametri mancanti o non validi.
  • 400 api_not_implemented: Richiesta non valida, probabilmente a causa di parametri mancanti o non validi.
  • 401 invalid_token: Non autorizzato, token di autorizzazione non valido o mancante.
  • 429 too_many_requests: Troppe richieste, hai superato il limite di frequenza.
  • 500 api_error: Errore interno del server, si è verificato un problema sul server.

Esempio di risposta di errore

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Conclusione

Attraverso questa documentazione, hai appreso come utilizzare la Producer Tasks API per interrogare tutte le informazioni dettagliate di un singolo task o di un batch di task. Ci auguriamo che questa documentazione possa aiutarti a integrare e utilizzare meglio l'API. Per qualsiasi domanda, non esitare a contattare il nostro team di supporto tecnico.