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 | |
nano-banana-2 |
image | |
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
tierexplicitly. Pricing is per tier, and asizethat 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
Metadata
Release files for genrelay 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genrelay-0.1.1.tar.gz | 12.3 kB | Without provenance | Details for genrelay-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genrelay-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for genrelay-0.1.1-py3-none-any.whl |
Total release size: 25.1 kB
Release files / genrelay-0.1.1.tar.gz
| Download URL | genrelay-0.1.1.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5117ec69db6b1f54541bcd22698d14b4e7935474e0cf1f513f36121c2dd58003
|
|
BLAKE2b-256 checksum How to use checksums |
4980f59302514420813d1159ecab68aa735bcc3ee5f9bc300d352a56fdfd061b
|
| 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.1-py3-none-any.whl
| Download URL | genrelay-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
180a2d1b663866d12c0a6891079275d95acf930179d79ba3dde7355d07fb30fc
|
|
BLAKE2b-256 checksum How to use checksums |
ddc451535409c440d96c54ae0e093ec6c37f4b0bf5acb78bf90d6bce3a701876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for genrelay 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.