Precise First-Frame Control in Video APIs: Base64 vs Image URLs Compared
First-frame (image-to-video) control on ToAPIs is a URL contract, not a Base64 body contract. Official documentation fetched on 2026-12-01 tells you to stage a public HTTP(S) image and pass that URL in a documented field. It does not document first_frame_base64, a data-URI, or inlined Base64 on POST /v1/videos/generations.
This tutorial keeps the scheduled comparison in the title and is honest about the result: production integrations should upload or host the first frame, then submit image_with_roles or image_urls as the target model documents. It is not a latency benchmark, and it does not invent a 1.2-second or 2-second speedup from pre-scaling. For completion signaling, see Handling Asynchronous AI Video Generation with Webhooks. For a broader ID comparison, see The Ultimate AI Video Generation API Benchmark 2026.
1. TL;DR & Performance Overview
- Base64 is not a documented generation-request field. The Upload Image API states that generation APIs no longer accept Base64 image data and gives a general reason: Base64 encoding inflates the payload by about 33 percent. Seedance asset review, Hailuo 2.3, Wan 2.6 / Flash, Wan 3.0, and Kling pages all require public URLs and reject Base64 or local paths.
- Stage a URL, then submit.
POST https://toapis.com/v1/uploads/images(mainland China:https://toapis.cn) accepts JPEG, PNG, WebP, or GIF up to 30 MB and returnsdata.url. A public or presigned HTTP(S) object you host yourself is also acceptable if it meets the model page you call. - Use the official field for that ID. Prefer
image_with_roleswithrole: "first_frame"onseedance-2-5,MiniMax-H3, andwan3.0-video. Useimage_urlsforMiniMax-Hailuo-2.3andwan2.6. Do not miximage_urlswithimage_with_roleson Seedance or MiniMax-H3. - Poll with the official bound. Webhooks are the primary completion signal when a Token is configured. Otherwise poll
GET /v1/videos/generations/{task_id}using the official example: wait 5 seconds, then query every 10 seconds with jitter, honorRetry-After, and cap at 600 seconds.
2. Official IDs, Image Fields, and What Is Documented
Generation examples use https://toapis.com (mainland China: https://toapis.cn) and a model API key:
POST https://toapis.com/v1/videos/generations
Authorization: Bearer <API_KEY>
The table below uses official public model names and request fields from pages fetched on 2026-12-01. Planning aliases such as minimax-h3 or wan-2-6-flash are not the documented IDs.
| Official ID | First-frame / I2V field | Duration window | Image constraints cited on the page |
|---|---|---|---|
seedance-2-5 | Prefer image_with_roles (first_frame, last_frame, reference_image; up to 30 images). Compatibility image_urls exists; do not send both. Use aspect_ratio: "adaptive" for first/last-frame tasks. | 4–30 seconds, or -1 to let the model choose | Public HTTP(S) URLs only; Base64 and local paths are not accepted; images ≤ 30 MB; URLs must not include credentials or exceed 2048 bytes |
seedance-2-5-flash | Same field pattern; up to 10 images | 4–30 seconds, or -1 | Same URL and size rules; output is 480p or 720p only |
seedance-2 / seedance-2-fast / seedance-2-mini | Same image_with_roles roles; seedance-2-mini allows up to 9 reference images | 4–15 seconds (0 or -1 auto duration on standard and fast only) | Same public-URL review rules |
MiniMax-H3 | Prefer image_with_roles. Compatibility image_urls: 1 image → first_frame; 2 → first and last; 3–9 → reference_image | 4–15 seconds (MiniMax-H3, MiniMax-H3-Highspeed, MiniMax-H3-Lite); Max / Max-Turbo: 5–15 | JPG, JPEG, PNG, WebP, HEIC, HEIF; ≤ 30 MB; both sides 256–5760 px; aspect 0.4–2.5. MiniMax-H3 output is 2K or 768p |
MiniMax-Hailuo-2.3 / MiniMax-Hailuo-2.3-Fast | image_urls only (one starting-frame image). Fast requires the image (I2V only) | 6 or 10 seconds; 1080P allows 6 only | JPG, JPEG, PNG, WebP; under 20 MB; short side > 300 px; aspect between 2:5 and 5:2; do not pass Base64 |
wan2.6 / wan2.6-flash | image_urls only, one image. Flash requires image_urls or metadata.reference_urls (not both) | 5, 10, or 15 seconds | Public http:// or https:// URL; Base64 is no longer supported; 720p / 1080p |
wan3.0-video / wan3.0-video-prime | image_with_roles with first_frame / last_frame (last requires first). Reference images are a separate array and cannot be mixed with frame roles | 2–30 seconds, or -1 | Public URL; do not pass local paths or Base64 in the generation request |
Frame mode and reference-image mode are mutually exclusive on Seedance, MiniMax-H3, and Wan 3.0. A last_frame image requires a first_frame image.
The 4/3 size overhead of Base64 is general encoding knowledge, and the Upload Image page cites that 33 percent inflation as one reason generation APIs dropped inlined data. Official pages do not publish a laboratory result such as "pre-scaling to 1920×1080 saves about 2 seconds" or "Base64 accelerates initiation by 1.2 seconds," so those planning-draft figures are not used here.
3. Production Implementation: Upload, Submit, Bounded Poll
The runnable path below stages a local file with the official upload endpoint, then submits a first-frame job on seedance-2-5. You can substitute a public object URL you already host; the generation request still uses image_with_roles.

Figure 1. Official path: stage a public HTTP(S) URL, then submit. Inlined Base64 is not a documented generation field.
3.1 cURL: upload, then first-frame submit
export TOAPIS_API_KEY="YOUR_API_KEY"
export BASE_URL="https://toapis.com" # mainland China: https://toapis.cn
UPLOAD=$(curl --fail --request POST \
--url "$BASE_URL/v1/uploads/images" \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--form "file=@./product-hero.jpg")
IMAGE_URL=$(printf '%s' "$UPLOAD" | python3 -c "import json,sys; print(json.load(sys.stdin)['data']['url'])")
curl --fail --request POST \
--url "$BASE_URL/v1/videos/generations" \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header "Content-Type: application/json" \
--data @- <<EOF
{
"model": "seedance-2-5",
"prompt": "The product sits on a sunlit marble counter. A slow dolly-in, soft shadows, no logo changes.",
"duration": 8,
"resolution": "1080p",
"aspect_ratio": "adaptive",
"generate_audio": true,
"image_with_roles": [
{"url": "$IMAGE_URL", "role": "first_frame"}
]
}
EOF
A Hailuo first-frame request uses the compatibility array instead of roles:
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "The product slowly rotates toward the camera [Push in]",
"image_urls": ["https://example.com/product-hero.jpg"],
"duration": 6,
"resolution": "1080P"
}
3.2 Python: upload, submit, official poll loop
import os
import random
import time
import requests
API_KEY = os.environ["TOAPIS_API_KEY"]
BASE_URL = os.environ.get("TOAPIS_BASE_URL", "https://toapis.com")
def upload_image(path: str) -> str:
with open(path, "rb") as fh:
resp = requests.post(
f"{BASE_URL}/v1/uploads/images",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"file": fh},
timeout=60,
)
resp.raise_for_status()
body = resp.json()
if not body.get("success"):
raise RuntimeError(body)
return body["data"]["url"]
def submit_first_frame(image_url: str) -> str:
resp = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": "seedance-2-5",
"prompt": (
"The product sits on a sunlit marble counter. "
"A slow dolly-in, soft shadows, no logo changes."
),
"duration": 8,
"resolution": "1080p",
"aspect_ratio": "adaptive",
"generate_audio": True,
"image_with_roles": [{"url": image_url, "role": "first_frame"}],
},
timeout=30,
)
resp.raise_for_status()
task = resp.json()
task_id = task.get("id") or task.get("task_id")
if not task_id:
raise RuntimeError(f"submit response missing id: {task}")
return task_id
def poll_video_task(task_id: str, max_wait: int = 600) -> dict:
"""Official video-status example: 5 s initial wait, 10 s interval, 600 s cap."""
start = time.time()
interval = 10
time.sleep(5)
while time.time() - start < max_wait:
resp = requests.get(
f"{BASE_URL}/v1/videos/generations/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=30,
)
if resp.status_code == 429:
retry_after = int(resp.headers.get("Retry-After", interval))
time.sleep(retry_after + random.uniform(0, 1))
interval = min(interval * 2, 120)
continue
resp.raise_for_status()
data = resp.json()
status = data.get("status")
if status == "completed":
item = (data.get("result") or {}).get("data") or []
if not item or not item[0].get("url"):
raise RuntimeError(f"completed without result URL: {data}")
return {
"url": item[0]["url"],
"format": item[0].get("format"),
"expires_at": data.get("expires_at"),
}
if status == "failed":
err = data.get("error") or {}
raise RuntimeError(err.get("message") or data)
time.sleep(interval + random.uniform(0, 1))
raise TimeoutError(f"task {task_id} still running after {max_wait}s")
if __name__ == "__main__":
image_url = upload_image("product-hero.jpg")
task_id = submit_first_frame(image_url)
result = poll_video_task(task_id)
print(result["url"], "expires_at=", result["expires_at"])
Ordinary image and video tasks may also be queried with GET /v1/tasks/{task_id}. Download result.data[0].url before expires_at (a Unix timestamp). Official retention is finish time plus 30 days.
If you already configure Task Webhooks, you can omit the tight poll loop and treat polling as a fallback, as described in Eliminating Video Generation Timeouts and the webhook tutorial.
4. Error Handling & Status Matrix
| Signal | Official values | What to do |
|---|---|---|
Submit HTTP 400, invalid_private_assets | Seedance review: credentialed URL, URL longer than 2048 bytes, the same URL used as different media types, or more than 64 media references | Host a public URL, shorten it, and do not reuse one URL as both image and video |
| Submit or async failure mentioning Base64 / local paths | Generation pages reject Base64 and local file paths | Upload first, or pass a public HTTP(S) URL |
image_urls plus image_with_roles | Seedance and MiniMax-H3 warn that roles become ambiguous | Send only image_with_roles on new integrations |
Mixed first_frame and reference_image | Mutually exclusive on Seedance, MiniMax-H3, and Wan 3.0 | Pick frame mode or reference mode, not both |
Poll queued / in_progress | Not final. Official table: wait 5–10 s on queued, 10–15 s on in_progress | Continue the 10 s bounded loop; honor Retry-After on 429 |
Poll completed | Read result.data[0].url (use fallback_url only if the primary URL cannot be accessed) | Download before expires_at |
Poll failed | Inspect error.message | Do not treat draft statuses such as succeeded as official |
Hailuo Fast without image_urls | Fast is image-to-video only | Provide one starting-frame URL |
Asset review on Seedance can keep a task in queued for several minutes on a first-time URL. Rejection or a preparation timeout ends the task as failed and incurs no video generation fee. Reusing the same URL for the same user and channel can reuse the review result. After the file bytes change, use a new URL.
5. Pricing & FinOps ROI
Unauthenticated GET /api/v1/pricing returned 401 on 2026-12-01, so this snapshot uses the public pricing page (1 credit ≈ $0.005) as an estimate. Confirm the catalog in your account; it is not a locked quote.
| Official ID | Public-page billing mode (2026-12-01) | Listed unit / estimate |
|---|---|---|
seedance-2-5 | Per usage.total_tokens after the task finishes; a per-second figure is only a budget estimate | $2.90 / 1M total tokens (about 580 credits / 1M tokens at 1 credit ≈ $0.005) |
seedance-2-5-flash | Same token settlement | $4.30 / 1M total tokens |
MiniMax-H3 | Per second | $0.064 / s (about 12.8 credits / s); the catalog row showed an estimated $0.32 for a 5-second default |
MiniMax-Hailuo-2.3 | Per request | $0.194 / request (about 38.8 credits) |
MiniMax-Hailuo-2.3-Fast | Per request | $0.136 / request (about 27.2 credits) |
wan2.6 | Per second | $0.060 / s; 5-second catalog estimate $0.30 |
wan2.6-flash | Per second | $0.015 / s; 5-second catalog estimate $0.075 |
Planning drafts that quote a Seedance "pricing baseline" of $0.030–$0.038 per second are not this catalog: seedance-2-5 settles on tokens, not a published per-second rate. Official pages also do not publish a 99.95% SLA.
Uploading once and reusing data.url avoids re-sending the same bytes on every variation, which is the reuse reason given on the Upload Image page — not a measured dollar saving in this article.
6. Frequently Asked Questions
The answers in the frontmatter cover Base64 support, official field names, upload versus self-hosted URLs, format limits, and polling. Two operational notes belong here as well:
- Presigned URLs. Official Seedance review requires a public HTTP(S) URL, rejects embedded credentials, and identifies media by URL. If you use a presigned object, keep the URL under 2048 bytes, make sure it stays reachable through asset review and generation, and issue a new URL after the object changes.
- Product pipelines. Once the first-frame URL is in hand, you can route the same asset to Seedance and MiniMax IDs that actually accept that duration and resolution. That assembly is covered in Automated E-Commerce Video Ad Pipeline.
7. Action Checklist
- Confirm the official model ID on today's generation page (
seedance-2-5,MiniMax-H3,MiniMax-Hailuo-2.3,wan2.6, orwan3.0-video— not planning aliases). - Stage the first frame with
POST /v1/uploads/imagesor a public HTTP(S) URL that meets that model's size and format limits. Do not send Base64 in the generation body. - Use
image_with_roleswithfirst_framewhere it is documented; useimage_urlsfor Hailuo 2.3 and Wan 2.6. Never mix the two fields on Seedance or MiniMax-H3. - Set
aspect_ratiotoadaptivefor Seedance first/last-frame tasks, as the generation page requires. - Configure Task Webhooks if you need a push completion signal; otherwise poll no faster than the official 5–10 / 10×60 guidance, with jitter and
Retry-After. - Download
result.data[0].urlbeforeexpires_at, and confirm prices in your account catalog rather than in a planning draft.
Official sources fetched on 2026-12-01: Upload Image, Seedance 2.5 generation, MiniMax H3 generation, Hailuo 2.3 generation, Wan 2.6 generation, Wan 3.0 generation, and Get Video Task Status.