s3.varg.ai, and transparent credit billing.
Base URL
Authentication
All requests (exceptGET /pricing) require a varg API key:
bunx vargai login. See Authentication for details.
Core concepts
The API vocabulary has three levels:
Tools:
image, video, speech, music, transcription, ffmpeg, render, pipeline. Discover them at runtime via GET /v2/tools.
Quick start
Every generation is an async job: create it, poll until terminal, read the output URL.Job lifecycle
Poll
GET /v2/jobs/{id} (full view) or GET /v2/jobs/{id}/status (lightweight, includes progress 0..1 and progress_message). A stuck job is guaranteed to reach a terminal status — the platform times out jobs after 30 minutes.
Request format
All generation endpoints take a flat JSON body:model plus tool-specific fields at the top level.
Media inputs are always passed by URL — upload local files first via
POST /v2/files to get a stable varg URL.
Model resolution
Most requests should just use the model name. Pass a canonical varg name (seedance_2, kling_v3, flux_schnell) and varg auto-routes by priority and input shape — if your request includes files, routes that map files are preferred; the first route whose schema accepts your input wins.
- Provider prefix — same auto-routing, restricted to routes on that provider.
- Exact
model_key— pins one specific route.model_keyvalues are a permanent public contract and safe to hardcode.
model_key is listed in GET /v2/models.
Two guarantees:
- No silent substitution. varg only picks which route serves the model you named — never a different model family.
- Transparent routing. The job records which provider model actually ran (
provider,provider_modelfields), andPOST /v2/estimatereturns theresolved_model_keybefore you submit.
files to kling_v3 routes to its image-to-video endpoint. Same family, same pricing rules.
Model ids use underscores (kling_v3, flux_schnell). Dashed spellings (kling-v3) are accepted and normalized automatically. Browse all models and prices at GET /v2/pricing (public, no auth).
Model catalog
GET /v2/models (public, no auth) returns the full catalog: every model with its routes, pricing, and operational hints. Filter by tool with ?tool=video.
model_key can be used directly in the model field to pin that route.
Discovering schemas at runtime
Agents and dynamic clients can discover the full API without reading docs:Pricing and billing
1 credit = 1 cent = $0.01. The billing flow:- Reserve — at job creation, the estimated cost is held from your balance (402 if insufficient).
- Commit — on completion, the hold is charged and a usage record written.
- Release — on failure, the hold is returned (most models; some bill partial work).
pricing.estimated, pricing.actual, pricing.billed_units (e.g. {"seconds": 6}), and a pricing_id that pins the price rule the job was charged under — mid-flight price changes never affect running jobs.
Caching
Results are cached by canonical input. Repeating an identical request returns a completed job instantly withactual_cost_cents: 0 and pricing.cached: true — cache hits are free.
Idempotency
Pass anIdempotency-Key header on any job-creating POST to make retries safe:
202). Retrying with the same key returns the same job (200) — no duplicate charge, no duplicate generation.
Files and lineage
Outputs are mirrored to varg storage and served from stables3.varg.ai URLs. Every output gets a file record with an AI-generated title, a thumbnail, and lineage back to the job that created it:
X-Content-Hash: sha256:<hex> on upload for content deduplication, or pre-check with GET /v2/files/check?hash=.
Error format
All errors use one envelope:model_not_found errors include suggestions in details: did_you_mean lists close model names, and models_url points to /v2/models for the full catalog.Rate limits
Rate limiting is a sliding window per API key. Every job-creation response carries:Retry-After seconds and retry (ideally with the same Idempotency-Key).
Migrating from v1
The v1 gateway (api.varg.ai/v1) is frozen. Key differences in v2: