TokenHot
HomeModelsConsoleDocumentationBlog
✓ English简体中文繁體中文日本語FrançaisРусскийTiếng Việt
TokenHot

One API. A model catalog. Usage-based billing.

Product

  • Models
  • Pricing
  • About
  • Support

Popular Models

  • GPT-5.6
  • Claude Opus 5
  • Claude Fable 5
  • Gemini 3.5 Flash
  • Claude Sonnet 5
  • DeepSeek V4 Pro
  • Kimi K3
  • Seedance 2.5

Model Providers

  • OpenAI
  • Anthropic
  • Google
  • DeepSeek
  • Qwen
  • ByteDance
  • Doubao
  • MiniMax
  • Z.ai (GLM)

Resources

  • Docs
  • Blog
  • hi@tokenhot.ai
  • Terms
  • Privacy
  • Refund Policy
© 2026 NEXORA AI PTE. LTD. · Tokenhot
HomeBlogAPI GuidesHow to Extend a Veo 3.1 Video Through an API
API Guides

How to Extend a Veo 3.1 Video Through an API

TTokenhot Team·October 18, 2026·7 min read
How to Extend a Veo 3.1 Video Through an API

Tokenhot’s documented Veo extension request refers to an existing task, not an arbitrary uploaded MP4. Generate the original video, confirm its successful result, then send its task ID in the extension request’s taskId field. Save the extension’s returned task_id separately: it is the child job you need to query next.

This tutorial follows Tokenhot’s veo3.1 request format. It does not substitute a native Google operation object, promise a fixed number of added seconds, or claim every external video can be extended. The code was checked offline; no initial video or extension was generated for this guide.

Check availability before investing in a new integration. On October 11, 2026, Google’s deprecation table lists October 22, 2026 as the earliest possible shutdown date for named native Veo 3.1 preview models. The read Tokenhot documentation does not establish how its veo3.1 alias maps to those IDs or when its route will stop. Confirm the gateway’s current lifecycle with Tokenhot support; do not treat this dated guide as an indefinite availability promise.

Understand the three identifiers before sending a request

Stage Field Meaning in this workflow
Original generation response task_id Identifier used to query the original job.
Extension request taskId Original job identifier passed into the continuation request.
Extension response task_id Newly returned child job identifier, queried independently.

The creation and extension examples also include an id. Do not guess that it is interchangeable with task_id: the query documentation explicitly uses task_id.

The generation reference describes extension as a separate endpoint, but both published request examples use the same URL, POST https://api.tokenhot.ai/v1/video/generations. In this guide, “extension” means the distinct documented request body and operation—not an invented /extend URL.

1. Create the original video task

Start with a short scene whose motion can continue naturally. For example, write this authored prompt to a UTF-8 file named original.txt:

A smooth camera move along a sunlit garden path toward a wooden gate. Maintain steady forward motion and consistent afternoon lighting.

The generation reference requires a prompt; its text-only example uses this shape:

{
  "model": "veo3.1",
  "prompt": "A smooth camera move along a sunlit garden path toward a wooden gate.",
  "aspect_ratio": "16:9",
  "resolution": "1080p"
}

These are example settings, not a complete capability matrix. The reference also describes image-to-video input, but this walkthrough uses a text-generated parent so that the task lineage is explicit.

Save the complete Python companion as media_workflows.py. It uses the standard library and was checked with Python 3.13.5.

Prepare the JSON locally:

python media_workflows.py veo-request --prompt-file original.txt --out veo-original.json

Set TOKENHOT_API_KEY following Quick Start. The next command makes one POST and can incur usage charges:

python media_workflows.py submit --kind veo --request veo-original.json --run runs/veo-parent --execute

The helper stores the request and received response in a new run directory before extracting task_id. It does not automatically repeat a submission. An existing run directory is rejected; using another directory is not server-side deduplication and can create another task.

2. Confirm and save the original result

Query the original submission:

python media_workflows.py poll --submission runs/veo-parent/response.json --model veo3.1 --out runs/veo-parent-poll --attempts 12 --interval 5 --execute

The documented query states are NOT_START, IN_PROGRESS, SUCCESS, and FAILURE. The helper checks the response envelope, matching model and task ID, and a result URL before accepting SUCCESS. It stops on a failure reason or an undocumented state rather than guessing what that state means.

A completed query is saved as runs/veo-parent-poll/success.json. If the polling budget ends first, start another query session in a fresh output directory against the same submission. These local attempt settings are not a completion-time guarantee or a strict wall-clock deadline.

Read the actual task ID from runs/veo-parent/task.json and the result hostname from the successful query. Download without forwarding the API key to the media host:

python media_workflows.py download --success runs/veo-parent-poll/success.json --task PARENT_TASK_ID --model veo3.1 --approve-host PARENT_RESULT_HOST --output output/original.mp4 --execute

Replace the capitalized placeholders with your actual values. Play the original and decide whether it is worth extending. Checking it first is a workflow safeguard, not a claim that Tokenhot requires manual playback before accepting an extension.

3. Prepare an extension linked to that successful task

Write continuation.txt with an instruction that continues the scene instead of restating its opening. For example:

Continue the same forward camera movement through the wooden gate into the garden. Preserve the afternoon lighting and the established direction of motion.

The extension reference shows this request shape:

{
  "model": "veo3.1",
  "taskId": "PARENT_TASK_ID",
  "prompt": "Continue the camera movement through the gate into the garden."
}

Notice the camelCase taskId. It is not input.task_id, a result URL, a Google operation name, or a local video pathname.

The preparation command checks that your saved successful parent query matches the supplied original ID and model:

python media_workflows.py extend-request --parent-success runs/veo-parent-poll/success.json --parent-task PARENT_TASK_ID --prompt-file continuation.txt --out veo-extension.json

This command is local. It cannot prove the provider will still accept that parent task; it prevents obvious mismatches in the saved inputs. The prepared JSON deliberately contains only the extension fields shown above. Creation settings are not silently copied into a different operation.

4. Submit and query the child—not the parent again

Extension is a separate request and may incur additional usage:

python media_workflows.py submit --kind extend --request veo-extension.json --run runs/veo-child --execute
python media_workflows.py poll --submission runs/veo-child/response.json --model veo3.1 --out runs/veo-child-poll --attempts 12 --interval 5 --execute

The helper stores both the child task_id and its parent_task_id in the child run’s task.json. It rejects a response that reuses the parent identifier instead of supplying a distinct child in this workflow; such a response needs contract verification, not an assumed success.

After child success, use its ID and result hostname:

python media_workflows.py download --success runs/veo-child-poll/success.json --task CHILD_TASK_ID --model veo3.1 --approve-host CHILD_RESULT_HOST --output output/extended.mp4 --execute

Keep original.mp4 and extended.mp4 separately until you have inspected both. Do not automatically concatenate them: the read Tokenhot extension page does not establish whether every response contains the entire extended clip or a continuation segment, or how that behavior is configured.

5. Recover at the stage that failed

Failure stage Recovery direction
Original generation outcome unknown Reconcile the first submission before creating another parent.
Parent still processing Continue querying the same parent; do not prepare an extension from an unconfirmed result.
Extension POST loses its response Keep the parent ID and extension request; check account/support records before sending another extension.
Child query reports failure Keep the child response and failure reason. A successful parent does not mean the child succeeded.
Media download fails Reuse the relevant successful task and a valid result URL, without repeating either POST.
Result plays but the scene jumps Treat it as an output-quality issue; compare the parent ending and child beginning before spending on a revised extension.

The companion rejects redirects, obvious private URL targets, and file overwrites. Media downloads carry no API authorization header. Its MP4 signature check is not a full video decode, and its URL guard is not a hardened server-side fetch system. Use the script locally with hosts you deliberately approve.

Can I extend any uploaded video, and by how many seconds?

The documented request uses an existing taskId; it does not establish arbitrary uploaded-video extension. The read gateway page also does not specify the duration added per request, allowed parent age, extension count, or a universal output-concatenation rule. Confirm those details for the exact route before designing an automatic chain. Native Google limits should not be imported without a verified mapping.

The useful acceptance record is a parent ID, a child ID, their exact prompts and saved responses, both downloaded results, and your inspection of continuity. Keep that record separate from usage and billing observations: no test in this guide verifies model quality, cost, or continuing account access.

Summary

Generate a Veo task, pass its ID into the extension request, track the new child task, and save both videos without confusing their outcomes.

Back to Blog

Related Articles

Grok Imagine Video API: Animate a Product Image

Grok Imagine Video API: Animate a Product Image

October 18, 2026
Kling 3 API: First and Last Frames to a Saved Video

Kling 3 API: First and Last Frames to a Saved Video

October 10, 2026
Gemini TTS API: From Text to Playable Audio in Python

Gemini TTS API: From Text to Playable Audio in Python

October 18, 2026