Skip to Content
API referenceVideo GenerationOverview

Video API

A unified video generation API compatible with the OpenRouter Video Generation standard. One schema covers text-to-video, image-to-video, first/last-frame, and reference-to-video generation. Submit a task asynchronously, then poll or receive a webhook when it finishes.

FeatureDetail
Base URLhttps://api.ofox.io
Protocol styleOpenRouter-compatible (async submit → poll / webhook)
Generation modeInferred implicitly: no images = text-to-video · frame_images = image-to-video / first-last frame · input_references = reference-to-video
Result deliveryPoll GET (rate-limit protected) or a callback_url webhook (HMAC-signed, automatically retried)
Video storageUpstream original URL (temporary) + optional CDN mirror (persistent signed URL)

Authentication

Every request carries your ofox API key (format sk-xxx…) in the HTTP header:

Authorization: Bearer $OFOX_API_KEY

callback_url must be HTTPS. Webhook callback addresses are validated against SSRF: private, loopback, and cloud-metadata addresses are all rejected. A non-HTTPS address or one pointing to an internal network fails at creation time with 400 invalid_callback_url.

Quickstart

Video generation is an asynchronous task completed in three steps:

  1. POST /v1/videos creates the task and immediately returns 202 with the task id.

    If the upstream is under unusually heavy load and has not accepted the task within 45 seconds, the task switches to asynchronous submission: the request still returns 202 with the task id (status is pending), and you get the result by polling or via webhook as usual.

  2. GET /v1/videos/{id} queries the status until status reaches a terminal state: completed, failed, cancelled, or expired. Poll no more often than once per second. Alternatively, pass a callback_url at creation time and OfoxAI will push a notification when the task finishes; see Webhooks.

  3. Download the video from mirror_urls (preferred) or unsigned_urls in the result. unsigned_urls are temporary upstream addresses that may expire after 24 hours; see Video URLs.

video.py
import time import requests API = "https://api.ofox.io/v1/videos" HEADERS = {"Authorization": "Bearer YOUR_OFOX_API_KEY"} # 1. Create the task resp = requests.post(API, headers=HEADERS, json={ "model": "bytedance/seedance-2.0-mini", "prompt": "A fox running through the snow, the camera following it", "duration": 5, "resolution": "720p", "aspect_ratio": "16:9", }) resp.raise_for_status() task_id = resp.json()["id"] # 2. Query every 10 seconds until a terminal state is reached while True: task = requests.get(f"{API}/{task_id}", headers=HEADERS).json() if task["status"] in ("completed", "failed", "cancelled", "expired"): break time.sleep(10) # 3. Download the result if task["status"] == "completed": url = (task.get("mirror_urls") or task["unsigned_urls"])[0] with open("fox.mp4", "wb") as f: f.write(requests.get(url, timeout=600).content) print("Video seconds:", task["usage"]["video_seconds"], "Cost:", task["usage"]["video_cost"]) else: print(task["status"], task.get("error"))

The create call returns:

{ "id": "9bcf3c60-7db2-4e1a-a1b2-c3d4e5f60718", "status": "pending", "polling_url": "https://api.ofox.io/v1/videos/9bcf3c60-7db2-4e1a-a1b2-c3d4e5f60718" }

All video models share the same request structure; change model to switch models. If resolution, duration, or aspect_ratio falls outside the model’s supported range, the create request returns 400 unsupported_parameter and no task is created. See Video models for each model’s supported range.

Endpoints

MethodEndpointDescription
POST/v1/videosCreate a video task
GET/v1/videos/{id}Get task status and result
DELETE/v1/videos/{id}Cancel a task

Use the video model catalog  for current video models. Resolutions, durations, aspect ratios, and prices vary by model. For each model’s parameter values, see the family pages Seedance, Wan & HappyHorse, and Hailuo; for definitions of the capability fields, see Video models.

Pin a provider

The same video model may be served by multiple providers. If none is specified, tasks are distributed by weight. To pin a provider, pass provider.type at the top level of the request body:

{ "model": "<model ID>", "prompt": "...", "provider": { "type": "<provider>" } }

See Provider routing for the field reference; the providers available for each model are listed on the corresponding model family page.

Pricing

Most video models are billed by duration: the system matches a tier in pricing.video_pricing.tiers based on resolution, input type, and audio options to get a USD-per-second rate, and you can estimate the cost as tier rate × requested duration. For video-to-video tasks, billed seconds may include the input video’s duration.

Seedance models are billed by tokens, consistent with the official pricing. The matched tier carries token_price (USD per 1M tokens), and the charge is video_tokens × token_price / 1,000,000, where video_tokens = (reference video seconds + output seconds) × output width × output height × 24 / 1024; a minimum token usage applies when a reference video is supplied. For these tiers, price is a per-second equivalent at 16:9 and is only useful for estimates: price × (output seconds + reference video seconds). The actual charge follows usage.video_tokens.

pricing.output_video_per_second only indicates the model’s lowest starting price; for token-billed models it is the lowest text-to-video tier. Once the task completes, use usage.video_cost in the response as the actual charge; token-billed tasks also return usage.video_tokens (the billed token count).

If resolution is omitted, the model’s default resolution (video_attributes.default_resolution) is used. The higher the default resolution, the higher the rate, so passing it explicitly is recommended. The cost is estimated from the request when the task is created; if your balance is insufficient, 402 insufficient_credits is returned and no task is created.

Next

Last updated on