Gemini Tasks API Integration and Usage

The main function of the Gemini Tasks API is to query the execution status of a task by providing a task ID generated by the Gemini Videos Generation API.

This document provides detailed integration instructions for the Gemini Tasks API, helping you easily integrate it and query the execution status of Gemini Videos Generation API tasks.

Application Process

To use the Gemini Videos 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 be automatically returned to the current page.

A general application's API Key can be used for services enabled for the account; a dedicated application's Key can be used within the scope of that application's services. 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 what is displayed in the account. If the balance is insufficient, click the "Recharge" button.

📘 Full documentation: Gemini Videos Generation API →

Request Example

The Gemini Tasks API can be used to query the results of the Gemini Videos Generation API.

Set Request Headers and Request Body

Request Headers include:

  • accept: Specifies that the response should be in JSON format. Set it to application/json.
  • 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 ID of the task to query.
  • action: The operation to perform on the task. For a single query, set it to retrieve.

CURL Code Example

curl -X POST 'https://api.acedata.cloud/gemini/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
  "action": "retrieve"
}'

Response Example

After a successful request, the API will return the details of the task. The request field is the request body used to initiate the task, and the response field is the response body returned after the task is completed, for example:

{
  "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
  "started_at": 1769262721.823,
  "finished_at": 1769262730.723,
  "elapsed": 8.9,
  "request": {
    "prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden",
    "model": "omni-flash",
    "aspect_ratio": "16:9"
  },
  "type": "videos",
  "response": {
    "success": true,
    "task_id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
    "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
    "data": [
      {
        "id": "omni-flash:job_01k777hjrbfrgs2060q5zvf2a5",
        "video_url": "https://cdn.acedata.cloud/gemini/example-video.mp4",
        "state": "succeeded"
      }
    ]
  }
}

The fields are described as follows:

  • id: The ID of the generation task, used to uniquely identify this generation task.
  • request: The request information in the queried task.
  • response: The response information in the queried task.
  • created_at: The task creation time, as a Unix timestamp (seconds, floating-point).
  • started_at: The task start time, as a Unix timestamp (seconds, floating-point).
  • finished_at: The task completion time, as a Unix timestamp (seconds, floating-point). This field is not returned when the task is incomplete.
  • elapsed: The task execution time in seconds (floating-point, rounded to 3 decimal places). This field is not returned when the task is incomplete.

Batch Query Operations

To query task details for multiple task IDs, set action to retrieve_batch and pass an array of task IDs through ids:

Request Body includes:

  • ids: An array of task IDs to query.
  • action: The operation to perform on the tasks. For a batch query, set it to retrieve_batch.
curl -X POST 'https://api.acedata.cloud/gemini/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["b8976e18-32dc-4718-9ed8-1ea090fcb6ea"],
  "action": "retrieve_batch"
}'