AI Video
Text-to-video generation with status polling and cancellation.
Overview
Base path:
/v1/videoPython namespace:
ai.videotext
# Python
from infrai import ai
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.videoMethods
video.generate
POST /v1/video/generate
Start a text-to-video generation job.
Python
python
ai.video.generate(prompt, *, reference_image_url=None, duration_seconds=None, aspect=None, resolution="720p", prefer="balanced", model=None, vendor=None, idempotency_key=None)TypeScript
typescript
client.video.generate(opts: VideoGenerateOptions): Promise<VideoJob>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
prompt | string | Required | Text description of the desired video. |
reference_image_url | string | Optional | Optional reference image URL. |
duration_seconds | number | Optional | Clip duration in seconds. |
aspect | "16:9" | "9:16" | "1:1" | Optional | Aspect ratio. |
resolution | "720p" | "1080p" | "4k" | Optional | Output resolution (720p/1080p/4k); gated per vendor. |
prefer | "balanced" | "cheapest" | "smartest" | Optional | Optimization axis: balanced (best value) | cheapest | smartest. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
VideoJob { job_id, state, video_url?, thumbnail_url?, error? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import ai
job = ai.video.generate("a timelapse of a city skyline at dusk",
resolution="1080p", prefer="balanced")
print("job:", job.get("job_id"), "| state:", job.get("state"))video.status
GET /v1/video/jobs/{id}
Poll the status of a video job.
Python
python
ai.video.status(id=job_id)TypeScript
typescript
client.video.status(jobId: string): Promise<VideoJob>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The job identifier. |
Returns
VideoJobExample
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import ai
job = ai.video.status(id="vid_...")
print("state:", job.get("state"), "| url:", job.get("video_url"))video.cancel
POST /v1/video/jobs/{id}/cancel
Cancel a running video job.
Python
python
ai.video.cancel(id=job_id)TypeScript
typescript
client.video.cancel(jobId: string): Promise<{ ok }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The job identifier. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import ai
print("cancelled:", ai.video.cancel(id="vid_...").get("ok"))