Before generating anything, determine the rendering mode.
Run bash scripts/setup.sh from the skill directory to auto-detect, or check manually:
bunffmpegModeNoNoCloud Render -- read cloud-render.mdYesNoCloud Render -- read cloud-render.mdYesYesLocal Render (recommended) -- read local-render.md
VARG_API_KEY is required for all modes. Get one at https://varg.ai
Everything you know about varg is likely outdated. Always verify against this skill and its references before writing code.
Image({...}) creates media, <Clip> composes timeline. Never write <Image prompt="..." />.Video({ prompt: { images: [img] } }) takes exactly one image. Multiple images cause errors.providerOptions: { varg: {...} }, never fal, when going through the gateway (both modes).bash
# Submit TSX code to the render service
curl -s -X POST https://render.varg.ai/api/render \
-H "Authorization: Bearer $VARG_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "const img = Image({ model: fal.imageModel(\"nano-banana-pro\"), prompt: \"a cabin in mountains at sunset\", aspectRatio: \"16:9\" });\nexport default (<Render width={1920} height={1080}><Clip duration={3}>{img}</Clip></Render>);"}'
# Poll for result (repeat until "completed" or "failed")
curl -s https://render.varg.ai/api/render/jobs/JOB_ID \
-H "Authorization: Bearer $VARG_API_KEY"
Full details: cloud-render.md
tsx
/** @jsxImportSource vargai */
import { Render, Clip, Image } from "vargai/react"
import { createVarg } from "@vargai/gateway"
const varg = createVarg({ apiKey: process.env.VARG_API_KEY! })
const img = Image({
model: varg.imageModel("nano-banana-pro"),
prompt: "a cabin in mountains at sunset",
aspectRatio: "16:9"
})
export default (
<Render width={1920} height={1080}>
<Clip duration={3}>{img}</Clip>
</Render>
)
bash
bunx vargai render video.tsx --preview # free preview
bunx vargai render video.tsx --verbose # full render (costs credits)
Full details: local-render.md
For one-off images, videos, speech, or music without building a multi-clip template:
bash
curl -X POST https://api.varg.ai/v1/image \
-H "Authorization: Bearer $VARG_API_KEY" \
-d '{"model": "nano-banana-pro", "prompt": "a sunset over mountains"}'
Full API reference: gateway-api.md
Video code has two layers: media generation (function calls) and composition (JSX).
tsx
// 1. GENERATE media via function calls
const img = Image({ model: ..., prompt: "..." })
const vid = Video({ model: ..., prompt: { text: "...", images: [img] }, duration: 5 })
const voice = Speech({ model: ..., voice: "rachel", children: "Hello!" })
// 2. COMPOSE via JSX tree
export default (
<Render width={1080} height={1920}>
<Music model={...} prompt="upbeat electronic" duration={10} volume={0.3} />
<Clip duration={5}>
{vid}
<Title position="bottom">Welcome</Title>
</Clip>
<Captions src={voice} style="tiktok" withAudio />
</Render>
)
ComponentTypePurposeImage()Function callGenerate still imageVideo()Function callGenerate video (text-to-video or image-to-video)Speech()Function callText-to-speech audio<Render>JSXRoot container -- sets width, height, fps<Clip>JSXTimeline segment -- duration, transitions<Music>JSXBackground audio (always set duration!)<Captions>JSXSubtitle track from Speech<Title>JSXText overlay<Overlay>JSXPositioned layer<Split> / <Grid>JSXLayout helpers
Full props: components.md
Cloud RenderLocal RenderNo imports neededimport { ... } from "vargai/react"``fal.imageModel("nano-banana-pro")``varg.imageModel("nano-banana-pro")``fal.videoModel("kling-v3")``varg.videoModel("kling-v3")``elevenlabs.speechModel("eleven_v3")``varg.speechModel("eleven_v3")Globals are auto-injectedMust call createVarg()
ScenarioUseAuthNew project, simplest setupvarg.*Model() (gateway)VARG_API_KEY onlyExisting project with fal/elevenlabs keysfal.*Model() / elevenlabs.*Model()Individual keysCloud render via curl/APIGateway (only option)VARG_API_KEYNeed $0 billing with own keysGateway + BYOK headersVARG_API_KEY + provider keysSpecific provider feature not in gatewayDirect providerIndividual key
Default recommendation: Use the gateway ( varg.*Model() + VARG_API_KEY). It handles routing, caching, billing, and works with a single key.
--preview generates free placeholders to validate structure.Load these on demand based on what you need:
NeedReferenceWhen to loadRender via APIcloud-render.mdNo bun/ffmpeg, or user wants cloud renderingRender locallylocal-render.mdbun + ffmpeg availablePatterns & workflowsrecipes.mdTalking head, character consistency, slideshow, lipsyncModel selectionmodels.mdChoosing models, checking prices, duration constraintsComponent propscomponents.mdNeed detailed props for any componentBetter promptsprompting.mdUser wants cinematic / high-quality resultsREST APIgateway-api.mdSingle-asset generation or Render API detailsDebuggingcommon-errors.mdSomething failed or produced unexpected resultsFull examplestemplates.mdNeed complete copy-paste-ready templatesBYOK keysbyok.mdUsing your own provider API keys for $0 billing