Gemini Videos Generation API Integration Guide
This article introduces how to integrate the Gemini Videos Generation API, which can generate Google Gemini (omni-flash) videos using a text prompt (and optional reference images).
¶ Application Process
To use the Gemini Videos Generation API, first obtain your API Token from the Ace Data Cloud Console and keep it for later use.

If you have not yet 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.
The API Key for a general application can be used for services enabled for the account; the Key for a dedicated application is 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 what is displayed in the account; if the balance is insufficient, click the "Recharge" button.
📘 Full documentation: Gemini Videos Generation API →
¶ Basic Usage
First, let's look at the basic usage: enter the prompt prompt, model model, and aspect ratio aspect_ratio to generate the corresponding video.
As you can see, we set the Request Headers here, including:
accept: The format in which you want to receive the response; here it is set toapplication/json, meaning JSON format.authorization: The key used to call the API, which can be selected directly from the dropdown after application.
We also set the Request Body, including:
prompt: The text prompt describing the video content to be generated, required.model: The model used to generate the video; currently onlyomni-flashis supported, and the default isomni-flash.aspect_ratio: The aspect ratio of the generated video; options are16:9(landscape) or9:16(portrait), with16:9as the default.resolution: The optional output resolution; options are720por1080p, with720pas the default.image_urls: An optional array of reference image links used to guide video generation; empty entries are ignored. This parameter is required (at least one image) when usingvideo_urlsfor video editing.video_urls: An optional array of reference video links (up to 1), used for video editing / video reference; when provided, at least oneimage_urlsentry must also be provided.callback_url: The asynchronous callback address. When set, the API immediately returns atask_idand POSTs the result to this address when the task is complete.async: Optional. When set totrue, the API immediately returns atask_idwithout requiring acallback_url, and the result can then be obtained by polling the corresponding task query API.
Click the "Try" button to test it, and the result will look similar to the following:
{
"success": true,
"task_id": "9258c45f-bed9-4dde-81c2-a70a710a6904",
"trace_id": "862d6aae-cec0-407f-9524-bc1be2291bcb",
"data": [
{
"id": "dc4b7292-070c-49a8-8183-919bdf8ad59e",
"video_url": "https://cdn.acedata.cloud/assets/examples/gemini/9258c45f-bed9-4dde-81c2-a70a710a6904-418c13e0605f.mp4",
"state": "succeeded",
"aspect_ratio": "16:9",
"prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden"
}
],
"started_at": 1784112953.856,
"finished_at": 1784113021.328,
"elapsed": 67.472,
"cost": {
"amount": 1.932,
"currency": "credit",
"list_amount": 2.1
}
}
The response contains several fields, described as follows:
success: Whether this video generation request was successful.task_id: The ID of this video generation task.trace_id: The trace ID of this request, used for troubleshooting.data: The list of generated video results.id: The unique identifier of the generated video.video_url: The link to the generated video (nullwhenstateispending).state: The status of the video generation task; possible values arepending/succeeded/failed.aspect_ratio: The aspect ratio of the video, consistent with the request parameter.prompt: The prompt used to generate the video.
In a synchronous response, the top level also includes fields such as started_at, finished_at, elapsed (duration, in seconds), and cost (the charge for this request, in Credits).
We only need to use the video_url link in data from the result to obtain the generated video.
The corresponding CURL code is as follows:
curl -X POST 'https://api.acedata.cloud/gemini/videos' \
-H 'authorization: Bearer ${bearer_token}' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
"prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden",
"model": "omni-flash",
"aspect_ratio": "16:9"
}'
The corresponding Python code is as follows:
import requests
url = "https://api.acedata.cloud/gemini/videos"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}",
"content-type": "application/json"
}
payload = {
"prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden",
"model": "omni-flash",
"aspect_ratio": "16:9"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
¶ Image-to-Video
If you want to generate a video based on reference images, you can pass one or more image links in image_urls to guide video generation:
{
"prompt": "The woman slowly turns around and smiles at the camera, gentle breeze",
"model": "omni-flash",
"aspect_ratio": "9:16",
"image_urls": [
"https://cdn.acedata.cloud/assets/examples/nanobanana/e44bfceb-1458-4b4b-9d10-21024678f1a3-5ccb6e83b402.png"
]
}
¶ Video Editing / Reference Video (Video Input, Video Output)
Directly "inputting a video and generating a new video" is supported: pass a reference video link (up to 1) in video_urls and simultaneously provide at least one reference image in image_urls, then use prompt to describe the desired editing effect (changing the style, changing the scene, adding or removing elements, etc.).
Below is a complete real example—changing a video of a sunny beach into a winter scene with heavy snowfall while preserving the layout of the beach, palm trees, and boats. Video editing takes longer (about 6.5 minutes in this example), so it is submitted asynchronously using async: true:
{
"prompt": "Turn this sunny tropical beach into a snowy winter scene with heavy falling snow and overcast sky; keep the same beach, palm trees and boat layout.",
"model": "omni-flash",
"aspect_ratio": "9:16",
"resolution": "720p",
"image_urls": [
"https://cdn.acedata.cloud/99289603bd.png"
],
"video_urls": [
"https://cdn.acedata.cloud/assets/examples/seedance/dd3dc063-3383-4f29-bedc-e771a096758c-044e05281a2a.mp4"
],
"async": true
}
After submission, the API immediately returns a task_id:
{
"task_id": "cd68b4ee-de70-4c94-ac69-997a3fed0284"
}
Then use the task_id as the id to poll the Gemini Tasks API. Once the task is complete, you can obtain the newly generated video (this is the actual response for this example):
{
"success": true,
"task_id": "cd68b4ee-de70-4c94-ac69-997a3fed0284",
"trace_id": "5b22104b-5a6d-4a4f-8063-69acae1dc1c6",
"data": [
{
"id": "e125d316-3d26-4c65-9413-55baf6be46b8",
"video_url": "https://cdn.acedata.cloud/assets/examples/sora/cd68b4ee-de70-4c94-ac69-997a3fed0284-c5603ef983da.mp4",
"state": "succeeded",
"aspect_ratio": "9:16",
"prompt": "Turn this sunny tropical beach into a snowy winter scene with heavy falling snow and overcast sky; keep the same beach, palm trees and boat layout."
}
],
"started_at": 1784084482.914,
"finished_at": 1784084877.09,
"elapsed": 394.176,
"cost": {
"amount": 1.932,
"currency": "credit",
"list_amount": 2.1
}
}
For a higher-resolution result, set resolution to 1080p (leaving the other parameters unchanged).
Tip: The input / output media links in the example are all actual generated results. Links to videos and images generated by the platform have a retention period and will expire, so please download and save them to your own storage promptly after receiving the results.
Note: A maximum of 1 reference video is allowed; and when providing
video_urls, you must provide at least one image inimage_urls, otherwise the following parameter error will be returned:
{
"success": false,
"error": {
"code": "bad_request",
"message": "image_urls (at least one reference image) is required when video_urls is provided."
}
}
¶ Asynchronous Callback
Video generation requires some processing time. If you do not want to keep a connection open while waiting, you can provide a callback_url. The API will then immediately return a task_id and POST the final result to that address once the task is complete:
{
"prompt": "A cinematic shot of a kitten chasing a butterfly in a sunlit garden",
"model": "omni-flash",
"aspect_ratio": "16:9",
"callback_url": "https://your-domain.com/callback/gemini"
}
The result returned immediately is as follows:
{
"task_id": "04a043bd-6b23-4b4e-945c-ce48158c3eee"
}
¶ Querying Task Results
If you use an asynchronous callback or want to query the task status yourself, you can use the Gemini Tasks API (POST https://api.acedata.cloud/gemini/tasks) to query the latest status and result of the task using its task_id. Pass the task_id returned when creating the video as the id in the request body:
{
"id": "04a043bd-6b23-4b4e-945c-ce48158c3eee"
}
The result returned after the task is complete is similar to the following. The structure of response.data is the same as for synchronous generation (while generation is in progress, state is pending and video_url is null):
{
"id": "04a043bd-6b23-4b4e-945c-ce48158c3eee",
"type": "videos",
"request": {
"model": "omni-flash",
"prompt": "A time-lapse of clouds over snow mountains at sunrise",
"aspect_ratio": "16:9",
"async": true
},
"response": {
"success": true,
"task_id": "04a043bd-6b23-4b4e-945c-ce48158c3eee",
"data": [
{
"id": "486ebd5a-6a4b-406c-84ae-33835de4fe19",
"video_url": "https://cdn.acedata.cloud/assets/examples/gemini/04a043bd-6b23-4b4e-945c-ce48158c3eee-3a89912507c7.mp4",
"state": "succeeded",
"aspect_ratio": "16:9",
"prompt": "A time-lapse of clouds over snow mountains at sunrise"
}
],
"elapsed": 96.716,
"cost": {
"amount": 1.932,
"currency": "credit",
"list_amount": 2.1
}
}
}
¶ Error Handling
When a problem occurs with a request, the API returns the corresponding error code and description. Common examples are as follows:
400: The request parameters are incorrect, such as a missingpromptor an invalidaspect_ratiovalue.401: Authentication failed; the token is invalid or does not match the API.403: Insufficient balance, or the prompt was rejected by content moderation.500: A service error occurred or generation failed.
