Skip to main content

genrelay-python

Python client for GenRelay — one API for Veo 3.1, Grok Imagine, Nano Banana Pro/2, GPT Image 2 and Omni Flash. Text-to-video, image-to-video, first/last-frame, and image generation.

pip install genrelay

Quick start

from genrelay import GenRelay

client = GenRelay()  # reads GENRELAY_API_KEY

video = client.videos.generate(
    model="veo_3_1",
    prompt="a neon fox running through a rainy city at night",
    seconds=8,
    size="1280x720",
    tier="1080p",
)

client.videos.download(video.id, "fox.mp4")

That's the whole loop: submit, poll with backoff, stream to disk. Generation takes seconds to minutes depending on the model and length.

Why this exists

Chat and image edits on GenRelay are OpenAI-compatible — point the official openai package at https://genrelay.ai/v1 and you're done:

from openai import OpenAI
client = OpenAI(base_url="https://genrelay.ai/v1", api_key="sk-...")

Generation jobs are different: they're asynchronous, with a submit → poll → download cycle that has no equivalent in that SDK. That's what this package handles — the polling loop, the backoff, the terminal-state detection, the streamed download, and typed errors instead of dict-digging.

Async, when you need control

job = client.videos.create(model="veo_3_1", prompt="...", seconds=8)
print(job.id, job.status)          # task_xxx queued

# ... do other work, persist job.id, come back later ...

video = client.videos.wait(job.id, timeout=900)

Watch progress while it runs:

client.videos.generate(
    model="veo_3_1",
    prompt="...",
    on_progress=lambda v: print(f"{v.status} {v.progress}%"),
)

Models

Model Kind Notes
veo_3_1 video Google Veo 3.1
veo_3_1-fl video first/last frame
veo_3_1-components video component-guided
grok-imagine-video-1-5-preview video xAI Grok Imagine 1.5
grok-imagine-1-0-video video Grok Imagine 1.0
omni-flash video fast, long clips
omni_flash_abra_edit video video editing
nano-banana-pro image Google
nano-banana-2 image Google
gpt-image-2 image OpenAI

Current list and per-model options: https://genrelay.ai/models

Parameters

Name Type Notes
model str required
prompt str required
seconds int | str 1–60, default 4. Ignored by image models
size str "1280x720". Aspect ratio is inferred — no separate parameter
tier str 1k/2k/4k (images), 720p/1080p/4k (Veo)
reference_images list[str] HTTPS or data: URLs
metadata dict model-specific extras, e.g. {"first_last_frame": True}

Set tier explicitly. Pricing is per tier, and a size that matches no tier falls back to the model's base rate — which can cost noticeably more than you expected.

Unknown keyword arguments are forwarded as-is, so new API fields work before this client knows about them.

Errors

from genrelay import InsufficientCreditsError, JobFailedError, JobTimeout

try:
    video = client.videos.generate(model="veo_3_1", prompt="...")
except InsufficientCreditsError:
    ...                      # 402 — top up
except JobFailedError as e:
    print(e.video.error)     # model couldn't produce a result
except JobTimeout as e:
    print(e.task_id)         # still running — poll later, don't resubmit

JobTimeout deliberately keeps the task id: resubmitting bills a second time, polling doesn't.

All exceptions derive from GenRelayError.

Configuration

GENRELAY_API_KEY API key, or pass api_key=
GENRELAY_BASE_URL override the endpoint (default https://genrelay.ai/v1)
client = GenRelay(api_key="sk-...", timeout=60.0, max_retries=2)

GenRelay is a context manager and closes its HTTP client on exit. Pass your own httpx.Client via http_client= to control pooling or proxies.

License

MIT

Release files for genrelay 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for genrelay 0.1.0
File Size Uploaded
genrelay-0.1.0.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for genrelay 0.1.0
File Interpreter ABI Platform
genrelay-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.1 kB

Release files / genrelay-0.1.0.tar.gz

Download URL genrelay-0.1.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f9c78cde1b954bab525bef04ba0cca669d8f0a3eb52c87edfb318872e1effae4
BLAKE2b-256 checksum
How to use checksums
75d1ca0d8ef01c4e96bc02bed797aa913b43af6888092e3ba16b81b616764e7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / genrelay-0.1.0-py3-none-any.whl

Download URL genrelay-0.1.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74433441c5c533db2ed8d953431b66b1cd85f894720eae13b4d91e099787059c
BLAKE2b-256 checksum
How to use checksums
2dd27d9166f6f3aa19f2005b49a8d3b9eefbc5ef5acea10d096490c0ef9b4763
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page