# Generate video from text prompts

> OpenGen routes text-to-video prompts across 25 exact video model variants using one canonical schema for resolution, duration, aspect ratio, and native audio. Inspect regional endpoints and published per-second or token pricing via GET /v1/models/{provider}/{model}, verify spend with POST /v1/pricing/estimate, submit once with a persisted Idempotency-Key, and stream or poll private delivery progress without risking duplicate charges.

## Agent Prompt

```text
Walk me through a text-to-video generation on OpenGen (https://opengen.dev):
1. Discover video models via GET https://opengen.dev/v1/models?operation=text-to-video (or MCP find_models with operation="text-to-video").
2. Inspect the exact model's resolutions, integer duration bounds, native audio policy, regional endpoints, privacy disclosures, and published pricing via GET https://opengen.dev/v1/models/{provider}/{model}?operation=text-to-video (or MCP get_model, e.g. id="alibaba/wan-3.0", operation="text-to-video").
3. Run a stateless dry-run estimate with POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) and present the selected regional route, estimatedCostMicros, recommendedMaxCostMicros, and workspaceEligibility.
4. Wait for my confirmation of the route and maxCostMicros spend ceiling before submitting.
5. Persist a unique Idempotency-Key and submit once via POST https://opengen.dev/v1/generations or MCP generate, then follow progress via GET https://opengen.dev/v1/generations/{id}/status (or /events SSE) or MCP job_get(id, afterRevision, waitMs=25000) without ever creating a second Idempotency-Key.
```

OpenGen `text-to-video` turns a text prompt into a private MP4 clip across 25 exact video variants while keeping regional endpoints, native audio policies, and per-second or token pricing explicit before you spend.

## 1. Compare exact video variants and regional routes

Video models differ sharply in resolution tiers, duration ranges, audio support (`switchable`, `always-on`, or `unsupported`), and regional endpoints:

- [Wan 3.0](/alibaba/wan-3.0) (`alibaba/wan-3.0`): official Singapore route `alibaba/ap-southeast-1/wan-3.0` is live-verified for `text-to-video` and `image-to-video` at `480p` / `2s` (higher resolutions and longer durations remain documented), supporting `480p`/`720p`/`1080p`, `2`–`30` seconds (or `"auto"`), switchable audio, and published per-second tariffs of `$0.05/s` at `480p`, `$0.10/s` at `720p`, and `$0.20/s` at `1080p`.
- [Kling 4.0](/kling/kling-4.0) (`kling/kling-4.0`): live-verified for `text-to-video` at `720p` / `3s` on `kling-ap-southeast-1/kling-kling-4.0` and `runway-undisclosed/kling-kling-4.0` (other resolutions and durations remain documented), supporting `720p`/`1080p`/`4K`, `3`–`30` seconds, always-on native audio, and multi-shot `shots` arrays.
- [FLUX 3 Video](/bfl/flux-3-video) (`bfl/flux-3-video`): live-verified for `text-to-video` at `720p` / `5s` on `bfl-undisclosed/bfl-flux-3-video` (higher resolutions and other durations remain documented), supporting `720p`–`2160p`, `5`–`20` seconds (or `"auto"`), and switchable audio.
- [Seedance 2.5](/bytedance/seedance-2.5) (`bytedance/seedance-2.5`): `480p`–`1080p`, `4`–`30` seconds, with optional `draft` preview mode (`480p` with `audio: false`) and `codec`/`bitrateMode` controls on compatible routes.

```bash tab="cURL"
# List text-to-video models (filter by region or collection if needed)
curl --fail-with-body \
  "https://opengen.dev/v1/models?operation=text-to-video&region=ap-southeast-1"

# Inspect Wan 3.0 schema, regional deployments, privacy disclosures, and pricing
curl --fail-with-body \
  "https://opengen.dev/v1/models/alibaba/wan-3.0?operation=text-to-video"
```

```ts tab="TypeScript"
const origin = process.env.OPENGEN_API_URL ?? 'https://opengen.dev';
const detail = await fetch(`${origin}/v1/models/alibaba/wan-3.0?operation=text-to-video`).then(
  (r) => r.json(),
);
console.log(
  detail.routes.map((r: { id: string; status: string }) => ({ id: r.id, status: r.status })),
);
```

```python tab="Python"
import os
import httpx

origin = os.environ.get("OPENGEN_API_URL", "https://opengen.dev")
with httpx.Client(timeout=30.0) as client:
    detail = client.get(
        f"{origin}/v1/models/alibaba/wan-3.0",
        params={"operation": "text-to-video"},
    ).raise_for_status().json()
    print([(r["id"], r["status"]) for r in detail["routes"]])
```

```json tab="MCP"
{
  "tool": "get_model",
  "arguments": {
    "id": "alibaba/wan-3.0",
    "operation": "text-to-video"
  }
}
```

```bash tab="CLI"
opengen catalog search --operation text-to-video --region ap-southeast-1
opengen catalog get alibaba/wan-3.0
opengen pricing --model alibaba/wan-3.0 --operation text-to-video
```

> [!NOTE]
> Endpoint location (`ap-southeast-1`, `us-east-1`, `eu-central-1`) is distinct from inference scope and storage residency. Always inspect each route's `privacyDisclosure` object from `GET /v1/models/{provider}/{model}` and see [Regional Routing](/docs/regional-routing).

## 2. Estimate cost and pin your regional route

Validate your exact payload with `POST /v1/pricing/estimate` before submitting. Pin a specific `routeId` (or narrow allowed providers and regions via `routing`) so OpenGen never routes outside your residency or cost policy.

```bash tab="cURL"
set -eu
umask 077
if [ -e t2v-submission.key ]; then
  echo "Existing t2v-submission.key found; recover read-only via GET /v1/generations/lookup before replacing t2v-request.json." >&2
  exit 1
fi
rm -f t2v-request.json
cat <<'JSON' > t2v-request.json
{
  "modelId": "alibaba/wan-3.0",
  "operation": "text-to-video",
  "input": {
    "prompt": "A wooden ferry crossing a misty fjord at dawn, slow aerial tracking shot, crisp ripples on dark blue water.",
    "resolution": "720p",
    "duration": 5,
    "aspectRatio": "16:9",
    "audio": true
  },
  "routeId": "alibaba/ap-southeast-1/wan-3.0",
  "billing": "managed",
  "maxCostMicros": 600000
}
JSON
chmod 600 t2v-request.json

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/pricing/estimate" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  --data @t2v-request.json
```

```ts tab="TypeScript"
const origin = process.env.OPENGEN_API_URL ?? 'https://opengen.dev';
const t2vPayload = {
  modelId: 'alibaba/wan-3.0',
  operation: 'text-to-video',
  input: {
    prompt:
      'A wooden ferry crossing a misty fjord at dawn, slow aerial tracking shot, crisp ripples on dark blue water.',
    resolution: '720p',
    duration: 5,
    aspectRatio: '16:9',
    audio: true,
  },
  routeId: 'alibaba/ap-southeast-1/wan-3.0',
  billing: 'managed',
  maxCostMicros: 600000,
} as const;

const estimate = await fetch(`${origin}/v1/pricing/estimate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.OPENGEN_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(t2vPayload),
}).then((r) => r.json());
console.log(estimate);
```

```python tab="Python"
import os
import httpx

origin = os.environ.get("OPENGEN_API_URL", "https://opengen.dev")
t2v_payload = {
    "modelId": "alibaba/wan-3.0",
    "operation": "text-to-video",
    "input": {
        "prompt": "A wooden ferry crossing a misty fjord at dawn, slow aerial tracking shot, crisp ripples on dark blue water.",
        "resolution": "720p",
        "duration": 5,
        "aspectRatio": "16:9",
        "audio": True,
    },
    "routeId": "alibaba/ap-southeast-1/wan-3.0",
    "billing": "managed",
    "maxCostMicros": 600000,
}

with httpx.Client(timeout=30.0) as client:
    estimate = client.post(
        f"{origin}/v1/pricing/estimate",
        headers={"Authorization": f"Bearer {os.environ['OPENGEN_API_KEY']}"},
        json=t2v_payload,
    ).raise_for_status().json()
    print(estimate)
```

```json tab="MCP"
{
  "tool": "estimate_cost",
  "arguments": {
    "modelId": "alibaba/wan-3.0",
    "operation": "text-to-video",
    "input": {
      "prompt": "A wooden ferry crossing a misty fjord at dawn, slow aerial tracking shot, crisp ripples on dark blue water.",
      "resolution": "720p",
      "duration": 5,
      "aspectRatio": "16:9",
      "audio": true
    },
    "routeId": "alibaba/ap-southeast-1/wan-3.0",
    "billing": "managed",
    "maxCostMicros": 600000
  }
}
```

```bash tab="CLI"
opengen pricing estimate --input t2v-request.json
```

## 3. Submit once and follow asynchronous progress

Video jobs run asynchronously on OpenGen's durable worker pool. Persist your `Idempotency-Key` and request body before calling `POST /v1/generations`. Save the returned `job.id` immediately, then follow progress via long-polling (`GET /v1/generations/{id}/status?waitMs=25000`), Server-Sent Events (`GET /v1/generations/{id}/events`), or a per-request [Ed25519 webhook](/docs/guides/webhooks-nextjs).

```bash tab="cURL"
set -eu
umask 077
if [ -e t2v-submission.key ]; then
  echo "Existing t2v-submission.key found; recover read-only via GET /v1/generations/lookup before creating a new submission." >&2
  exit 1
fi
RAW_UUID="$(uuidgen)"
[ -n "$RAW_UUID" ] || { echo "uuidgen failed" >&2; exit 1; }
IDEMPOTENCY_KEY="t2v-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > t2v-submission.key)

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/generations" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  --data @t2v-request.json > t2v-receipt.json

# Stream real-time job lifecycle updates over SSE
JOB_ID="$(jq -r '.id' t2v-receipt.json)"
curl -N \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Accept: text/event-stream" \
  "https://opengen.dev/v1/generations/$JOB_ID/events"
```

```ts tab="TypeScript"
import { randomUUID } from 'node:crypto';
import { writeFile } from 'node:fs/promises';

const idempotencyKey = `t2v-${randomUUID()}`;
// flag: 'wx' refuses to overwrite an existing unresolved submission record.
await writeFile(
  't2v-submission.json',
  JSON.stringify({ idempotencyKey, payload: t2vPayload }, null, 2),
  { mode: 0o600, flag: 'wx' },
);
const auth = { Authorization: `Bearer ${process.env.OPENGEN_API_KEY}` };

const acceptRes = await fetch(`${origin}/v1/generations`, {
  method: 'POST',
  headers: { ...auth, 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey },
  body: JSON.stringify(t2vPayload),
});
if (!acceptRes.ok)
  throw new Error(`Generation failed (${acceptRes.status}): ${await acceptRes.text()}`);
const accepted = await acceptRes.json();

let current = accepted;
while (
  ['queued', 'submitting', 'running'].includes(current.status) ||
  (current.status === 'succeeded' && current.deliveryStatus === 'pending')
) {
  const qs = new URLSearchParams({ waitMs: '25000' });
  if (current.revision) qs.set('afterRevision', current.revision);
  const pollRes = await fetch(`${origin}/v1/generations/${accepted.id}/status?${qs}`, {
    headers: auth,
  });
  if (!pollRes.ok)
    throw new Error(`Status poll failed (${pollRes.status}): ${await pollRes.text()}`);
  const poll = await pollRes.json();
  current = poll.job ?? poll;
}

const completedRes = await fetch(`${origin}/v1/generations/${accepted.id}`, {
  headers: auth,
});
if (!completedRes.ok) {
  throw new Error(`Job detail failed (${completedRes.status}): ${await completedRes.text()}`);
}
const completed = await completedRes.json();
console.log(completed.status, completed.outputs, completed.settledMicros);
```

```python tab="Python"
import json
import os
import uuid
import httpx

origin = os.environ.get("OPENGEN_API_URL", "https://opengen.dev")
auth = {"Authorization": f"Bearer {os.environ['OPENGEN_API_KEY']}"}
idempotency_key = f"t2v-{uuid.uuid4()}"
# O_EXCL refuses to overwrite an existing unresolved submission record.
fd = os.open("t2v-submission.json", os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
with os.fdopen(fd, "w", encoding="utf-8") as handle:
    json.dump({"idempotencyKey": idempotency_key, "payload": t2v_payload}, handle, indent=2)

with httpx.Client(timeout=45.0) as client:
    job = client.post(
        f"{origin}/v1/generations",
        headers={**auth, "Idempotency-Key": idempotency_key},
        json=t2v_payload,
    ).raise_for_status().json()

    current = job
    while current.get("status") in {"queued", "submitting", "running"} or (
        current.get("status") == "succeeded" and current.get("deliveryStatus") == "pending"
    ):
        params = {"waitMs": 25000}
        if current.get("revision"):
            params["afterRevision"] = current["revision"]
        snap = client.get(
            f"{origin}/v1/generations/{job['id']}/status",
            headers=auth,
            params=params,
        ).raise_for_status().json()
        current = snap.get("job", snap)

    completed = client.get(f"{origin}/v1/generations/{job['id']}", headers=auth).raise_for_status().json()
    print(completed["status"], completed["outputs"], completed.get("settledMicros"))
```

```json tab="MCP"
{
  "tool": "generate",
  "arguments": {
    "idempotencyKey": "t2v-example-001",
    "modelId": "alibaba/wan-3.0",
    "operation": "text-to-video",
    "input": {
      "prompt": "A wooden ferry crossing a misty fjord at dawn, slow aerial tracking shot, crisp ripples on dark blue water.",
      "resolution": "720p",
      "duration": 5,
      "aspectRatio": "16:9",
      "audio": true
    },
    "routeId": "alibaba/ap-southeast-1/wan-3.0",
    "billing": "managed",
    "maxCostMicros": 600000
  }
}
```

```bash tab="CLI"
set -eu
umask 077
if [ -e t2v-submission.key ]; then
  echo "Existing t2v-submission.key found; run 'opengen job recover --idempotency-key \"\$(cat t2v-submission.key)\"' before creating a new submission." >&2
  exit 1
fi
RAW_UUID="$(uuidgen)"
[ -n "$RAW_UUID" ] || { echo "uuidgen failed" >&2; exit 1; }
IDEMPOTENCY_KEY="t2v-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > t2v-submission.key)
opengen generate --input t2v-request.json --idempotency-key "$IDEMPOTENCY_KEY" > t2v-receipt.json
JOB_ID="$(jq -r '.id' t2v-receipt.json)"
opengen job wait "$JOB_ID" --timeout-ms 900000
opengen job get "$JOB_ID"
```

## 4. Handle timeouts, cancellation, and delivery safely

- **Separate observations:** upstream `status: "succeeded"`, private archive `deliveryStatus: "available"`, and billing `settledMicros` are independent states. Wait for `deliveryStatus: "available"` before downloading, and never assume `settledMicros: null` means free.
- **No blind retries:** if `POST /v1/generations` times out, look up the original key with `GET /v1/generations/lookup?idempotencyKey=$IDEMPOTENCY_KEY` (CLI `opengen job recover --idempotency-key "$IDEMPOTENCY_KEY"`). If the job enters `submission-unknown`, keep the receipt and reconcile through your installation operator.
- **Explicit cancellation:** `POST /v1/generations/{id}/cancel` requests cancellation, but running upstream video tasks may reject cancellation and cancellation does not establish refundability.

## Next steps

- Start from an owned still frame instead of text alone in [Image to Video](/docs/guides/image-to-video).
- Reuse your generated video clip directly in [Video Editing](/docs/guides/video-edit) or [Video Extension](/docs/guides/video-extend).
- Receive completion callbacks without polling in [Next.js Webhook Verification](/docs/guides/webhooks-nextjs).

## Supported Models

Live catalog variants supporting `text-to-video` (single-source tariffs from `@media-router/catalog`; unknown prices stay `Unknown`, never `$0`).

| Model | Exact ID | Creator | Routes | Lowest published rate | Weights | Inspect schema |
| --- | --- | --- | --- | --- | --- | --- |
| [Wan 3.0](https://opengen.dev/alibaba/wan-3.0#variant-alibaba-wan-3.0) | `alibaba/wan-3.0` | Alibaba | 10 | $0.0325 / sec | Closed | `GET /v1/models/alibaba/wan-3.0?operation=text-to-video` |
| [Wan 3.0 Prime](https://opengen.dev/alibaba/wan-3.0#variant-alibaba-wan-3.0-prime) | `alibaba/wan-3.0-prime` | Alibaba | 10 | $0.051 / sec | Closed | `GET /v1/models/alibaba/wan-3.0-prime?operation=text-to-video` |
| [HappyHorse 1.1](https://opengen.dev/alibaba/happy-horse-1.1#variant-alibaba-happy-horse-1.1) | `alibaba/happy-horse-1.1` | Alibaba | 6 | $0.061885 / sec | Closed | `GET /v1/models/alibaba/happy-horse-1.1?operation=text-to-video` |
| [Kling 4.0](https://opengen.dev/kling/kling-4.0#variant-kling-kling-4.0) | `kling/kling-4.0` | Kling AI | 5 | $0.157 / sec | Closed | `GET /v1/models/kling/kling-4.0?operation=text-to-video` |
| [Kling 4.0 Flash](https://opengen.dev/kling/kling-4.0#variant-kling-kling-4.0-flash) | `kling/kling-4.0-flash` | Kling AI | 3 | $0.094 / sec | Closed | `GET /v1/models/kling/kling-4.0-flash?operation=text-to-video` |
| [FLUX 3 Video](https://opengen.dev/bfl/flux-3-video#variant-bfl-flux-3-video) | `bfl/flux-3-video` | Black Forest Labs | 2 | $0.15 / sec | Closed | `GET /v1/models/bfl/flux-3-video?operation=text-to-video` |
| [H3 Flex · Pika](https://opengen.dev/minimax/h3#variant-pika-h3-flex) | `pika/h3-flex` | Pika | 1 | $0.01 / sec | Open weights | `GET /v1/models/pika/h3-flex?operation=text-to-video` |
| [Seedance 2.0](https://opengen.dev/bytedance/seedance-2.0#variant-bytedance-seedance-2.0) | `bytedance/seedance-2.0` | ByteDance | 6 | ≈$0.07 / sec | Closed | `GET /v1/models/bytedance/seedance-2.0?operation=text-to-video` |
| [Seedance 2.0 Fast](https://opengen.dev/bytedance/seedance-2.0#variant-bytedance-seedance-2.0-fast) | `bytedance/seedance-2.0-fast` | ByteDance | 5 | ≈$0.0591 / sec | Closed | `GET /v1/models/bytedance/seedance-2.0-fast?operation=text-to-video` |
| [Seedance 2.0 Mini](https://opengen.dev/bytedance/seedance-2.0#variant-bytedance-seedance-2.0-mini) | `bytedance/seedance-2.0-mini` | ByteDance | 5 | ≈$0.0369 / sec | Closed | `GET /v1/models/bytedance/seedance-2.0-mini?operation=text-to-video` |
| [Seedance 2.5](https://opengen.dev/bytedance/seedance-2.5#variant-bytedance-seedance-2.5) | `bytedance/seedance-2.5` | ByteDance | 5 | $0.1028 / sec | Closed | `GET /v1/models/bytedance/seedance-2.5?operation=text-to-video` |
| [Gemini Omni 1.1 Flash](https://opengen.dev/google/gemini-omni-1.1-flash#variant-google-gemini-omni-1.1-flash) | `google/gemini-omni-1.1-flash` | Google | 5 | $0.03 / sec | Closed | `GET /v1/models/google/gemini-omni-1.1-flash?operation=text-to-video` |
| [MiniMax H3](https://opengen.dev/minimax/h3#variant-minimax-h3) | `minimax/h3` | MiniMax | 5 | $0.05 / sec | Open weights | `GET /v1/models/minimax/h3?operation=text-to-video` |
| [Seedance 2.5 Flash](https://opengen.dev/bytedance/seedance-2.5#variant-bytedance-seedance-2.5-flash) | `bytedance/seedance-2.5-flash` | ByteDance | 4 | ≈$0.07 / sec | Closed | `GET /v1/models/bytedance/seedance-2.5-flash?operation=text-to-video` |
| [Gemini Omni 1.2 Flash](https://opengen.dev/google/gemini-omni-1.2-flash#variant-google-gemini-omni-1.2-flash) | `google/gemini-omni-1.2-flash` | Google | 3 | $0.02 / sec | Closed | `GET /v1/models/google/gemini-omni-1.2-flash?operation=text-to-video` |
| [MiniMax H3 Max](https://opengen.dev/minimax/h3#variant-minimax-h3-max) | `minimax/h3-max` | MiniMax | 3 | $0.05 / sec | Closed | `GET /v1/models/minimax/h3-max?operation=text-to-video` |
| [Grok Imagine Video 1.5](https://opengen.dev/xai/grok-imagine-video#variant-xai-grok-imagine-video-1.5) | `xai/grok-imagine-video-1.5` | xAI | 3 | $0.08 / sec | Closed | `GET /v1/models/xai/grok-imagine-video-1.5?operation=text-to-video` |
| [Grok Imagine Video 1.5 Lite](https://opengen.dev/xai/grok-imagine-video#variant-xai-grok-imagine-video-1.5-lite) | `xai/grok-imagine-video-1.5-lite` | xAI | 3 | $0.02 / sec | Closed | `GET /v1/models/xai/grok-imagine-video-1.5-lite?operation=text-to-video` |
| [Seedance 1.0 Pro](https://opengen.dev/bytedance/seedance-1.0#variant-bytedance-seedance-1.0-pro) | `bytedance/seedance-1.0-pro` | ByteDance | 2 | ≈$0.0251 / sec | Closed | `GET /v1/models/bytedance/seedance-1.0-pro?operation=text-to-video` |
| [Seedance 1.0 Pro Fast](https://opengen.dev/bytedance/seedance-1.0#variant-bytedance-seedance-1.0-pro-fast) | `bytedance/seedance-1.0-pro-fast` | ByteDance | 2 | ≈$0.01 / sec | Closed | `GET /v1/models/bytedance/seedance-1.0-pro-fast?operation=text-to-video` |
| [MiniMax H3 Highspeed](https://opengen.dev/minimax/h3#variant-minimax-h3-highspeed) | `minimax/h3-highspeed` | MiniMax | 2 | $0.03 / sec | Closed | `GET /v1/models/minimax/h3-highspeed?operation=text-to-video` |
| [MiniMax H3 Lite](https://opengen.dev/minimax/h3#variant-minimax-h3-lite) | `minimax/h3-lite` | MiniMax | 2 | $0.0125 / sec | Closed | `GET /v1/models/minimax/h3-lite?operation=text-to-video` |
| [FLUX 3 Max Video · fal](https://opengen.dev/bfl/flux-3-video#variant-fal-flux-3-max-video) | `fal/flux-3-max-video` | fal | 1 | $0.17 / sec | Closed | `GET /v1/models/fal/flux-3-max-video?operation=text-to-video` |
| [H3 Max Turbo · fal](https://opengen.dev/minimax/h3#variant-fal-h3-max-turbo) | `fal/h3-max-turbo` | fal | 1 | $0.025 / sec | Closed | `GET /v1/models/fal/h3-max-turbo?operation=text-to-video` |
