Skip to content

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_.

shell
export VISTARA_BASE_URL="https://<your-workspace-host>"
export VISTARA_API_KEY="<paste from console>"   # never commit or log this

Send the key as Authorization: Bearer $VISTARA_API_KEY. Never put a key in a URL, in browser code, or in logs.

Quickstart

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

scripts/quickstart.sh
#!/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.

Sandbox presets
PresetPromptResult
studio-bagAn unbranded bag turns on a studio table.Fixture clip, 5s or 10s
ceramic-cupA ceramic cup rotates slowly under soft window light.Fixture clip, 5s or 10s
linen-swatchA linen swatch ripples in a gentle breeze.Fixture clip, 5s or 10s
sandbox-failureSandbox: simulate a failed job.Always fails (generation_failed)

Capabilities

Requests are validated against an explicit capability map. Unknown fields are rejected.

Request fields
FieldTypeSandbox values
modelstringvideo-sandbox
promptstringA preset prompt (see above)
duration_secondsinteger5, 10
resolutionstring720p
aspect_ratiostring16: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.

GET /v1/videos/{id} → 200
{
  "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-Key is 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 429 with Retry-After in 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-After hint. 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.

Error codes
CodeMeaning
invalid_requestThe request body failed validation. See `details`.
unsupported_modelThe model is not in the capability map for this key's mode.
unsupported_optionDuration, resolution or aspect ratio is not supported by the model.
prompt_not_in_sandbox_presetsSandbox only accepts published preset prompts.
content_rejectedThe prompt was rejected by the content policy.
missing_idempotency_keyIdempotency-Key header is required (1–255 visible ASCII characters).
idempotency_conflictThis Idempotency-Key was already used with a different payload.
unauthorizedMissing, malformed, revoked or unknown API key.
not_foundNo job with this id exists in your workspace.
rate_limitedToo many requests. Wait for Retry-After seconds.
concurrency_limitYour workspace has too many jobs in flight. Retry after one finishes.
spend_cap_reachedThis job would exceed the workspace's agreed spend cap.
live_mode_unavailableLive mode is not enabled for this deployment or workspace.
service_pausedLive submissions are paused by an operator.
generation_failedThe job failed during generation. You are not charged.
submit_unconfirmedThe upstream submit could not be confirmed. Held for review; you are not charged.
output_expiredThe output asset is no longer retained.
link_expiredThis download link has expired. GET the job again for a fresh link.
internal_errorSomething 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.

bash
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"}'
eventual GET → 200
{
  "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.