Video API quickstart
Submit a job, poll its status, and download the MP4. Everything here runs against the sandbox, which returns fixture clips and never bills.
Base URL and keys
Set two environment variables. Keys are created in the console after your workspace is approved; the raw secret is shown once. Sandbox keys start with vck_test_.
export VISTARA_BASE_URL="https://<your-workspace-host>"
export VISTARA_API_KEY="<paste from console>" # never commit or log thisSend the key as Authorization: Bearer $VISTARA_API_KEY. Never put a key in a URL, in browser code, or in logs.
Quickstart
curl -sS "$VISTARA_BASE_URL/v1/videos" \
-H "Authorization: Bearer $VISTARA_API_KEY" \
-H "Idempotency-Key: your-unique-job-key" \
-H 'Content-Type: application/json' \
-d '{"model":"video-sandbox","prompt":"An unbranded bag turns on a studio table.","duration_seconds":5,"resolution":"720p","aspect_ratio":"16:9"}'
# Replace JOB_ID with the returned id. Repeat with backoff until terminal.
curl -sS "$VISTARA_BASE_URL/v1/videos/JOB_ID" \
-H "Authorization: Bearer $VISTARA_API_KEY"Polling script
This is the script CI runs against the fixture adapter on every change. It uses a bounded poll with exponential backoff.
#!/usr/bin/env bash
# Vistara Compute quickstart: submit a sandbox job, then poll with backoff until it is terminal.
# Requires VISTARA_BASE_URL and VISTARA_API_KEY in your environment.
set -euo pipefail
: "${VISTARA_BASE_URL:?set VISTARA_BASE_URL}"
: "${VISTARA_API_KEY:?set VISTARA_API_KEY}"
IDEMPOTENCY_KEY="${IDEMPOTENCY_KEY:-quickstart-$(date +%s)-$RANDOM}"
created=$(curl -sS "$VISTARA_BASE_URL/v1/videos" \
-H "Authorization: Bearer $VISTARA_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"video-sandbox","prompt":"An unbranded bag turns on a studio table.","duration_seconds":5,"resolution":"720p","aspect_ratio":"16:9"}')
echo "$created"
JOB_ID=$(printf '%s' "$created" | sed -n 's/.*"id":"\([^"]*\)".*/\1/p')
[ -n "$JOB_ID" ] || { echo "submit failed" >&2; exit 1; }
delay=1
for attempt in $(seq 1 20); do
job=$(curl -sS "$VISTARA_BASE_URL/v1/videos/$JOB_ID" \
-H "Authorization: Bearer $VISTARA_API_KEY")
status=$(printf '%s' "$job" | sed -n 's/.*"status":"\([^"]*\)".*/\1/p')
echo "poll $attempt: ${status:-error}"
case "$status" in
succeeded) echo "$job"; exit 0 ;;
failed) echo "$job"; exit 1 ;;
esac
sleep "$delay"
delay=$(( delay < 8 ? delay * 2 : 8 ))
done
echo "gave up after 20 polls" >&2
exit 2
Sandbox presets
The sandbox accepts only these prompts, exactly as written. Any other prompt returns 422 prompt_not_in_sandbox_presets, because a sandbox clip would not reflect it.
| Preset | Prompt | Result |
|---|---|---|
| studio-bag | An unbranded bag turns on a studio table. | Fixture clip, 5s or 10s |
| ceramic-cup | A ceramic cup rotates slowly under soft window light. | Fixture clip, 5s or 10s |
| linen-swatch | A linen swatch ripples in a gentle breeze. | Fixture clip, 5s or 10s |
| sandbox-failure | Sandbox: simulate a failed job. | Always fails (generation_failed) |
Capabilities
Requests are validated against an explicit capability map. Unknown fields are rejected.
| Field | Type | Sandbox values |
|---|---|---|
| model | string | video-sandbox |
| prompt | string | A preset prompt (see above) |
| duration_seconds | integer | 5, 10 |
| resolution | string | 720p |
| aspect_ratio | string | 16:9 |
POST returns 202 with {id, status, mode, created_at}.
Job object
status is one of queued, running, succeeded, failed. On success, output.url is a signed link that expires at output.expires_at. Each authorized GET returns a fresh link while the asset is retained. A job from another workspace returns 404.
{
"id": "vid_8Kq2xVnR0c1aYpLm",
"object": "video",
"status": "succeeded",
"mode": "sandbox",
"model": "video-sandbox",
"duration_seconds": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"created_at": "2026-12-02T10:00:00.000Z",
"started_at": "2026-12-02T10:00:01.300Z",
"finished_at": "2026-12-02T10:00:05.100Z",
"output": {
"url": "https://…/api/assets/fixtures/studio-bag-5s.mp4?exp=…&sig=…",
"expires_at": "2026-12-02T10:10:05.000Z",
"content_type": "video/mp4"
},
"error": null
}Idempotency
Idempotency-Keyis required on POST (1–255 visible ASCII characters). Keys are scoped to your workspace.- Same key and same payload returns the original job (header
Idempotent-Replayed: true). No second job, no second charge. - Same key with a different payload returns
409 idempotency_conflict. - Keys are retained for at least 7 days, longer than any retry window.
Rate limits and polling
- POST: 30 per minute per key. GET: 120 per minute per key. Over the limit returns
429withRetry-Afterin seconds. - Each workspace has a cap on jobs in flight. Over the cap returns
429 concurrency_limit. - While a job is not terminal, GET returns a
Retry-Afterhint. Poll with backoff (1s, 2s, 4s, capped at 8s) and stop after a bounded number of attempts. - v1 has no webhooks.
Errors
Errors use a stable shape: {"error": {"code", "message", "details?"}}. Codes never change meaning.
| Code | Meaning |
|---|---|
| invalid_request | The request body failed validation. See `details`. |
| unsupported_model | The model is not in the capability map for this key's mode. |
| unsupported_option | Duration, resolution or aspect ratio is not supported by the model. |
| prompt_not_in_sandbox_presets | Sandbox only accepts published preset prompts. |
| content_rejected | The prompt was rejected by the content policy. |
| missing_idempotency_key | Idempotency-Key header is required (1–255 visible ASCII characters). |
| idempotency_conflict | This Idempotency-Key was already used with a different payload. |
| unauthorized | Missing, malformed, revoked or unknown API key. |
| not_found | No job with this id exists in your workspace. |
| rate_limited | Too many requests. Wait for Retry-After seconds. |
| concurrency_limit | Your workspace has too many jobs in flight. Retry after one finishes. |
| spend_cap_reached | This job would exceed the workspace's agreed spend cap. |
| live_mode_unavailable | Live mode is not enabled for this deployment or workspace. |
| service_paused | Live submissions are paused by an operator. |
| generation_failed | The job failed during generation. You are not charged. |
| submit_unconfirmed | The upstream submit could not be confirmed. Held for review; you are not charged. |
| output_expired | The output asset is no longer retained. |
| link_expired | This download link has expired. GET the job again for a fresh link. |
| internal_error | Something went wrong on our side. |
Failure example
To test failure handling, submit the failure preset. It always ends in failed with generation_failed, and is never charged.
curl -sS "$VISTARA_BASE_URL/v1/videos" \
-H "Authorization: Bearer $VISTARA_API_KEY" \
-H "Idempotency-Key: your-unique-job-key" \
-H 'Content-Type: application/json' \
-d '{"model":"video-sandbox","prompt":"Sandbox: simulate a failed job.","duration_seconds":5,"resolution":"720p","aspect_ratio":"16:9"}'{
"id": "vid_…",
"status": "failed",
"mode": "sandbox",
"output": null,
"error": {
"code": "generation_failed",
"message": "Sandbox failure example: this preset always fails so you can test error handling."
}
}Sandbox and live
Sandbox and live use the same contract. A key belongs to one mode. Sandbox usage is shown separately in the console and is always $0. Live mode is available only to approved workspaces, with an agreed spend cap and quote.