---
name: Custom Video Generation On Demand
title: Custom Video Generation On Demand
description: Generate custom videos via Varosity AI. Includes an optional reference image step, recommended when the look matters.
trigger: User requests a custom video with specific directions
author: Varosity AI
version: "3.1"
updated: "2026-06-20"
source_url: https://varosity.ai/api/v1/skills/custom-video-generation
local_path: ~/.varosity/skills/custom-video-generation.md
tags: [varosity, video, custom-content, on-demand, reference-image]
kind: pipeline
reproducibility:
  providers:
    - { name: pick_reference_images / gemini-3-pro-image, role: optional reference frame (when the look matters), endpoint: POST /api/v1/images }
    - { name: kling-3.0 / veo-3.1, role: video render, endpoint: POST /api/v1/video/generate }
  inputs: "Concept + style/tone + aspect ratio; optionally a reference image (recommended when a product, character or brand must look a certain way)."
  dependencies: ["scope: generate:video", "scope: generate:image"]
  parameters: { aspect_ratio: "9:16 or 16:9", duration: "model max (Veo 8s / Kling 10s)" }
  cost: "Veo $0.15/s, Kling $0.168/s on Credits; failed renders not billed"
  example: "#reference-run"
  failure_modes:
    - "no reference frame when the look matters -> off-target $0.50-2 render; pick one frame per project for products, characters or brands"
    - "status running/rendering with code insufficient_credits -> a finished render held 24 hours (1 hour for providers whose files expire); buy credits and poll once more, never resubmit"
    - "requesting duration beyond model max -> capped; check /api/v1/models maxDurationSec"
---

> **Varosity runtime notes (2026-11-10.2) — these apply to every step below and win over anything older in this playbook.**
>
> - **Auth.** REST steps need a `vsk_` key (`Authorization: Bearer vsk_…`). An app signed in over OAuth (a `vso_` token) can use only the MCP server at `https://varosity.ai/api/mcp`: 29 of the 46 tools and a daily cap that starts at $5, without multi-voice assembly (`/api/v1/audio/assemble`), storyboards, brand agents, transcription, webhook changes or `govern_asset`. Keys made through agent connect have the default scopes (generate:*, projects:*, webhooks:read, credits:read); steps needing any other scope (transcription, storyboards, brands, runs, gates, webhook changes, asset governance) answer 403 until the user adds it on the API keys page. No key yet? A 401 carries `agent_connect` (get a key yourself — POST it, show your user the approval link, poll; the user only approves) and `agent_key` (a one-click key page for your user).
> - **Daily cap.** Every key has a daily spend cap. A run that costs more stops part-way with 429 `daily_cap_exceeded` — estimate first (`GET /api/v1/video/estimate` is free).
> - **Errors.** Not enough Credits (and no own provider key): video, images and music answer 409 `auth_not_configured`; `/api/tts` and storyboards answer 402 `insufficient_credits`; the other voice tools (sound effects, cloning, voice design, voice changer, transcription, dubbing) answer 409 `provider_not_configured`. A finished result the balance can't cover is 402 `insufficient_credits` (from `get_job`: `running` with that code). In every case: top up or connect a key, then retry or poll again — don't resubmit a held result. A finished video whose charge failed on our side is held with `billing_unavailable` instead (`get_job` `running`, REST `/api/v1/jobs` `rendering`): it is never charged twice and the balance is not the problem — keep polling every 30–60 s; don't call `buy_credits` and don't resubmit. A hold can still end `failed`, uncharged (render it again): a billing hold after 72 h, either hold after 1 h on Replicate- or HeyGen-routed models (their outputs expire), or if the output is gone when it would be released. 429 `rate_limited`: wait `Retry-After`, then retry. 429 `daily_cap_exceeded` (with `spent_today_cents`, `daily_cap_cents`): stop and tell the user — it resets at 00:00 UTC; retrying won't help. 400 `reference_image_unreachable`: we couldn't download the reference image and nothing was charged — host it publicly or send a `data:` URI. 400 `invalid_url` (voice tools): a URL you gave isn't public, can't be reached or answered an error, or is too large — fix the URL; retrying won't help. REST errors are `{ ok: false, error, code }`; over MCP a failed tool call says the same — as a result with `isError: true` when your client connects over HTTP and sends `MCP-Protocol-Version`, otherwise (the `@varosity/mcp-server` stdio proxy, plain JSON-RPC callers) as a JSON-RPC error; unknown tools and bad arguments are JSON-RPC `-32602`.
> - **Music.** MCP `generate_music` waits up to 90 s. If `audioUrl` is empty (`sync: false`), call `get_job` with `jobId` = the `trackId` every ~15 s until it succeeds (REST, with a `vsk_` key: `POST /api/music/poll { trackId }`). It is charged once, when ready; a track unfinished after 30 min is reported failed and not charged.
> - **Retries.** An `Idempotency-Key` header blocks a repeat sent while the first is still running on video generation (`/api/v1/video/generate`, `/api/generate`), images (`/api/v1/images` and its aliases), voice (`/api/tts`, `/api/v1/tts`), music (`/api/music`, `/api/v1/music`), `/api/v1/sfx` and `/api/v1/audio/assemble` — that repeat gets 409 `idempotency_in_flight` (retry shortly for the first result); a key reused on a different endpoint gets 409 `idempotency_key_reused`; 409 `idempotency_result_lost` means the first request already ran (and may have been charged) but its response was lost — it is not run or charged again under that key, so do not resend with a new key unless the user wants a second paid generation. Elsewhere, wait for the first call to finish before retrying.
> - **Keep your files.** A video's `outputUrl` is the provider's own link, not Varosity storage: Replicate deletes outputs after about an hour and other providers expire them later — download each clip as soon as its job succeeds, and stitch within the hour if any clip came from a Replicate-routed model (stitching downloads the clips). Images, voice, ElevenLabs Music and stitched project renders are stored by Varosity.
> - **Veo 3.1** (`veo-3.1`, `veo-3.1-quality`, `veo-3.1-lite`) keeps its ids and prices; all three tiers now run on Varosity credits only (no own-key route), always with audio, 1080p only on 8-second clips.
> - **Tell your user** which model made each result and what it cost, from the response: `cost_cents` (REST images), `costCents` (MCP images, music and `generate_voice`, video jobs), `totalCostCents` (assemble). On the user's own provider key there is no Varosity charge — say so.


> ⚡ **Maintained by Varosity AI.** The `refresh_skills` MCP tool with `slug: "custom-video-generation"` returns the latest version of this skill (it also lives at https://varosity.ai/api/v1/skills/custom-video-generation).
> Manual update: `curl -s https://varosity.ai/api/v1/skills/custom-video-generation > <your-runtime-skills-path>/custom-video-generation.md`

# Custom Video Generation On Demand (Clean Pipeline)

Generate raw custom videos on **Varosity AI**. **Clean delivery only**: a hosted MP4 URL, nothing else. No subtitles, no end cards, no branding, no auto-posting.

## Core Promise

When you ask for a video:
1. ✅ Engineer your concept into a Varosity generation request
2. ✅ Submit to a Varosity video model (Veo 3.1 or Kling 3.0)
3. ✅ Poll the job to completion
4. ✅ Return the hosted MP4 URL
5. ✅ Done — no extras

## How to Use

Describe what you want:

```
"Make me a video of [concept]. [Your style/tone]. [Details]. [9:16 or 16:9]."
```

I'll confirm specs, offer a reference frame if the look matters, and generate.

## Authentication

All Varosity API/MCP calls use your `vsk_` API key (manage at https://varosity.ai → API Keys).
- **REST:** header `Authorization: Bearer vsk_...`. Video needs the `generate:video` scope.
- **MCP:** connect the Varosity MCP server (`https://varosity.ai/api/mcp`, Streamable HTTP) — the key is configured once on the connection.

Billing is automatic: Varosity uses your saved provider key if you have one (BYOK, zero markup), otherwise your Varosity Credits balance. Failed generations are never billed.

## Reference Image (recommended when the look matters)

A text prompt alone is enough for a first clip. When a product, character or brand must look a certain way, pick a reference frame once per project (never per shot) and reuse it:

1. **Ask:** "Do you already have a reference image you'd like to use?"
   - If YES → use their URL as `referenceImageUrl`.
   - If NO → call the `pick_reference_images` MCP tool with a style/mood prompt (or `generate_image` / `POST /api/v1/images` for a single frame).
2. **Show 3 options** and ask: "Which best matches what you're going for? (1, 2, or 3)"
3. **Generate the video**, passing the chosen image as `referenceImageUrl`. Reuse the same image for every shot in the project.

This costs about 6¢ (3 candidates at 2¢ each on the default `muapi-flux-dev`; more on pricier image models) and can prevent an off-target $0.50–$2 video render.

## The Clean Pipeline

**Step 0 — Reference image (optional):** see above. Skip it for a first clip where a text prompt is enough.

**Step 1 — Parse the request:** concept, duration, aspect ratio, style, critical details.

**Step 2 — Engineer the prompt:** scene description, camera direction, lighting, color, pacing, mood. (Optional: call `POST /api/v1/route` / Smart Route to get a model recommendation for the shot.)

**Step 3 — Submit.**

MCP (preferred):
```
generate_video({
  prompt: "[detailed prompt]",
  modelId: "veo-3.1",          // or "kling-3.0"
  aspectRatio: "9:16",          // veo-3.1: 16:9 | 9:16 · kling-3.0: 16:9 | 9:16 | 1:1 (check the model's aspectRatios in GET /api/v1/models)
  durationSec: 8,               // Veo renders 4, 6 or 8s; Kling 5 or 10s — you are billed for the seconds produced
  referenceImageUrl: "[chosen reference image URL]"
})
→ { jobId, status }
```

REST equivalent:
```
POST https://varosity.ai/api/v1/video/generate
Authorization: Bearer vsk_...
Content-Type: application/json

{ "prompt": "[detailed prompt]", "modelId": "veo-3.1",
  "aspectRatio": "9:16", "durationSec": 8,
  "referenceImageUrl": "[chosen reference image URL]" }
→ { "ok": true, "jobId": "...", "status": "rendering", "outputUrl": null, "billingMode": "platform" }
```

**Step 4 — Poll to completion.**
- MCP: `get_job({ jobId })` every 2–5 seconds.
- REST: `GET https://varosity.ai/api/v1/jobs/{jobId}` every 2–5 seconds.
- Status goes `rendering → succeeded` (or `failed`). Renders typically take a few minutes.
- **Termination:** stop on `succeeded` (read `outputUrl`) or `failed`/`error` (fatal — don't retry the same call). Give up after a **max ~120 polls / ~10 min** wall-clock and report a timeout; that's a stuck job, not normal latency.
- **Held renders:** a result with status `running` / `rendering` and `code: "insufficient_credits"` is a FINISHED render held for 24 hours (1 hour for providers whose files expire) until it is paid for. Stop polling, call `buy_credits` (or tell the user to add credits), then poll once more to release it. Don't resubmit.

**Step 5 — Deliver.** On `succeeded`, return the `outputUrl` (a hosted MP4). That's the clean deliverable — play, download, or share it anywhere.

## Reference run — concrete single-shot (verified)

Shows the one thing prose can't: a **raw user ask turned into an engineered prompt**, then the exact calls.

**Raw request:** "a quick 8-second vertical clip of a barista pouring latte art, cozy vibe."

**Step 2 — engineered prompt** (raw asks lack camera/light/mood; fill them in):
> "Close-up, slow-motion pour of espresso into steamed milk forming a rosetta leaf in a ceramic cup,
> a barista's hands steady in frame, warm morning window light, shallow depth of field, soft cafe
> bokeh, gentle steam rising, cozy and inviting, cinematic 9:16."

**Step 0 — reference frame:**
```
POST /api/v1/images { "prompt": "<same scene, single frame>", "modelId": "gemini-3-pro-image", "aspectRatio": "9:16" }
→ { "imageUrl": "https://nkluppgbrrxbfkaktnks.supabase.co/storage/v1/object/public/varosity-assets/img/latte.png" }
```
**Step 3 — generate:**
```
POST /api/v1/video/generate
{ "prompt": "<engineered prompt above>", "modelId": "veo-3.1", "aspectRatio": "9:16",
  "durationSec": 8, "referenceImageUrl": "https://nkluppgbrrxbfkaktnks.supabase.co/storage/v1/object/public/varosity-assets/img/latte.png" }
→ { "ok": true, "jobId": "c41a...", "status": "rendering" }
```
**Step 4 — poll:** `GET /api/v1/jobs/c41a...` every 3s → … → `{ "status": "succeeded", "outputUrl": "https://nkluppgbrrxbfkaktnks.supabase.co/storage/v1/object/public/varosity-renders/v/latte.mp4" }`

**Cost:** 14¢ image (gemini-3-pro-image) + 8s × $0.15/s (veo-3.1) ≈ **$1.34**. Failed renders: $0.

**Complete request surface (so nothing is "missing"):** `/api/v1/images` requires only
`{prompt, modelId, aspectRatio}` and `/api/v1/video/generate` only the five fields shown — there are
**no hidden required params**: dimensions derive from `aspectRatio`, and these endpoints expose no
`width`/`steps`/`seed` knobs. `billingMode` in the response (`platform` = Credits vs `byok`) only
records who pays; it changes nothing in your call.

**Determinism workaround:** no seed exists, so to reproduce the *exact* look, **persist the returned
`imageUrl`** and reuse it verbatim as `referenceImageUrl` along with the verbatim prompt — that pins
the visual anchor. Same inputs → equivalent (not bit-identical) clip.

**On timeout:** there's no cancel endpoint — abandon the `jobId` (you weren't billed for an
unfinished render) and submit a fresh `generate_video`. This does not apply to a held render
(`code: "insufficient_credits"`): that one is finished, so add credits and poll it once more instead
of resubmitting.

## Models

- **`veo-3.1`** — cinematic, character/scene work, native audio. Best default for storytelling.
- **`kling-3.0`** — product motion, dynamic action, strong physics.

Call `GET /api/v1/models` for the full list with capabilities and pricing. Use `POST /api/v1/route` if unsure which model fits a shot.

## Duration & longer videos

- A single `generate_video` shot is **3–10 seconds** (model limit).
- For longer pieces, use the **storyboard pipeline**: `POST /api/v1/storyboards` → keyframes → `POST /api/v1/storyboards/{id}/render` (creates a project + shots) → generate each shot → **`POST /api/v1/projects/{projectId}/stitch`** to combine the rendered shots into one MP4.

## Aspect Ratios
- **9:16** — TikTok, Reels, Shorts
- **16:9** — YouTube, widescreen
- **1:1** / **4:5** — feed posts
- **21:9** — cinematic ultrawide

Each video model renders only a subset (`veo-3.1`: 16:9, 9:16; `kling-3.0`: 16:9, 9:16, 1:1) — check the model's `aspectRatios` in `GET /api/v1/models`. An unsupported ratio is refused with HTTP 400 `unsupported_aspect_ratio` listing the supported ones.

## What you get / don't get

✅ Raw hosted MP4 URL · your exact specs · native audio (model-generated) · ready to use anywhere
❌ No subtitles · no end cards · no branding · no auto-posting · no platform integration

## Limitations
- AI-generated, not filmed footage.
- English prompts work best.
- AI-composed music only (no licensed tracks); specify a vibe.
- Lip-sync is approximate.
- Per-shot ≤10s; longer requires the stitch pipeline above.

## Troubleshooting
- **Render seems slow:** video renders take minutes — keep polling `get_job` / `GET /api/v1/jobs/{jobId}`; don't treat a multi-minute render as a failure.
- **`404`:** you're on the wrong path — image is `POST /api/v1/images`, video is `POST /api/v1/video/generate`, polling is `GET /api/v1/jobs/{jobId}`. See `https://varosity.ai/llms.txt` and `https://varosity.ai/api/openapi.json`.
- **`403 missing scope`:** your API key needs `generate:video` (and `generate:image` for reference frames). Re-issue the key with those scopes.
- **`409 provider_not_configured`:** the model needs a provider key you don't have and has no credits fallback — switch models (`GET /api/v1/models`) or add credits.
- **Output doesn't match vision:** refine the prompt and regenerate; failed/again renders aren't double-billed for the failure.

## When to use this skill
✅ One-off custom videos, social clips, product demos, lifestyle/aesthetic shots, promos.
❌ Multi-video scheduled campaigns or branded/auto-posted content — use the orchestration skills (`varosity-video-orchestration`) instead.
