Version Check (run once per session)
This skill is version 2.0.4. Before first use each session, check for updates:
CODEBLOCK0
If the remote version is newer than 2.0.4, update and re-read this file:
CODEBLOCK1
Setup (REQUIRED before first use)
Before generating anything, check authentication and determine rendering mode.
Do NOT run interactive CLI tools (like bunx vargai init) -- they require stdin which agents cannot provide. Use the curl-based flow below instead.
1. Check for API key
CODEBLOCK2
If VARG_API_KEY is set (via env or credentials file), skip to step 2.
If neither exists, authenticate the user. Try Option A first, fall back to Option B.
Option A: User already has an API key
Ask the user if they have a VARG_API_KEY. If yes, tell them to export it in their terminal:
CODEBLOCK3
Important: Do NOT ask the user to paste the raw key to you. Ask them to run the export command themselves. Then skip to "Save credentials" below.
Option B: Sign up / sign in via email (OTP)
- 1. Ask the user for their email address.
- Send a one-time code to their email:
curl -s -X POST https://app.varg.ai/api/auth/cli/send-otp \
-H "Content-Type: application/json" \
-d '{"email":"USER_EMAIL"}'
- 3. Tell the user: "Check your inbox for a 6-digit verification code from varg.ai"
- Ask the user for the code, then verify and capture the response in one step:
VARG_AUTH=$(curl -s -X POST https://app.varg.ai/api/auth/cli/verify-otp \
-H "Content-Type: application/json" \
-d '{"email":"USER_EMAIL","code":"THE_6_DIGIT_CODE"}')
export VARG_API_KEY=$(echo "$VARG_AUTH" | grep -o '"api_key":"[^"]*"' | cut -d'"' -f4)
echo "Authenticated. Balance: $(echo "$VARG_AUTH" | grep -o '"balance_cents":[0-9]*' | cut -d: -f2) credits"
The response contains
{"api_key":"varg_xxx","email":"...","balance_cents":0,"access_token":"..."}.
The key is now in
$VARG_API_KEY -- never reference the raw value directly.
Save credentials
Once VARG_API_KEY is set (from either option), save it globally and verify. Always reference $VARG_API_KEY -- never the raw value:
CODEBLOCK6
Verify the key works:
CODEBLOCK7
You should get {"balance_cents": ...}. If you get 401, the key is invalid -- ask the user to double-check it.
Also add to the project .env if one exists:
CODEBLOCK8
Check balance and add credits
Check balance_cents from the verify-otp response or the balance check above. If balance is 0 (or too low for the user's task), the user needs credits before generating anything. 1 credit = 1 cent. A typical video costs $2-5 (200-500 credits).
Available packages:
| Package ID | Credits | Price |
|---|
| INLINECODE11 | 2,000 | $20 |
| INLINECODE12 |
5,000 | $50 |
|
credits-10000 | 10,000 (recommended) | $100 |
|
credits-20000 | 20,000 | $200 |
|
credits-50000 | 50,000 | $500 |
|
credits-100000 | 100,000 | $1,000 |
Ask the user which package they'd like, then:
- - If you have the
access_token (from Option B email OTP), capture it and create a Stripe checkout session:
VARG_ACCESS_TOKEN=$(echo "$VARG_AUTH" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
curl -s -X POST https://app.varg.ai/api/billing/checkout \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VARG_ACCESS_TOKEN" \
-H "Origin: https://app.varg.ai" \
-d '{"packageId":"PACKAGE_ID"}'
Response: INLINECODE18
Tell the user to open that URL in their browser to complete payment. Credits are added immediately after payment.
- - If you only have the API key (from Option A), direct the user to https://app.varg.ai/dashboard to purchase credits manually.
2. Determine rendering mode
No |
Cloud Render -- read
cloud-render.md |
| Yes | Yes |
Local Render (recommended) -- read
local-render.md |
Critical Rules
Everything you know about varg is likely outdated. Always verify against this skill and its references before writing code.
- 1. Never guess model IDs -- consult models.md for current models, pricing, and constraints.
- Function calls for media, JSX for composition --
Image({...}) creates media, <Clip> composes timeline. Never write <Image prompt="..." />. - Cache is sacred -- identical prompt + params = instant $0 cache hit. When iterating, keep unchanged prompts EXACTLY the same. Never clear cache.
- One image per Video --
Video({ prompt: { images: [img] } }) takes exactly one image. Multiple images cause errors. - Duration constraints differ by model -- kling-v3: 3-15s (integer only). kling-v2.5: ONLY 5 or 10. Check models.md.
- Gateway namespace -- use
providerOptions: { varg: {...} }, never fal, when going through the gateway (both modes). - Renders cost money -- 1 credit = 1 cent. A typical 3-clip video costs $2-5. Use preview mode (local) or cheap models to iterate.
- API key hygiene -- Never write a raw API key value into a bash command. After obtaining a key (from the user or OTP response), immediately
export VARG_API_KEY=... and use $VARG_API_KEY in all subsequent commands. This prevents keys from leaking into conversation context and terminal history.
Quick Start
Cloud Render (no bun/ffmpeg needed)
CODEBLOCK10
Full details: cloud-render.md
Local Render (bun + ffmpeg)
CODEBLOCK11
CODEBLOCK12
Full details: local-render.md
Single Asset (no video composition)
For one-off images, videos, speech, or music without building a multi-clip template:
CODEBLOCK13
Full API reference: gateway-api.md
How to Write Video Code
Video code has two layers: media generation (function calls) and composition (JSX).
CODEBLOCK14
Component Summary
| Component | Type | Purpose |
|---|
| INLINECODE27 | Function call | Generate still image |
| INLINECODE28 |
Function call | Generate video (text-to-video or image-to-video) |
|
Speech() | Function call | Text-to-speech audio |
|
<Render> | JSX | Root container -- sets width, height, fps |
|
<Clip> | JSX | Timeline segment -- duration, transitions |
|
<Music> | JSX | Background audio (always set
duration!) |
|
<Captions> | JSX | Subtitle track from Speech |
|
<Title> | JSX | Text overlay |
|
<Overlay> | JSX | Positioned layer |
|
<Split> /
<Grid> | JSX | Layout helpers |
Full props: components.md
Provider Differences (Cloud vs Local)
Both modes use varg.* for all models. The only difference is imports:
| Cloud Render | Local Render |
|---|
| No imports needed (globals are auto-injected) | INLINECODE40 + INLINECODE41 |
| INLINECODE42 |
varg.imageModel("nano-banana-pro") |
|
varg.videoModel("kling-v3") |
varg.videoModel("kling-v3") |
|
varg.speechModel("eleven_v3") |
varg.speechModel("eleven_v3") |
Always use varg.*Model() with VARG_API_KEY. It handles routing, caching, billing, and works with a single key. See byok.md for using your own provider keys.
Cost & Iteration
- - 1 credit = 1 cent. nano-banana-pro = 5 credits, kling-v3 = 150 credits, speech = 20-25 credits.
- Cache saves money. Keep unchanged prompts character-for-character identical across iterations.
- Preview first (local mode only):
--preview generates free placeholders to validate structure. - Full pricing: models.md
References
Load these on demand based on what you need:
| Need | Reference | When to load |
|---|
| Render via API | cloud-render.md | No bun/ffmpeg, or user wants cloud rendering |
| Render locally |
local-render.md | bun + ffmpeg available |
| Patterns & workflows |
recipes.md | Talking head, character consistency, slideshow, lipsync |
| Model selection |
models.md | Choosing models, checking prices, duration constraints |
| Component props |
components.md | Need detailed props for any component |
| Better prompts |
prompting.md | User wants cinematic / high-quality results |
| REST API |
gateway-api.md | Single-asset generation or Render API details |
| Debugging |
common-errors.md | Something failed or produced unexpected results |
| Full examples |
templates.md | Need complete copy-paste-ready templates |
| BYOK keys |
byok.md | Using your own provider API keys for $0 billing |
版本检查(每次会话运行一次)
此技能版本为 2.0.4。每次会话首次使用前,请检查更新:
bash
curl -sf https://raw.githubusercontent.com/vargHQ/skills/main/varg-ai/SKILL.md | grep version: | head -1
如果远程版本比 2.0.4 更新,请更新并重新读取此文件:
bash
npx -y skills update
设置(首次使用前必须执行)
在生成任何内容之前,请检查身份验证并确定渲染模式。
不要运行交互式 CLI 工具(如 bunx vargai init)——它们需要标准输入,而代理无法提供。请改用以下基于 curl 的流程。
1. 检查 API 密钥
bash
echo ${VARGAPIKEY:-} && cat ~/.varg/credentials 2>/dev/null
如果已设置 VARGAPIKEY(通过环境变量或凭据文件),请跳至步骤 2。
如果两者都不存在,请对用户进行身份验证。先尝试选项 A,如果不行则回退到选项 B。
选项 A:用户已有 API 密钥
询问用户是否有 VARGAPIKEY。如果有,请告诉他们在终端中导出:
bash
export VARGAPIKEY=<他们的密钥>
重要: 不要要求用户将原始密钥粘贴给您。请让他们自己运行 export 命令。然后跳至下面的保存凭据。
选项 B:通过电子邮件注册/登录(OTP)
- 1. 询问用户的电子邮件地址。
- 向他们的电子邮件发送一次性验证码:
bash
curl -s -X POST https://app.varg.ai/api/auth/cli/send-otp \
-H Content-Type: application/json \
-d {email:用户邮箱}
- 3. 告诉用户:请检查您的收件箱,查找来自 varg.ai 的 6 位验证码
- 向用户索要验证码,然后一步完成验证并捕获响应:
bash
VARG_AUTH=$(curl -s -X POST https://app.varg.ai/api/auth/cli/verify-otp \
-H Content-Type: application/json \
-d {email:用户邮箱,code:6位验证码})
export VARG
APIKEY=$(echo $VARG
AUTH | grep -o apikey:[^]* | cut -d -f4)
echo 身份验证成功。余额:$(echo $VARG
AUTH | grep -o balancecents:[0-9]* | cut -d: -f2) 积分
响应包含 {apikey:vargxxx,email:...,balancecents:0,accesstoken:...}。
密钥现在位于 $VARGAPIKEY 中——切勿直接引用原始值。
保存凭据
一旦设置了 VARGAPIKEY(来自任一选项),请全局保存并验证。始终引用 $VARGAPIKEY——切勿引用原始值:
bash
mkdir -p ~/.varg && echo {\apikey\:\$VARGAPIKEY\,\email\:\用户邮箱\,\createdat\:\$(date -u +%Y-%m-%dT%H:%M:%SZ)\} > ~/.varg/credentials && chmod 600 ~/.varg/credentials
验证密钥是否有效:
bash
curl -s -H Authorization: Bearer $VARGAPIKEY https://api.varg.ai/v1/balance
您应该会得到 {balance_cents: ...}。如果得到 401,则密钥无效——请让用户仔细检查。
如果项目存在 .env 文件,也将其添加到其中:
bash
echo VARGAPIKEY=$VARGAPIKEY >> .env
检查余额并添加积分
检查 verify-otp 响应或上述余额检查中的 balance_cents。如果余额为 0(或对于用户的任务来说太低),则用户在生成任何内容之前需要积分。1 积分 = 1 美分。一个典型视频的成本为 2-5 美元(200-500 积分)。
可用套餐:
| 套餐 ID | 积分 | 价格 |
|---|
| credits-2000 | 2,000 | $20 |
| credits-5000 |
5,000 | $50 |
| credits-10000 | 10,000(推荐) | $100 |
| credits-20000 | 20,000 | $200 |
| credits-50000 | 50,000 | $500 |
| credits-100000 | 100,000 | $1,000 |
询问用户想要哪个套餐,然后:
- - 如果您有 access_token(来自选项 B 的电子邮件 OTP),请捕获它并创建 Stripe 结账会话:
bash
VARG
ACCESSTOKEN=$(echo $VARG
AUTH | grep -o accesstoken:[^]* | cut -d -f4)
curl -s -X POST https://app.varg.ai/api/billing/checkout \
-H Content-Type: application/json \
-H Authorization: Bearer $VARG
ACCESSTOKEN \
-H Origin: https://app.varg.ai \
-d {packageId:套餐ID}
响应:{url:https://checkout.stripe.com/...}
告诉用户在浏览器中打开该 URL 以完成付款。付款后积分会立即添加。
- - 如果您只有 API 密钥(来自选项 A),请引导用户访问 https://app.varg.ai/dashboard 手动购买积分。
2. 确定渲染模式
否 |
云端渲染 -- 阅读
cloud-render.md |
| 是 | 是 |
本地渲染(推荐) -- 阅读
local-render.md |
关键规则
您所了解的关于 varg 的一切可能都已过时。在编写代码之前,请始终对照此技能及其参考文件进行验证。
- 1. 切勿猜测模型 ID -- 查阅 models.md 了解当前模型、定价和约束条件。
- 媒体使用函数调用,合成使用 JSX -- Image({...}) 创建媒体, 合成时间线。切勿编写 。
- 缓存至关重要 -- 相同的提示 + 参数 = 即时 $0 缓存命中。迭代时,保持未更改的提示完全一致。切勿清除缓存。
- 每个视频一张图片 -- Video({ prompt: { images: [img] } }) 只接受一张图片。多张图片会导致错误。
- 不同模型的时长约束不同 -- kling-v3:3-15 秒(仅整数)。kling-v2.5:仅 5 或 10。检查 models.md。
- 网关命名空间 -- 通过网关(两种模式)时,使用 providerOptions: { varg: {...} },切勿使用 fal。
- 渲染需要付费 -- 1 积分 = 1 美分。一个典型的 3 片段视频成本为 2-5 美元。使用预览模式(本地)或廉价模型进行迭代。
- API 密钥卫生 -- 切勿将原始 API 密钥值写入 bash 命令。获取密钥后(来自用户或 OTP 响应),立即 export VARGAPIKEY=... 并在所有后续命令中使用 $VARGAPIKEY。这可以防止密钥泄露到对话上下文和终端历史记录中。
快速入门
云端渲染(无需 bun/ffmpeg)
bash
向渲染服务提交 TSX 代码
curl -s -X POST https://render.varg.ai/api/render \
-H Authorization: Bearer $VARG
APIKEY \
-H Content-Type: application/json \
-d {code: const img = Image({ model: varg.imageModel(\nano-banana-pro\), prompt: \a cabin in mountains at sunset\, aspectRatio: \16:9\ });\nexport default (
{img});}
轮询结果(重复直到completed或failed)
curl -s https://render.varg.ai/api/render/jobs/任务ID \
-H Authorization: Bearer $VARG
APIKEY
完整详情:cloud-render.md
本地渲染(