Skip to main content
This page provides complete context for AI agents (Claude, GPT, Cursor, etc.) to help users create videos with varg. If you’re a human, you might prefer the Quickstart guide.

What is varg?

varg is a JSX-based AI video generation platform. Users write React-like code to describe video compositions, and varg handles AI generation (images, video, voice, music) and final video rendering. Everything goes through one API (api.varg.ai), one API key. For the best agent experience, install the varg skill which includes 10 reference docs, setup scripts, and auto-update:

Required Environment

Get a key at app.varg.ai. This single key provides access to all AI providers (images, video, speech, music, lipsync) through the varg API.
If the user doesn’t have a key, you can drive the OTP login flow with curl. See Authentication for the agent-driven login flow.

Two Rendering Modes

Minimal Working Example (Local Render)

Render: bunx vargai render video.tsx --verbose

Minimal Working Example (Cloud Render)

Cloud render uses fal.*Model() syntax — globals are auto-injected. Local render uses varg.*Model() via createVarg().

All Components

Critical: Image(), Video(), Speech() are function calls that return references. <Music>, <Captions>, <Title> are JSX components. Never write <Image prompt="..." />.

All AI Models

Image Models

Video Models

Lipsync Models

Audio Models

Voices

Import Statement (Local Render)

Common Patterns

Character Consistency

Transitions Between Clips

Caption Styles

Zoom Effects

Aspect Ratios

Template: Simple Slideshow

Template: Talking Character

Template: Before/After Transformation

Media Processing (FFmpeg)

Cloud-hosted FFmpeg for video manipulation — no local install needed. One endpoint (POST /v2/ffmpeg), the operation is selected by the model field. All operations return a job — poll GET /v2/jobs/{id} until completed.

Probe

Inspect a video or audio file — returns metadata synchronously (not a job).
Returns: { url, media_type, width, height, duration_ms, duration, metadata }

Trim

Cut a segment. Provide start + either end or duration. Set precise: true for frame-accurate cuts.

Resize

Scale to new dimensions. At least one of width/height required. Fit modes: cover (default, crop overflow), contain (letterbox), stretch.

Slice

Split a video into segments. Modes: every (interval), at (timestamps), count (equal parts), ranges (explicit ranges).

Custom FFmpeg Command

Run any FFmpeg command. Use {{in_N}}/{{out_N}} placeholders mapped through input_files/output_files.
All FFmpeg operations cost ~6 credits per call. Outputs land in output.outputs[] on the completed job.

Common Errors and Solutions

CLI Commands

Cost Reference

1 credit = 1 cent. Cache hits are always free. Typical 3-clip video: $2-5. Discover models and routes (no auth): GET https://api.varg.ai/v2/models (filter with ?tool=video). Live price catalog (no auth): GET https://api.varg.ai/v2/pricing. Price any request without running it: POST https://api.varg.ai/v2/estimate — the response includes resolved_model_key, the exact route the request would run on.

File Structure

Tips for Best Results

  1. One API key: Use VARG_API_KEY with createVarg() — no need for individual provider keys
  2. Character consistency: Use soul for characters, or generate once with nano-banana-pro and reference in all scenes
  3. Video quality: kling-v3 for best quality, wan-2.5 for characters
  4. Lipsync: Works best with frontal face, clear audio, 5-10 second clips
  5. Caching: Same props = instant $0. Even slightly different prompt = full regeneration
  6. Music volume: Keep at 0.1-0.3 for background, voices at 1.0
  7. Duration: kling-v3 needs integer 3-15s. kling-v2.5 needs exactly 5 or 10. seedance_2 accepts integer 4-15 (fal routes also accept “auto”).