Python client for the Varya video generation API
Project description
varya-avataar (Python)
Python client for the Varya video generation API. Submit a text (or image) prompt, and the client handles the async job lifecycle — submit, poll, and download — for you.
Install
pip install varya-avataar
Installs as
varya-avataaron PyPI but imports asvarya:from varya import VaryaClient.
Requires Python 3.8+ and [requests](https://pypi.org/project/requests/).
Authentication
Create a key in the Varya web app (Account menu → API key). It looks like
sk_live_…. Keep it secret; it draws down your account's credit balance.
export VARYA_API_KEY=sk_live_xxxxx
Quick start
from varya import VaryaClient
client = VaryaClient(api_key="sk_live_xxxxx")
result = client.generate_video(
"A snow leopard prowling the Himalayan slopes at dawn",
resolution="480p", # "480p" | "720p"
duration=5, # seconds, 1–5
on_status=print, # optional progress callback
)
print(result["video_url"])
client.download(result["video_url"], "out.mp4")
For a full end-to-end walkthrough (text-to-video and image-to-video, saving the output, error handling), see USAGE.md.
VaryaClient is also a context manager (with VaryaClient(...) as client:)
which closes the underlying HTTP session on exit.
CLI
Installing the package also installs a varya command:
# create a new video and download it
varya "a cat surfing a wave" --resolution 720p --output out.mp4
# resume / fetch an existing generation (no prompt, nothing re-charged)
varya --get gen_xxxxxxxx --output out.mp4
Run varya --help for all flags (--duration, --resolution, --style,
--seed, --enhance, --image, --timeout, …).
The key is read from --key or $VARYA_API_KEY; the base URL from
--base-url or $VARYA_BASE_URL.
API
VaryaClient(api_key, base_url=..., auth_scheme="x-api-key", connect_timeout=15, read_timeout=60)
| Method | Description |
|---|---|
generate_video(prompt, **opts) |
Submit and wait. Returns the final result dict. The 90% path. |
submit(prompt, **opts) |
POST /api/generations; returns { generation_id, status, credits_charged, … } without waiting. |
status(generation_id) |
GET /generations/{id}; current status/result. |
wait(generation_id, poll_interval=2, timeout=600, on_status=None) |
Poll until completed/failed. |
download(url, dest) |
Stream a finished video URL to a local file. |
Generation options (for generate_video / submit): resolution
("480p" / "720p"), duration (1–5 s), style, seed, enhance,
image_path (image-to-video). The output is always watermarked.
Single-clip only: the client targets the streamlined
POST /api/generationsendpoint, so there is no compare / long-form / continuation mode andfpsis fixed server-side.durationmust be 1–5 (out-of-range raisesLONG_FORM_NOT_SUPPORTEDbefore any request is sent).
Result shape
- completed:
{ "status": "completed", "video_url": "https://…" } - failed:
{ "status": "failed", "error": "…", "error_code": "…" }
Errors
Business/API failures raise VaryaError with a .code and .status:
from varya import VaryaError
try:
client.generate_video("…")
except VaryaError as e:
if e.code == "INSUFFICIENT_CREDITS":
... # top up
elif e.code == "NSFW_CONTENT_BLOCKED":
... # adjust the prompt/image
else:
raise
Notes
- Seed. A
seedis always sent. When you don't pass one it's randomized client-side (in[100, 1_000_000), matching the web app) and returned on the result asseed, so you can reproduce a run by passing that sameseedback. - Async by design. Jobs are queued; the client polls every ~2s — raise
timeoutif a job needs longer. - Resilient polling. One keep-alive connection is reused, idempotent
GETs are retried with backoff, and transient network blips don't abort a run.POST /api/generationsis never auto-retried, so a job is never double-charged. - Auth header. Defaults to
X-API-Key. If your deployment expectsAuthorization: Bearer, passauth_scheme="bearer". - Cost. 1 credit (480p) / 2 (720p). The exact charge is returned as
credits_charged.
Development
pip install -e ".[dev]"
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file varya_avataar-0.1.2.tar.gz.
File metadata
- Download URL: varya_avataar-0.1.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
debd39cda31e1bd31ef3fd0e980f6a832228b7622140d94bcab427ee04de73a9
|
|
| MD5 |
68c594d51a92ac3522c7267ac16d92de
|
|
| BLAKE2b-256 |
4a083848116abf6cab0e9c383d4ae614022c67842b3356b29df127c0020c9e92
|
File details
Details for the file varya_avataar-0.1.2-py3-none-any.whl.
File metadata
- Download URL: varya_avataar-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98db2b7a80a5c9555839b63adac2863da668902bb59f64515997a8f37595f6fb
|
|
| MD5 |
8813c741bba1f72fb27160c71d2562ce
|
|
| BLAKE2b-256 |
e6487791ed2375ed4cde8ab527ea10a720557aa9bb10a775bf9c1624e57c5af1
|