Grok Tasks API Integration and Usage

The main function of the Grok Tasks API is to query the execution status of tasks by inputting the task ID generated by the Grok Videos Generation API.

This document will provide detailed instructions for integrating the Grok Tasks API, helping you easily query the execution status of tasks from the Grok Videos Generation API.

Application Process

To use the Grok Videos Generation API, first obtain your API Token from the YuJun Console for future use.

If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in, and will return to the current page upon completion.

One API Token can call all services on the platform without needing to apply separately for each service. The first application will grant a free quota for a trial experience; when the quota is insufficient, you can recharge the general balance in the console.

📘 Complete Documentation: Grok Videos Generation API →

Request Example

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

Setting Request Headers and Request Body

Request Headers include:

  • accept: Specifies that the response should be in JSON format, set to application/json.
  • authorization: The key to call the API, which can be selected directly after application.

Request Body includes:

  • id: The task ID to be queried.
  • action: The operation method for the task, set to retrieve for a single query.

CURL Code Example

curl -X POST 'https://api.acedata.cloud/grok/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

Upon a successful request, the API will return the details of the task here. The request field contains the request body when the task was initiated, and the response field contains the response body returned after the task is completed, for example:

{
  "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
  "started_at": 1769262721.823,
  "finished_at": 1769262729.623,
  "elapsed": 7.8,
  "request": {
    "prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden",
    "model": "grok-imagine-video-1.5-fast:reverse",
    "resolution": "480p",
    "duration": 8
  },
  "type": "videos",
  "response": {
    "success": true,
    "task_id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
    "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
    "data": [
      {
        "id": "grok-imagine-video-1.5-fast:reverse:41eb9a5f-3b2d-4d1e-9f5a-6c2f1a0b9e77",
        "video_url": "https://cdn.acedata.cloud/c8cbf53aa0.mp4",
        "state": "succeeded"
      }
    ]
  }
}

Field descriptions are as follows:

  • id: The ID of the generated task, used to uniquely identify this generation task.
  • request: The request information in the queried task.
  • response: The return information in the queried task.
  • created_at: The task creation time, Unix timestamp (seconds, float).
  • started_at: The time the task started execution, Unix timestamp (seconds, float).
  • finished_at: The time the task was completed, Unix timestamp (seconds, float). This field is not returned if the task is not completed.
  • elapsed: The time taken for task execution, in seconds (float, rounded to 3 decimal places). This field is not returned if the task is not completed.

Batch Query Operation

When querying the details of multiple task IDs, set the action to retrieve_batch, and pass the task ID array through ids:

Request Body includes:

  • ids: The array of task IDs to be queried.
  • action: The operation method for the task, set to retrieve_batch for batch queries.
curl -X POST 'https://api.acedata.cloud/grok/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["b8976e18-32dc-4718-9ed8-1ea090fcb6ea"],
  "action": "retrieve_batch"
}'