Video guides
Video Generation API Quickstart: Create, Poll and Download
Use this platform’s API Key to inspect models, estimate Credits, submit one video task, poll its status and download the result. Includes a runnable Node.js example.
Use this platform’s API to select an available model, estimate Credits, create one asynchronous video task, query its status and download its output. This is the API of this independent website, not Pika’s official API. Pika H3 Flex itself is not currently available here. Use model IDs returned by this site’s catalog.
Contract checked against the site implementation on November 9, 2026. The downloadable example is checked with simulated responses and local unauthenticated requests; this guide does not claim a paid end-to-end provider run.
1. Create an API Key
Sign in and open Settings → API Keys. Create a key for your integration. Supply it from your backend environment as API_KEY; do not put it into frontend bundles, public repositories or URLs.
The generation and task-query APIs accept Authorization: Bearer sk_.... An invalid explicit credential is rejected even if a browser also has a valid session. Your key uses its owner’s account and Credit balance.
Use https://pikah3flex.com as the base origin. API paths are /api/... in both languages: do not add /zh.
| Method and path | Purpose | Authentication |
|---|---|---|
GET /api/ai/router01/models?projectOnly=1&type=video |
Inspect project video models and current params |
Public catalog; no key required |
POST /api/ai/router01/quote |
Validate inputs and estimate Credits | Public estimate; no task is created |
POST /api/ai/generate |
Create a task and deduct Credits | Your API Key |
GET /api/ai/task?taskId=... |
Query a task owned by that account | The same account’s API Key |
Upload routes, /api/download, /api/storage/download and account-management routes are not all API-Key-enabled. The download and upload proxies currently require a signed-in browser session. For server integrations, supply reachable media URLs and download from the output URL directly. Do not assume that /api/credits accepts this API Key; use the account UI to inspect balance and history.
2. Inspect the model before choosing settings
export API_BASE_URL='https://pikah3flex.com'
curl -sS "${API_BASE_URL}/api/ai/router01/models?projectOnly=1&type=video"
A successful envelope has code: 0 and an array in data. Each model includes its slug, type, name and params. Inspect allowed values, minimums, maximums, required inputs and defaults. An empty project catalog is not proof that arbitrary platform models can be generated; contact support if the intended model is absent.
The example below assumes the currently listed seedance-2.0-mini supports 4 seconds, 480p and 16:9. Verify these values first or choose another listed model with compatible settings.
3. Quote the same payload you plan to submit
Save this as request.json:
{
"mediaType": "video",
"model": "seedance-2.0-mini",
"prompt": "A ceramic cup on a wooden table. One slow camera push-in, soft morning light, restrained movement.",
"options": {
"mode": "text-to-video",
"visibility": "private",
"duration": 4,
"resolution": "480p",
"aspect_ratio": "16:9"
}
}
curl -sS "${API_BASE_URL}/api/ai/router01/quote" \
-H 'Content-Type: application/json' \
--data-binary @request.json
Read data.credits as the estimate for the complete attempt. Quote fields such as priceUsd, scope and provider describe the pricing calculation; a USD provider amount is not a separate cash checkout or necessarily your effective cost per purchased Credit. See Credit costs and pack conversion.
A quote does not reserve a price or a task slot. Submission calculates the price again. Do not send your own price or balance as authority.
4. Submit once and keep the local task ID
This POST can consume Credits. Only run it after reviewing the estimate and settings:
curl -sS "${API_BASE_URL}/api/ai/generate" \
-H "Authorization: Bearer ${API_KEY}" \
-H 'Content-Type: application/json' \
--data-binary @request.json
On success, the response envelope’s data contains id, dbId, taskId, taskStatus, taskInfo, costCredits and remainingBalance. The initial state is queued. Save dbId or id as your stable lookup ID before polling; later responses may also contain a provider task ID.
Check both HTTP status and the JSON envelope. Some validation and business failures return HTTP 200 with code: -1 and a message. HTTP 200 alone does not mean the task exists. This API has no documented client idempotency-key contract: if a generation POST times out or its response is lost, check My Creations and contact support before submitting again.
5. Poll, then download
curl -sS --get "${API_BASE_URL}/api/ai/task" \
-H "Authorization: Bearer ${API_KEY}" \
--data-urlencode "taskId=${VIDEO_TASK_ID}"
A single-ID query returns one task in data.
data.taskStatus |
What to do |
|---|---|
queued, pending, processing |
Keep the ID and query again after a reasonable interval, such as 10 seconds |
success |
Read data.taskInfo.videos[].videoUrl and download the required outputs |
failed, canceled |
Inspect data.taskInfo.userErrorCode, then check task and Credit history |
Stopping your poll loop does not cancel the task. A client deadline also does not prove server-side failure. Batch queries use taskIds and return data.tasks; the current limit is 10 IDs. Do not confuse that shape with a single-ID response.
Download the returned HTTPS media URL from your backend or a tool such as curl. Do not forward the platform API Key to the media host. If a media URL fails, query the existing task and retry the download where appropriate; do not create a replacement generation simply to download again. Avoid sharing signed result URLs publicly.
Runnable Node.js example
Download video-api-quickstart.mjs and run it with Node.js 22 or later. It uses built-in modules only. Set API_KEY in your server environment first.
# Default: inspect the catalog and request a quote only.
node video-api-quickstart.mjs
# After reviewing the quote: permit one new generation.
SUBMIT_VIDEO=1 node video-api-quickstart.mjs
# Resume an existing task; this does not create another task.
VIDEO_TASK_ID='your_saved_local_task_id' node video-api-quickstart.mjs
Optional settings are API_BASE_URL, VIDEO_MODEL, VIDEO_DURATION, VIDEO_RESOLUTION and VIDEO_RATIO. The example validates basic settings against the catalog, submits at most once, makes up to 60 status queries with a ten-second wait between queries, and writes a new video-<task-id>.<format> without overwriting an existing file. It never forwards the key to the media host. It is a short-clip example that buffers the download in memory; use streaming for larger production assets.
If polling ends or a read fails, retain the task ID and resume the query. The example stops on errors rather than automatically retrying a paid POST. A fresh run without VIDEO_TASK_ID, with SUBMIT_VIDEO=1, can create another chargeable task.
Add image or reference inputs
The sample explicitly sets options.visibility: "private" to exclude the creation from public listings. Omitting it can leave a task eligible for public display. This does not guarantee authenticated media URLs, zero retention or no provider training; see the privacy and commercial-use guide before submitting confidential inputs.
Use top-level imageUrls, videoUrls and audioUrls with the same options structure. For image-to-video, choose options.mode: "image-to-video" and pass the first frame in imageUrls. For reference-to-video, use options.mode: "reference-to-video" and only the reference types/counts supported by that model. Do not wrap this site’s request in an upstream input object or assume all models accept audio-only references.
The media must remain reachable by the provider for processing; local filesystem paths and URLs needing your browser cookies are unsuitable. Upload support, model input limits and provider metering are separate checks. Requote after changing inputs, especially video/audio durations.
For failures and public task codes, use the video troubleshooting guide. For creative revisions, see the prompt guide. Include the task ID, model, time and redacted request when contacting support, never your API Key.