Fish Tasks API Integration and Usage

The main function of the Fish Tasks API is to query the execution status of a task by entering the task ID generated by the Fish Audios Generation API.

This document provides detailed integration instructions for the Fish Tasks API, helping you easily integrate and take full advantage of its powerful features. With the Fish Tasks API, you can easily query the execution status of Fish Audios Generation API tasks.

Application Process

To use the Fish Audios Generation API, first go to the Ace Data Cloud Console to obtain your API Token for later use.

If you have not logged in or registered, you will be automatically redirected to the login page to register and log in. Once completed, you will automatically return to the current page.

The API Key for a general application can be used for services enabled for the account; the Key for a dedicated application can be used within that application's service scope. Please check the Key's permissions, validity period, and limits, and confirm that the application balance is sufficient to pay for this request. Available trial credits are subject to the amount shown in your account. If the balance is insufficient, click the "Recharge" button.

📘 Full documentation: Fish Audios Generation API →

Request Example

The Fish Tasks API can be used to query the results of the Fish Audios Generation API. For information on how to use the Fish Audios Generation API, please refer to the documentation Fish Videos Generation API .

We will use a task ID returned by the Fish Audios Generation API service as an example to demonstrate how to use this API. Suppose we have a task ID: 2725a2d3-f87e-4905-9c53-9988d5a7b2f5. Next, we will demonstrate how to do so by passing in a task ID.

Example Task Image

Set the Request Headers and Request Body

Request Headers include:

  • accept: Specifies that the response should be received in JSON format. Enter application/json here.
  • authorization: The key used to call the API. After applying for it, you can select it directly from the drop-down list.

Request Body includes:

  • id: The submitted task ID.
  • action: The operation to perform on the task.

Set them as shown below:

Code Examples

You can see that code in various languages has already been automatically generated on the right side of the page, as shown below:

Some code examples are as follows:

CURL

curl -X POST 'https://api.acedata.cloud/fish/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
  "action": "retrieve"
}'

Response Example

After a successful request, the API will return the details of this task. For example:

{
  "_id": "68cfad98550a4144a5476a92",
  "id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
  "api_id": "8e6f8083-4683-45fe-a993-3e1d993fc999",
  "application_id": "3559d836-2505-46be-96ea-ea72bcb7c080",
  "created_at": 1758440856.34,
  "started_at": 1758440856.4,
  "finished_at": 1758440869.2,
  "elapsed": 12.8,
  "credential_id": "881ad87d-8ba7-40b7-ac45-d19e41ae6e3a",
  "request": {
    "action": "speech",
    "prompt": "a white siamese cat",
    "model": "fish-tts",
    "voice_id": "d7900c21663f485ab63ebdb7e5905036",
    "callback_url": "https://webhook.site/4815f79f-a40f-4078-ac85-1cc126b6bb34"
  },
  "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
  "type": "audios",
  "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
  "response": {
    "success": true,
    "task_id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
    "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
    "data": [
      {
        "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3"
      }
    ]
  }
}

The returned result contains multiple fields. The request field is the request body used to initiate the task, while the response field is the response body returned after the task is completed. The fields are described below.

  • id: The ID generated for this task, used to uniquely identify this generation task.
  • request: The request information in the queried task.
  • response: The response information in the queried task; upon final success, its cost.amount is the Credits actually deducted for that synthesis.
  • created_at: The task creation time, as a Unix timestamp (seconds, floating-point).
  • started_at: The time the task started executing, as a Unix timestamp (seconds, floating-point).
  • finished_at: The time the task was completed, as a Unix timestamp (seconds, floating-point). This field is not returned if the task is incomplete.
  • elapsed: The task execution time in seconds (floating-point, rounded to 3 decimal places). This field is not returned if the task is incomplete.

Batch Query Operation

This is used to query task details for multiple task IDs. Unlike the above, you need to select retrieve_batch for action.

Request Body includes:

  • ids: An array of submitted task IDs.
  • action: The operation to perform on the tasks.

Set them as shown below:

Code Examples

You can see that code in various languages has already been automatically generated on the right side of the page, as shown below:

Some code examples are as follows:

Response Example

After a successful request, the API will return the specific details of all tasks in this batch. For example:

{
  "items": [
    {
      "_id": "68cfad98550a4144a5476a92",
      "id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
      "api_id": "8e6f8083-4683-45fe-a993-3e1d993fc999",
      "application_id": "3559d836-2505-46be-96ea-ea72bcb7c080",
      "created_at": 1758440856.34,
      "started_at": 1758440856.4,
      "finished_at": 1758440869.2,
      "elapsed": 12.8,
      "credential_id": "881ad87d-8ba7-40b7-ac45-d19e41ae6e3a",
      "request": {
        "action": "speech",
        "prompt": "a white siamese cat",
        "model": "fish-tts",
        "voice_id": "d7900c21663f485ab63ebdb7e5905036",
        "callback_url": "https://webhook.site/4815f79f-a40f-4078-ac85-1cc126b6bb34"
      },
      "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
      "type": "audios",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
        "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
        "data": [
          {
            "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3"
          }
        ]
      }
    },
    {
      "_id": "68cfad98550a4144a5476a92",
      "id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
      "api_id": "8e6f8083-4683-45fe-a993-3e1d993fc999",
      "application_id": "3559d836-2505-46be-96ea-ea72bcb7c080",
      "created_at": 1758440856.34,
      "started_at": 1758440856.4,
      "finished_at": 1758440869.2,
      "elapsed": 12.8,
      "credential_id": "881ad87d-8ba7-40b7-ac45-d19e41ae6e3a",
      "request": {
        "action": "speech",
        "prompt": "a white siamese cat",
        "model": "fish-tts",
        "voice_id": "d7900c21663f485ab63ebdb7e5905036",
        "callback_url": "https://webhook.site/4815f79f-a40f-4078-ac85-1cc126b6bb34"
      },
      "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
      "type": "audios",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "2725a2d3-f87e-4905-9c53-9988d5a7b2f5",
        "trace_id": "e2d308bc-4df8-4c69-9369-a60f3c54f2b3",
        "data": [
          {
            "audio_url": "https://cdn.acedata.cloud/assets/examples/fish/5ade0339-5f11-487e-aacc-06a908271706-8e3fcb0e5547.mp3"
          }
        ]
      }
    }
  ],
  "count": 2
}

The response contains several fields, among which items contains the details of the batch tasks. The details of each task have the same fields as above, and the field information is as follows.

  • items, all the details of the batch tasks. It is an array, and each element in the array has the same format as the response for querying a single task above.
  • count, the number of tasks queried in this batch.

CURL

curl -X POST 'https://api.acedata.cloud/fish/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["2725a2d3-f87e-4905-9c53-9988d5a7b2f5","2725a2d3-f87e-4905-9c53-9988d5a7b2f5"],
  "action": "retrieve_batch"
}'

Error Handling

When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:

  • 400 token_mismatched: Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token: Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests: Too many requests, you have exceeded the rate limit.
  • 500 api_error: Internal server error, something went wrong on the server.

Error Response Example

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

Conclusion

Through this document, you have learned how to use the Fish Tasks API to query all the details of a single task or a batch of tasks. We hope this document helps you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.