Flux Videos API Integration Guide

The Flux Videos API uses POST /flux/videos for video generation, keyframe-based image-to-video generation, video continuation, and draft enhancement. action=generate is the default, and mode selects the generation mode; use the existing POST /flux/tasks to query all results.

Currently in Beta. Text-to-video, image-to-video, video continuation, and draft enhancement are available. HTTP 200 and a task ID only indicate that the task has been accepted; you must continue querying for the final result.

1. Get an API Token

  1. After logging in to the Ace Data Cloud console, open General Application and click the copy button to the right of API KEY. Make sure the application has permission to call the Flux service and has sufficient balance.
  2. Check the plans and prices for each operation on the Flux service page. If your balance is insufficient, click the “Recharge” button.
  3. Requests use Authorization: Bearer <your Token>. The token should be stored in a server-side environment variable, not in frontend pages, public repositories, screenshots, or callback URLs.

Apply for an API Token in the console

The code in this guide consistently reads an environment variable:

export ACEDATACLOUD_API_TOKEN='替换为你自己的 API Token'
Item Value
API base URL https://api.acedata.cloud
Submit video task POST /flux/videos
Query existing task POST /flux/tasks
Authentication Authorization: Bearer $ACEDATACLOUD_API_TOKEN
Request format Content-Type: application/json

For complete fields and online testing, see Flux Videos API; for task queries, see Flux Tasks API.

2. Select an Operation and Input

action mode Input Result
generate (default when action is omitted) t2v prompt Generate a video from text
generate i2v prompt, keyframes Generate a video from one or more keyframes
generate v2v prompt, start_video Continue from an input video
generate draft_enhance draft_task_id of your own completed draft Enhance that draft

The generation model is flux-3, and action is generate (default). Use mode to select text-to-video, image-to-video, video continuation, or draft enhancement.

General Generation Parameters

Parameter Description
mode Required; t2v, i2v, v2v, or draft_enhance
prompt Required for standard generation; draft enhancement does not allow the original prompt to be overridden
duration An integer from 5–20 seconds for t2v/i2v, an integer from 5–15 seconds for v2v, or auto; the final output duration may differ slightly from the requested value
resolution hd, fhd, qhd, uhd; defaults to hd for standard generation and fhd for draft enhancement
aspect_ratio auto, 21:9, 2:1, 16:9, 4:3, 1:1, 3:4, 9:16, 9:21
draft Whether to generate a draft first; drafts only support hd
generate_audio Whether to generate synchronized audio; false is a valid value, so retain explicit Boolean values
safety_tolerance Optional; an integer from 0–4
async Recommended to set to true to return the platform task ID immediately, then poll for the result
callback_url Optional; an HTTP(S) address that receives the final JSON result; setting it also causes the task to be accepted asynchronously

Asset URLs must be accessible to the service. If using temporary signed URLs, allow sufficient validity time for downloading and processing. Do not use webpage URLs as image or video file URLs.

3. Text-to-Video: Complete Tested Request and Result

The following request was successfully executed against the production API before the price adjustment on 2026-10-02. Omitting action verified the default generation behavior; async=true avoids a long wait on the HTTP connection.

curl -X POST 'https://api.acedata.cloud/flux/videos' \
  -H "Authorization: Bearer $ACEDATACLOUD_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "flux-3",
    "mode": "t2v",
    "prompt": "A small toy sailboat floating on calm blue water in warm morning light, steady camera, no text.",
    "duration": 5,
    "resolution": "hd",
    "draft": true,
    "async": true
  }'

Acceptance response (real task ID):

{
  "task_id": "4341eb66-3845-4972-bb86-712a6cfae845",
  "trace_id": "b0f851bd-0925-43ca-acc3-6f634c70d607"
}

Save the task_id from your own response and continue querying; do not use the task ID in the documentation example to query another account’s results.

curl -X POST 'https://api.acedata.cloud/flux/tasks' \
  -H "Authorization: Bearer $ACEDATACLOUD_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"action":"retrieve","id":"替换为本次返回的 task_id"}'

The response field returned by the task query contains the final business result. Below is the successful response from this test, with the outer task metadata omitted. The video URL in the documentation has been replaced with a copy of the same file on a long-term example CDN (matching SHA-256); actual calls return the result URL for that task:

{
  "success": true,
  "task_id": "4341eb66-3845-4972-bb86-712a6cfae845",
  "trace_id": "b0f851bd-0925-43ca-acc3-6f634c70d607",
  "data": [
    {
      "id": "4341eb66-3845-4972-bb86-712a6cfae845",
      "model": "flux-3",
      "video_url": "https://cdn.acedata.cloud/assets/examples/flux/4341eb66-3845-4972-bb86-712a6cfae845-5f4391e1942c.mp4",
      "seconds": 5.041667,
      "width": 1280,
      "height": 704,
      "fps": 24,
      "draft_task_id": "4341eb66-3845-4972-bb86-712a6cfae845"
    }
  ],
  "usage": {
    "action": "generate",
    "seconds": 5.041667,
    "output_mp_seconds": 4.3326825781250005,
    "mode": "t2v",
    "resolution": "hd",
    "draft": true
  },
  "cost": {
    "amount": 2.6884689277500002,
    "currency": "credit",
    "list_amount": 2.9871876975000005
  }
}

View the video from this test. A media inspection confirmed that the output is a 1280×704, 24 fps, 5.041667-second MP4 with a file size of 2,607,276 bytes.

Response field Purpose
success Whether the final task succeeded; receiving a task_id at the acceptance stage does not mean success=true
task_id Platform task ID, used for polling and business-level idempotency
trace_id Provided to support staff when troubleshooting
data[].video_url URL of the accessible video result
data[].seconds/width/height/fps Actual output duration, dimensions, and frame rate measured by the server
data[].draft_task_id Input ID for draft enhancement; appears only when a reusable draft is returned
usage Final billable usage; do not overwrite actual seconds with the request duration
cost.amount Credits ultimately charged for this task; currency=credit is not USD
cost.list_amount Credits before the user's consumption discount is applied; returned when applicable

This is a historical test conducted before the price adjustment: list_amount=2.9871876975 Credits, and the account had a 10% consumption discount at the time, resulting in an actual amount=2.68846892775 Credits. The new price as of 2026-10-02 has been reduced by approximately 6.33%; the same 5.041667-second draft costs 2.798125185 Credits at the current price (before consumption discounts), or 2.5183126665 Credits if a 10% consumption discount still applies. Historical task charges are not recalculated. Plans and discounts may differ for other accounts; this is not a fixed USD price for all users.

4. Image-to-video: ordinary and timed keyframes

The following are parameter examples; the asset URLs must be replaced, and they are not statements that these examples have already run successfully. After generation is complete, query the result using the process above; the result structure is the same.

Use an ordinary array for one or two images:

{
  "action": "generate",
  "model": "flux-3",
  "mode": "i2v",
  "prompt": "The camera slowly moves around the product in soft studio light.",
  "keyframes": ["https://example.com/first-frame.jpg"],
  "duration": 5,
  "resolution": "hd",
  "generate_audio": false,
  "async": true
}

When specifying keyframe times, use [seconds, image URL] pairs:

{
  "action": "generate",
  "model": "flux-3",
  "mode": "i2v",
  "prompt": "A smooth transition from morning light to a warm sunset.",
  "keyframes": [[0, "https://example.com/start.jpg"], [5, "https://example.com/end.jpg"]],
  "duration": 5,
  "resolution": "hd",
  "async": true
}

Between 1 and 10 keyframes are allowed. Timed arrays must be in ascending time order, with times from 0 to 20 seconds; ordinary URLs and timed entries cannot be mixed. Three or more ordinary keyframes require an explicitly specified duration; auto cannot be used.

Image-to-video test output

The matching input for this test is as follows (only the complete base64 is replaced with explanatory text; all other fields are from the actual request):

{
  "async": true,
  "action": "generate",
  "model": "flux-3",
  "prompt": "The toy sailboat drifts slowly across calm water. A steady camera, gentle daylight, no people or text.",
  "duration": 5,
  "resolution": "hd",
  "generate_audio": false,
  "draft": false,
  "mode": "i2v",
  "keyframes": [
    "<下图 PNG 文件的原始 base64 字符串>"
  ]
}

Reference keyframe for this image-to-video test

After downloading the PNG keyframe, you can use Python's base64.b64encode(image_bytes).decode("ascii") to obtain the raw string and place it in the keyframes array. Do not use the explanatory text in the documentation as image input.

The following is the actual final response from a production task on 2026-10-01 (not a simulated response); only the video URL has been replaced with a long-term example copy with the same hash. The test input used the raw base64 string of a 1280×720 PNG as a single keyframe; the URL inputs above are separate parameter examples.

{
  "success": true,
  "task_id": "b1106de8-d586-4e23-b489-381e2f86a10f",
  "trace_id": "f62d5c56-cfb2-4f8f-b339-ef019d4c0d10",
  "data": [
    {
      "id": "b1106de8-d586-4e23-b489-381e2f86a10f",
      "model": "flux-3",
      "video_url": "https://cdn.acedata.cloud/assets/examples/flux/b1106de8-d586-4e23-b489-381e2f86a10f-bef14458cc9d.mp4",
      "seconds": 5.041667,
      "width": 1280,
      "height": 704,
      "fps": 24
    }
  ],
  "usage": {
    "action": "generate",
    "seconds": 5.041667,
    "output_mp_seconds": 4.3326825781250005,
    "mode": "i2v",
    "resolution": "hd",
    "draft": false
  },
  "cost": {
    "amount": 7.617328628625,
    "currency": "credit",
    "list_amount": 8.46369847625
  }
}

View the tested video.

5. Video Continuation

Pass the URL of an existing video file to start_video, with mode=v2v; the maximum duration is 15 seconds.

{
  "action": "generate",
  "model": "flux-3",
  "mode": "v2v",
  "prompt": "Continue the sailboat drifting forward with the same steady camera.",
  "start_video": "https://example.com/source.mp4",
  "duration": 5,
  "resolution": "hd",
  "async": true
}

Video Continuation Test Output

The complete test input is shown below; replace the draft ID with your own when reproducing draft enhancement. The asset URL uses a long-term example copy of the same file:

{
  "action": "generate",
  "model": "flux-3",
  "mode": "v2v",
  "start_video": "https://cdn.acedata.cloud/assets/examples/flux/b41293be-94c0-4dc7-9f39-ce04f0a8798d-c055a3079059.mp4",
  "prompt": "Continue the same sailboat drifting gently across calm water in the same continuous steady shot.",
  "duration": 5,
  "resolution": "hd",
  "generate_audio": false,
  "async": true
}

The following is the actual final response from the 2026-10-01 production task (not a simulated response); only the video URL has been replaced with a long-term example copy with the same hash.

{
  "success": true,
  "task_id": "8af9aa42-7e4d-47a4-bd61-144d97440c91",
  "trace_id": "4fb49afc-abca-4039-bbaa-adb66e293544",
  "data": [
    {
      "id": "8af9aa42-7e4d-47a4-bd61-144d97440c91",
      "model": "flux-3",
      "video_url": "https://cdn.acedata.cloud/assets/examples/flux/8af9aa42-7e4d-47a4-bd61-144d97440c91-a512d6574811.mp4",
      "seconds": 5,
      "width": 1280,
      "height": 704,
      "fps": 24
    }
  ],
  "usage": {
    "action": "generate",
    "seconds": 5,
    "output_mp_seconds": 4.296875,
    "mode": "v2v",
    "resolution": "hd",
    "draft": false
  },
  "cost": {
    "amount": 18.219375,
    "currency": "credit",
    "list_amount": 20.24375
  }
}

View the tested video.

The tested start_video input was the completed draft video, and the remaining parameters were duration=5, resolution=hd, generate_audio=false.

6. Draft First, Then Enhance

  1. Generate a draft with draft=true and resolution=hd and wait for it to succeed.
  2. Retrieve the platform draft ID from the final data[0].draft_task_id.
  3. Submit an enhancement request using application credentials under the same ownership:
{
  "action": "generate",
  "model": "flux-3",
  "mode": "draft_enhance",
  "draft_task_id": "替换为自己的已完成草稿 ID",
  "resolution": "fhd",
  "async": true
}

Draft enhancement cannot accept prompt, duration, aspect_ratio, version, generate_audio, draft, keyframes, or start_video to override the original content. The draft cache is a temporary resource, so please enhance it promptly; permanent storage or a fixed retention period is not guaranteed. Drafts belonging to another user or application, unfinished drafts, and expired caches cannot be reused. Draft generation and enhancement are two separate tasks, each billed separately upon success.

Draft Enhancement Test Output

The complete test input is shown below; replace the draft ID with your own when reproducing draft enhancement. The asset URL uses a long-term example copy of the same file:

{
  "action": "generate",
  "model": "flux-3",
  "mode": "draft_enhance",
  "draft_task_id": "b41293be-94c0-4dc7-9f39-ce04f0a8798d",
  "resolution": "hd",
  "async": true
}

The following is the actual final response from the 2026-10-01 production task (not a simulated response); only the video URL has been replaced with a long-term example copy with the same hash.

{
  "success": true,
  "task_id": "1db6243b-4a05-4484-828c-25bb17de7108",
  "trace_id": "64f93fa1-8d18-4c8b-a6d2-888009eb7cfa",
  "data": [
    {
      "id": "1db6243b-4a05-4484-828c-25bb17de7108",
      "model": "flux-3",
      "video_url": "https://cdn.acedata.cloud/assets/examples/flux/1db6243b-4a05-4484-828c-25bb17de7108-058d92166607.mp4",
      "seconds": 5.041667,
      "width": 1280,
      "height": 704,
      "fps": 24
    }
  ],
  "usage": {
    "action": "generate",
    "seconds": 5.041667,
    "output_mp_seconds": 4.3326825781250005,
    "mode": "t2v",
    "resolution": "hd",
    "draft": false
  },
  "cost": {
    "amount": 7.617328628625,
    "currency": "credit",
    "list_amount": 8.46369847625
  }
}

View the tested video.

The test input used the user's own draft_task_id=b41293be-94c0-4dc7-9f39-ce04f0a8798d and resolution=hd; the final usage.mode=t2v indicates the original draft mode. This task and the original draft are billed separately.

7. End-to-End Python Call

Install requests, set your own token, and run the script below to complete “submit once → poll → output the video URL.” Both queries and network retries should use the original task_id to avoid submitting duplicate paid tasks.

import os
import time
import requests

base_url = "https://api.acedata.cloud"
headers = {
    "Authorization": "Bearer " + os.environ["ACEDATACLOUD_API_TOKEN"],
    "Accept": "application/json",
}
payload = {
    "action": "generate",
    "model": "flux-3",
    "mode": "t2v",
    "prompt": "A small toy sailboat floating on calm blue water in warm morning light.",
    "duration": 5,
    "resolution": "hd",
    "draft": True,
    "async": True,
}
submitted = requests.post(base_url + "/flux/videos", json=payload, headers=headers, timeout=120)
submitted.raise_for_status()
accepted = submitted.json()
if accepted.get("error"):
    raise RuntimeError(accepted["error"])
task_id = accepted["task_id"]
print("Task ID:", task_id)  # 持久化保存,用于恢复轮询

# 30 分钟是本示例的客户端等待上限,不是服务的完成时限承诺。
deadline = time.monotonic() + 30 * 60
while time.monotonic() < deadline:
    polled = requests.post(
        base_url + "/flux/tasks",
        json={"action": "retrieve", "id": task_id},
        headers=headers,
        timeout=30,
    )
    polled.raise_for_status()
    task = polled.json()
    if task.get("error"):
        raise RuntimeError(task["error"])
    result = task.get("response") or task.get("result")
    if isinstance(result, dict) and result.get("success") is True:
        print("Video:", result["data"][0]["video_url"])
        print("Usage:", result.get("usage"))
        print("Cost:", result.get("cost"))
        break
    if isinstance(result, dict) and result.get("error"):
        raise RuntimeError(result["error"])
    time.sleep(10)
else:
    raise TimeoutError("Still processing; resume polling with task_id=" + task_id)

After a network timeout, do not treat an unknown status as a failure and immediately resubmit. If you have obtained a task_id, continue querying that task; record the task_id and trace_id to help with troubleshooting. The polling interface itself does not incur generation charges.

8. Using Callbacks

Add callback_url when submitting. After the task is completed, the final JSON result will be sent to that address via POST. The success structure is consistent with the response described above, while a failure contains an error.

{
  "action": "generate",
  "model": "flux-3",
  "mode": "t2v",
  "prompt": "A small sailboat on calm water.",
  "duration": 5,
  "resolution": "hd",
  "draft": true,
  "callback_url": "https://your-server.example/flux-callback"
}

The callback address should be accessible from the public internet. After receiving a notification, process it idempotently by task_id and return a 2xx response as soon as possible; business processing can be queued. This document does not claim that callbacks have signature authentication: before sensitive operations such as granting business entitlements, use your own Token to query the same task and verify the result. If the callback is not received, you can continue polling; do not generate again.

9. Current Billing and Price Table

Updated 2026-10-02: The unit prices for all tiers of the video API have been reduced by approximately 6.33%; metering, packages, and spending discount rules remain unchanged. The cost in the historical test responses above is the charge at the time the task was completed and does not represent current pricing.

Video generation is billed by actual output seconds. Below are the current Credits unit prices before account spending discounts are applied, consistent with the rules on the Flux pricing page.

Operation/Mode Resolution Credits Unit Price
t2v / i2v draft hd 0.555 / second
v2v draft hd 1.11 / second
t2v / i2v / corresponding draft enhancement hd 1.5725 / second
Same as above fhd 2.6825 / second
Same as above qhd 3.7 / second
Same as above uhd 7.4 / second
v2v / corresponding draft enhancement hd 3.7925 / second
Same as above fhd 4.9025 / second
Same as above qhd 6.0125 / second
Same as above uhd 8.7875 / second

Convert to USD: actual cost (USD) = cost.amount (Credits) × package price / package amount. Top-up tiers and spending discounts affect the actual price; Credits cannot be treated directly as USD. Failed tasks do not incur generation charges; the final amount is based on the completed result and the console call records.

10. Frequently Asked Questions and Troubleshooting

Situation Recommendation
Parameter error (400) Check action=generate, mode, duration, and keyframe format; do not mix fields from different generation modes
Authentication error (401) Check the Bearer Token, application permissions, and whether the credentials are valid
Content moderation rejection (403) Adjust the materials and prompt; do not repeatedly resubmit them unchanged
Rate limiting (429) Reduce concurrency and retry with backoff
service_unavailable (503) The current operation is unavailable; an accepted asynchronous task may report this error in the final response
task_id returned but no video yet Continue querying the response; do not treat HTTP 200 as generation completion
Draft cannot be reused Confirm the owner/current application, that the task is complete, and that the original request had draft=true, and check whether the temporary cache is still valid

When providing feedback, include the task_id, trace_id, request time, and sanitized parameters; do not send the API Token. For more methods, see the Flux MCP integration guide.