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

# Integrazione e utilizzo dell'API Producer Tasks

> Producer Music Generation 集成指南 - XHuoAPI

La principale funzionalità dell'API Producer Tasks è quella di consentire la consultazione dello stato di esecuzione di un'attività tramite l'ID attività generato dall'API Producer Audios Generation.

Questo documento fornirà una descrizione dettagliata dell'integrazione dell'API Producer Tasks, aiutandoti a integrare facilmente e sfruttare appieno le potenti funzionalità di questa API. Con l'API Producer Tasks, puoi facilmente consultare lo stato di esecuzione delle attività dell'API Producer Audios Generation.

## Processo di richiesta

Per utilizzare l'API Producer Tasks, è necessario prima visitare la pagina di richiesta [Producer Audios Generation API](https://api.xhuoapi.ai/documents/producer-audios) per richiedere il servizio corrispondente, quindi copiare l'ID attività dell'API Producer Audios Generation, come mostrato nell'immagine:

<p>
  <img src="https://cdn.xhuoapi.ai/om6p6g.png" width="500" className="m-auto" />
</p>

Infine, accedi alla pagina dell'API Tasks [Producer Tasks API](https://api.xhuoapi.ai/documents/622626b1-30a7-4799-a772-4946e1df3ac0) per richiedere il servizio corrispondente. Una volta entrato nella pagina, fai clic sul pulsante "Acquire", come mostrato nell'immagine:

![Pagina di richiesta](https://cdn.xhuoapi.ai/rci31i.png)

Se non hai ancora effettuato il login o la registrazione, verrai automaticamente reindirizzato alla [pagina di login](https://api.xhuoapi.ai) che ti invita a registrarti e accedere. Dopo aver effettuato il login o la registrazione, verrai automaticamente riportato alla pagina corrente.

Alla prima richiesta, verrà offerto un credito gratuito, che ti consente di utilizzare gratuitamente questa API.

## Esempio di richiesta

L'API Producer Tasks può essere utilizzata per consultare i risultati dell'API Producer Audios Generation. Per informazioni su come utilizzare l'API Producer Audios Generation, fare riferimento al documento [Producer Audios Generation API](https://api.xhuoapi.ai/documents/producer-audios-integration).

Prendiamo come esempio un ID attività restituito dal servizio Producer Audios Generation API, per dimostrare come utilizzare questa API. Supponiamo di avere un ID attività: 1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad, e ora dimostriamo come passare un ID attività.

### Esempio di attività

<p>
  <img src="https://cdn.xhuoapi.ai/om6p6g.png" width="500" className="m-auto" />
</p>

### Impostazione dell'intestazione della richiesta e del corpo della richiesta

**Request Headers** includono:

* `accept`: specifica di ricevere la risposta in formato JSON, qui inserito come `application/json`.
* `authorization`: la chiave per chiamare l'API, che può essere selezionata direttamente dopo la richiesta.

**Request Body** include:

* `id`: l'ID dell'attività caricata.
* `action`: il modo di operare sull'attività.

Impostato come mostrato nell'immagine:

<p>
  <img src="https://cdn.xhuoapi.ai/bfe4ww.png" width="500" className="m-auto" />
</p>

### Esempio di codice

Si può notare che sul lato destro della pagina sono già stati generati automaticamente vari codici in diverse lingue, come mostrato nell'immagine:

<p>
  <img src="https://cdn.xhuoapi.ai/u4pb2f.png" width="500" className="m-auto" />
</p>

Alcuni esempi di codice sono i seguenti:

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/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à le informazioni dettagliate su questa attività. Ad esempio:

```json theme={null}
{
  "_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,
  "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://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/image/1dd08826-478e-43a6-868f-aff5ababac2c.jpg",
        "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://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/audio/1dd08826-478e-43a6-868f-aff5ababac2c.m4a",
        "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"
      }
    ]
  },
  "duration": 40.06500005722046,
  "finished_at": 1767119785.589
}
```

Il risultato della richiesta contiene diversi campi, il campo request è il corpo della richiesta al momento dell'avvio del compito, mentre il campo response è il corpo della risposta restituito al termine del compito. Di seguito la descrizione dei campi.

* `id`, l'ID del compito generato, utilizzato per identificare univocamente questo compito di generazione.
* `request`, informazioni sulla richiesta nel compito di query.
* `response`, informazioni sulla risposta nel compito di query.

## Operazione di query in batch

Questa è per interrogare i dettagli di più ID di compiti, a differenza di quanto sopra, è necessario selezionare l'azione come retrieve\_batch.

**Corpo della richiesta** include:

* `ids`: array degli ID dei compiti caricati.
* `action`: modalità di operazione sui compiti.

Impostare come mostrato nell'immagine sottostante:

<p>
  <img src="https://cdn.xhuoapi.ai/jlkoma.png" width="500" className="m-auto" />
</p>

### Esempio di codice

Si può notare che sul lato destro della pagina sono già stati generati automaticamente vari codici in diverse lingue, come mostrato nell'immagine:

<p>
  <img src="https://cdn.xhuoapi.ai/emw66n.png" width="500" className="m-auto" />
</p>

Di seguito alcuni esempi di codice:

### Esempio di risposta

Dopo una richiesta riuscita, l'API restituirà i dettagli specifici di tutti i compiti in batch. Ad esempio:

```json theme={null}
{
  "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,
      "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://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/image/1dd08826-478e-43a6-868f-aff5ababac2c.jpg",
            "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://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/audio/1dd08826-478e-43a6-868f-aff5ababac2c.m4a",
            "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"
          }
        ]
      },
      "duration": 40.06500005722046,
      "finished_at": 1767119785.589
    }, {
      "_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,
      "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": "Mi sono svegliato con il sole negli occhi",
            "image_url": "https://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/image/1dd08826-478e-43a6-868f-aff5ababac2c.jpg",
            "lyric": "[Verso]\nMi sono svegliato con il sole negli occhi\nNessuna nuvola sopra, solo blu nel cielo\nScarpe ai piedi, sono pronto a correre\nOgni passo sembra una pistola carica\n[ ritornello]\nGiorni felici stanno arrivando\nLascia che la gioia sotto la mia pelle\nNiente più ombre, niente più bugie\nSolo la verità che mi solleva in alto\n[Verso 2]\nBallando per le strade della città\nUn ritmo che batte nel mio cuore\nGli sconosciuti sorridono, si sta diffondendo\nQuesto mondo è un palcoscenico, siamo tutti una canzone\n[ ritornello]\nGiorni felici stanno arrivando\nLascia che la gioia sotto la mia pelle\nNiente più ombre, niente più bugie\nSolo la verità che mi solleva in alto\n[Ponte]\nButta via le tue preoccupazioni\nLascia che affondino sul fondo dell'oceano\nSiamo vivi ed è abbastanza\nLa vita è disordinata ma è amore\n[ ritornello]\nGiorni felici stanno arrivando\nLascia che la gioia sotto la mia pelle\nNiente più ombre, niente più bugie\nSolo la verità che mi solleva in alto",
            "audio_url": "https://storage.googleapis.com/corpusant-app-public/riffs/3bff6223-fe13-4bef-973e-2cbaef430d5d/audio/1dd08826-478e-43a6-868f-aff5ababac2c.m4a",
            "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"
          }
        ]
      },
      "duration": 40.06500005722046,
      "finished_at": 1767119785.589
    }
  ],
  "count": 2
}
```

I risultati restituiti contengono diversi campi, dove `items` include i dettagli specifici del compito batch, ogni informazione specifica del compito è simile ai campi del risultato della query di un singolo compito sopra. I campi sono i seguenti.

* `items`, tutti i dettagli specifici del compito batch. È un array, ogni elemento dell'array ha lo stesso formato del risultato della query di un singolo compito sopra.
* `count`, il numero di compiti in questa query batch.

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/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 restituirà il codice di errore e le informazioni 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, qualcosa è andato storto sul server.

### Esempio di risposta di errore

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

## Conclusione

Attraverso questo documento, hai compreso come utilizzare l'API Producer Tasks per interrogare i dettagli specifici di un singolo o di più compiti. Speriamo che questo documento ti aiuti a integrare e utilizzare meglio questa API. Se hai domande, non esitare a contattare il nostro team di supporto tecnico.
