ToAPIs
    InicioToAPIs
    Generación de imágenesGPT Image 2.6, Gemini, FLUX…Generación de videoSeedance, Veo, Kling, Sora…Chat y redacciónGPT-5.6, Claude, DeepSeek…Voz y músicaLocuciones, TTS, audio
    NovedadSeedance 2.5
    PreciosDocumentación de APIMCP
    BlogAlternativas
    Iniciar sesiónEmpieza gratis
    Todos los modelosPreciosDocumentación de APIMCPBlogAlternativas
    Iniciar sesiónEmpieza gratis

    Idioma

    1. Inicio
    2. Blog
    3. Tutorial
    4. Precise First-Frame Control in Video APIs: Base64 vs Image URLs Compared
    Volver a todos los artículos
    tutorial2026-12-018 min de lectura

    Precise First-Frame Control in Video APIs: Base64 vs Image URLs Compared

    Official ToAPIs first-frame and image-to-video inputs accept public HTTP(S) URLs, not inlined Base64. This tutorial compares documented fields (image_with_roles vs image_urls), the Upload Image API, and URL constraints fetched on 2026-12-01.

    ToAPIs Engineering & Evaluation Team
    First FrameImage-to-VideoUpload APISeedanceMiniMax
    TL;DR - Puntos clave
    • Official pages fetched on 2026-12-01 do not document a first_frame_base64 field, a data-URI body, or inlined Base64 in video generation requests. Seedance, MiniMax Hailuo / H3, Wan, Kling, and the Upload Image API all say to use public HTTP(S) URLs and not to pass Base64 or local paths.
    • The supported production path is to stage a reachable URL first: POST /v1/uploads/images (JPEG, PNG, WebP, or GIF, max 30 MB) returns data.url, or you can pass any public HTTP(S) image URL that meets the target model's size and format limits.
    • Field names differ by family. Prefer image_with_roles with role first_frame on seedance-2-5, MiniMax-H3, and wan3.0-video. Hailuo 2.3 and wan2.6 use image_urls as the first-frame / I2V input. Do not send image_urls and image_with_roles in the same Seedance or MiniMax-H3 request.
    • URL constraints are documented, not optional style tips: public HTTP(S), no embedded credentials, Seedance review rejects URLs longer than 2048 bytes, and each family has its own file-size, dimension, and format window.
    • This is a contract comparison, not a latency benchmark. Official pages do not publish a 1.2-second or 2-second speedup from pre-scaling or from choosing Base64 versus URLs. Bound your poller to the official video-status example: initial 5 s wait, 10 s interval, 600 s cap.

    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 returns data.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_roles with role: "first_frame" on seedance-2-5, MiniMax-H3, and wan3.0-video. Use image_urls for MiniMax-Hailuo-2.3 and wan2.6. Do not mix image_urls with image_with_roles on 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, honor Retry-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:

    text
    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 IDFirst-frame / I2V fieldDuration windowImage constraints cited on the page
    seedance-2-5Prefer 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 choosePublic 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-flashSame field pattern; up to 10 images4–30 seconds, or -1Same URL and size rules; output is 480p or 720p only
    seedance-2 / seedance-2-fast / seedance-2-miniSame image_with_roles roles; seedance-2-mini allows up to 9 reference images4–15 seconds (0 or -1 auto duration on standard and fast only)Same public-URL review rules
    MiniMax-H3Prefer image_with_roles. Compatibility image_urls: 1 image → first_frame; 2 → first and last; 3–9 → reference_image4–15 seconds (MiniMax-H3, MiniMax-H3-Highspeed, MiniMax-H3-Lite); Max / Max-Turbo: 5–15JPG, 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-Fastimage_urls only (one starting-frame image). Fast requires the image (I2V only)6 or 10 seconds; 1080P allows 6 onlyJPG, 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-flashimage_urls only, one image. Flash requires image_urls or metadata.reference_urls (not both)5, 10, or 15 secondsPublic http:// or https:// URL; Base64 is no longer supported; 720p / 1080p
    wan3.0-video / wan3.0-video-primeimage_with_roles with first_frame / last_frame (last requires first). Reference images are a separate array and cannot be mixed with frame roles2–30 seconds, or -1Public 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.

    Abstract flow from a staged image URL through a gateway, with a blocked inline path underneath

    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

    bash
    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:

    json
    {
      "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

    python
    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

    SignalOfficial valuesWhat to do
    Submit HTTP 400, invalid_private_assetsSeedance review: credentialed URL, URL longer than 2048 bytes, the same URL used as different media types, or more than 64 media referencesHost a public URL, shorten it, and do not reuse one URL as both image and video
    Submit or async failure mentioning Base64 / local pathsGeneration pages reject Base64 and local file pathsUpload first, or pass a public HTTP(S) URL
    image_urls plus image_with_rolesSeedance and MiniMax-H3 warn that roles become ambiguousSend only image_with_roles on new integrations
    Mixed first_frame and reference_imageMutually exclusive on Seedance, MiniMax-H3, and Wan 3.0Pick frame mode or reference mode, not both
    Poll queued / in_progressNot final. Official table: wait 5–10 s on queued, 10–15 s on in_progressContinue the 10 s bounded loop; honor Retry-After on 429
    Poll completedRead result.data[0].url (use fallback_url only if the primary URL cannot be accessed)Download before expires_at
    Poll failedInspect error.messageDo not treat draft statuses such as succeeded as official
    Hailuo Fast without image_urlsFast is image-to-video onlyProvide 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 IDPublic-page billing mode (2026-12-01)Listed unit / estimate
    seedance-2-5Per 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-flashSame token settlement$4.30 / 1M total tokens
    MiniMax-H3Per 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.3Per request$0.194 / request (about 38.8 credits)
    MiniMax-Hailuo-2.3-FastPer request$0.136 / request (about 27.2 credits)
    wan2.6Per second$0.060 / s; 5-second catalog estimate $0.30
    wan2.6-flashPer 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, or wan3.0-video — not planning aliases).
    • Stage the first frame with POST /v1/uploads/images or 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_roles with first_frame where it is documented; use image_urls for Hailuo 2.3 and Wan 2.6. Never mix the two fields on Seedance or MiniMax-H3.
    • Set aspect_ratio to adaptive for 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].url before expires_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.

    Explora los modelos mencionados en este artículo

    ByteDanceVIDEO

    Seedance 2.5

    Tarifa actual: Input 2,000 credits/1M, Output 2,000 credits/1M
    Guía del modeloProbar en la consolaObtener clave de API
    MiniMaxVIDEO

    minimax-h3

    Tarifa actual: 13 credits /second, +4 credits /input image (first 5 free)
    Guía del modeloProbar en la consolaObtener clave de API
    AlibabaVIDEO

    wan2.6

    Tarifa actual: 12 credits /second
    Guía del modeloProbar en la consolaObtener clave de API

    Artículos relacionados

    tutorial2026-12-01T10:00:00+08:007 min de lectura

    Automated E-Commerce Video Ad Pipeline: Combining Seedance and MiniMax APIs

    A production-shaped product-image-to-video pipeline that routes official Seedance and MiniMax IDs by documented duration and resolution windows. Costs are a 2026-12-01 catalog estimate, not a $1.20-per-ad unit price, and client-side stitching stays out of band.

    TO
    ToAPIs Engineering & Evaluation Team
    #E-commerce
    tutorial2026-11-23T10:00:00+08:008 min de lectura

    Building Precision Image-to-Video Pipelines with Wan 2.6 R2V API

    A production guide to Wan 2.6 image-to-video and reference-video (R2V) on ToAPIs: documented public IDs wan2.6 and wan2.6-flash, routing rules, metadata parameter placement, resolution vs aspect_ratio behavior, polling, and live pricing.

    TO
    ToAPIs Engineering & Evaluation Team
    #Wan 2.6
    tutorial2026-11-11T10:00:00+08:007 min de lectura

    Integración de la API de MiniMax Hailuo 2.3: generar movimiento humano complejo en vídeo con IA

    Guía para desarrolladores sobre la API de vídeo MiniMax Hailuo 2.3 en ToAPIs: patrones de prompt para movimiento humano, el contrato actual de solicitud para trabajos de 6 y 10 segundos en 768P y 1080P, y ejemplos en cURL y Python.

    TO
    ToAPIs Engineering & Evaluation Team
    #MiniMax Hailuo
    ToAPIs
    InicioToAPIs
    Pasarela empresarial de API de IA. Accede a GPT-5, Claude, Gemini y más de 200 modelos mediante una única API unificada.

    Modelos populares

    • Seedance 2.5 API
    • Seedance 2.0 API
    • Veo 3.1 Fast API
    • Kling 3.0 Turbo API
    Mostrar másMostrar menos
    • GPT Image 2 API
    • Claude Opus 4.8 API
    • Nano Banana 2 API
    • Seedance 2 Mini API
    • Todos los modelos

    Categorías de API

    • API de imagen con IA
    • API de vídeo con IA
    • API texto a vídeo
    • API imagen a vídeo
    Mostrar másMostrar menos
    • API de edición de imágenes con IA
    • API de LLM y razonamiento
    • Todas las herramientas API →

    Alternativas

    Alternativas
    • Alternativa a Kie.ai
    • Alternativa a Fal.ai
    • Alternativa a OpenRouter
    • Alternativa a Replicate
    • Alternativa a Wavespeed AI
    • Todas las comparativas →

    Guías destacadas

    Guías destacadas
    • Precios de Seedance 2.0 y 2.5
    • Guía de la API Seedance más económica
    • Guía de integración de MiniMax H3
    • Clave de API gratuita de Seedance 2
    • Inicio rápido de la API Seedance 2
    • Todos los artículos técnicos →

    Desarrolladores y plataforma

    Desarrolladores y plataforma
    • Documentación de API
    • MCP
    • Precios
    • Área de pruebas de modelos
    • LLMs.txt
    • Contactar con soporte
    • Directorio de guías de modelos
    Entidad operadora:
    鯨樞智能科技有限公司
    JINGSHU INTELLIGENT LIMITED
    Domicilio social:
    ROOM 5042, 5/F, YAU LEE CENTRE, NO.45, HOI YUEN ROAD, KWUN TONG, KOWLOON, HONG KONG
    PrivacidadTérminosUso aceptableEliminación de datosConservación de datosSubencargados y regionesFacturación y reembolsosPolítica de cookiesMapa del sitioAcerca de

    © 2026 ToAPIs. Todos los derechos reservados.