# Extend video clips and continue owned jobs

> OpenGen video-extend continues an existing clip across six video models using either an uploaded or reused input.sourceVideo asset or a stateful top-level previousJobId continuation pinned to the original model and deployment. Inspect route-specific duration caps via GET /v1/models/{provider}/{model}?operation=video-extend, verify spend with POST /v1/pricing/estimate, and submit once with a persisted Idempotency-Key while keeping all outputs workspace-private.

## Agent Prompt

```text
Walk me through a video-extend generation on OpenGen (https://opengen.dev):
1. Discover models supporting video-extend via GET https://opengen.dev/v1/models?operation=video-extend (or MCP find_models with operation="video-extend").
2. Inspect the exact model via GET https://opengen.dev/v1/models/{provider}/{model}?operation=video-extend (or MCP get_model, e.g. id="bfl/flux-3-video" or "google/gemini-omni-1.2-flash", operation="video-extend") to verify route-specific extension duration bounds and field restrictions.
3. Either upload/reuse a private source clip via POST https://opengen.dev/v1/assets (placed in input.sourceVideo) or pass top-level previousJobId for an owned continuation pinned to the original deployment.
4. Run POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) and wait for my confirmation of the selected route and maxCostMicros spend cap.
5. Submit once with a persisted Idempotency-Key via POST https://opengen.dev/v1/generations or MCP generate, then follow via job_get until delivered.
```

OpenGen `video-extend` lengthens an existing shot using either a workspace-private source clip (`input.sourceVideo`) or a stateful top-level `previousJobId` continuation. Every model enforces its own extension duration window and parameter rules before billing admission.

## 1. Choose an extension model and inspect route duration caps

| Model                                                                                                     | Extension duration                     | Key constraints on `video-extend`                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [FLUX 3 Video](/bfl/flux-3-video) (`bfl/flux-3-video`)                                                    | `5`–`15`s on official BFL route        | Active official route `bfl-undisclosed/bfl-flux-3-video` (live-verified for `text-to-video` at `720p`/`5s`; `video-extend` remains `documented`). Published continuation tariff: `$0.21/s` at `720p`, `$0.27/s` at `1080p`, `$0.31/s` at `1440p`, `$0.45/s` at `2160p`. |
| [Grok Imagine Video](/xai/grok-imagine-video?variant=xai%2Fgrok-imagine-video) (`xai/grok-imagine-video`) | `1`–`15`s (`2`–`10`s on fal/Replicate) | Active official route `xai-undisclosed/xai-grok-imagine-video` (live-verified for `video-edit` at `720p`/`3s`; `video-extend` remains `documented`). Preserves source resolution (`input.resolution` is rejected on `video-extend`).                                    |
| [Gemini Omni 1.2 Flash](/google/gemini-omni-1.2-flash) (`google/gemini-omni-1.2-flash`)                   | `3`–`10`s per extension call           | Supports stateful `previousJobId` continuation pinned to the originating deployment and model version; `audio` is always on.                                                                                                                                            |
| [Seedance 2.5](/bytedance/seedance-2.5) (`bytedance/seedance-2.5`)                                        | `4`–`30`s (or `"auto"`)                | Documented on Runway route; supports `480p`/`720p`/`1080p` and `aspectRatio: "source"`.                                                                                                                                                                                 |

```bash tab="cURL"
curl --fail-with-body \
  "https://opengen.dev/v1/models?operation=video-extend"

curl --fail-with-body \
  "https://opengen.dev/v1/models/bfl/flux-3-video?operation=video-extend"
```

```ts tab="TypeScript"
const origin = process.env.OPENGEN_API_URL ?? 'https://opengen.dev';
const detail = await fetch(`${origin}/v1/models/bfl/flux-3-video?operation=video-extend`).then(
  (r) => r.json(),
);
console.log(detail.pricing);
```

```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/bfl/flux-3-video",
        params={"operation": "video-extend"},
    ).raise_for_status().json()
    print(detail["pricing"])
```

```json tab="MCP"
{
  "tool": "get_model",
  "arguments": {
    "id": "bfl/flux-3-video",
    "operation": "video-extend"
  }
}
```

```bash tab="CLI"
opengen catalog search --operation video-extend
opengen catalog get bfl/flux-3-video
opengen pricing --model bfl/flux-3-video --operation video-extend
```

## 2. Provide `input.sourceVideo` (upload or reuse an owned output)

Upload a local MP4/WebM clip (up to `100 MiB` via presigned single-PUT + `POST /v1/assets/complete`) or promote an existing OpenGen job output into a ready workspace input with `{ "source": "job_output", "sourceJobId": "<job-uuid>", "outputIndex": 0 }`:

```bash tab="cURL"
curl --fail-with-body \
  -X POST "https://opengen.dev/v1/assets" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: extend-src-$(uuidgen | tr '[:upper:]' '[:lower:]')" \
  --data '{
    "source": "job_output",
    "sourceJobId": "550e8400-e29b-41d4-a716-446655440000",
    "outputIndex": 0
  }'
```

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

const origin = process.env.OPENGEN_API_URL ?? 'https://opengen.dev';
const auth = {
  Authorization: `Bearer ${process.env.OPENGEN_API_KEY}`,
  'Content-Type': 'application/json',
};

const sourceAsset = await fetch(`${origin}/v1/assets`, {
  method: 'POST',
  headers: { ...auth, 'Idempotency-Key': `extend-src-${randomUUID()}` },
  body: JSON.stringify({
    source: 'job_output',
    sourceJobId: '550e8400-e29b-41d4-a716-446655440000',
    outputIndex: 0,
  }),
}).then((r) => r.json());
console.log(sourceAsset.assetKey, sourceAsset.state);
```

```python tab="Python"
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']}"}

with httpx.Client(timeout=60.0) as client:
    source_asset = client.post(
        f"{origin}/v1/assets",
        headers={**auth, "Idempotency-Key": f"extend-src-{uuid.uuid4()}"},
        json={
            "source": "job_output",
            "sourceJobId": "550e8400-e29b-41d4-a716-446655440000",
            "outputIndex": 0,
        },
    ).raise_for_status().json()
    print(source_asset["assetKey"], source_asset["state"])
```

```json tab="MCP"
{
  "tool": "upload_asset",
  "arguments": {
    "source": "job_output",
    "sourceJobId": "550e8400-e29b-41d4-a716-446655440000",
    "outputIndex": 0,
    "idempotencyKey": "extend-src-001"
  }
}
```

```bash tab="CLI"
opengen upload /absolute/path/clip-to-extend.mp4 --media-type video/mp4
```

## 3. Estimate route eligibility before submitting

Run `POST /v1/pricing/estimate` first to confirm route and duration eligibility before submitting.

> [!IMPORTANT]
> Because `video-extend` billing depends on source-video duration and extension rules, managed `video-extend` quotes on `bfl-undisclosed/bfl-flux-3-video` are currently **comparison-only** (`selectedRouteId: null`). The executable example below uses `"billing": "byok"` with your connected provider account (omit `maxCostMicros`, since OpenGen cannot cap direct BYOK provider charges).

```bash tab="cURL"
set -eu
umask 077
if [ -e video-extend-submission.key ]; then
  echo "Existing video-extend-submission.key found; recover read-only via GET /v1/generations/lookup before replacing video-extend-request.json." >&2
  exit 1
fi
rm -f video-extend-request.json
cat <<'JSON' > video-extend-request.json
{
  "modelId": "bfl/flux-3-video",
  "operation": "video-extend",
  "input": {
    "prompt": "Continue the tracking shot smoothly past the lighthouse as evening clouds drift across the horizon.",
    "sourceVideo": {
      "assetKey": "inputs/YOUR_WORKSPACE/RETURNED_VIDEO_UUID.mp4"
    },
    "duration": 5,
    "resolution": "720p",
    "aspectRatio": "source",
    "audio": true
  },
  "routeId": "bfl-undisclosed/bfl-flux-3-video",
  "billing": "byok"
}
JSON
chmod 600 video-extend-request.json

# Dry-run estimate only (review selectedRouteId and workspaceEligibility before submitting)
curl --fail-with-body \
  -X POST "https://opengen.dev/v1/pricing/estimate" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  --data @video-extend-request.json
```

```json tab="MCP"
{
  "tool": "estimate_cost",
  "arguments": {
    "modelId": "bfl/flux-3-video",
    "operation": "video-extend",
    "input": {
      "prompt": "Continue the tracking shot smoothly past the lighthouse as evening clouds drift across the horizon.",
      "sourceVideo": {
        "assetKey": "inputs/YOUR_WORKSPACE/RETURNED_VIDEO_UUID.mp4"
      },
      "duration": 5,
      "resolution": "720p",
      "aspectRatio": "source",
      "audio": true
    },
    "routeId": "bfl-undisclosed/bfl-flux-3-video",
    "billing": "byok"
  }
}
```

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

### Submit once after reviewing the estimate

Run this step only after reviewing the estimate output above and confirming `selectedRouteId`, `workspaceEligibility`, and your BYOK billing payer.

```bash tab="cURL"
set -eu
umask 077
if [ -e video-extend-submission.key ]; then
  echo "Existing video-extend-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="vext-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > video-extend-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 @video-extend-request.json > video-extend-receipt.json
```

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

const extendPayload = {
  modelId: 'bfl/flux-3-video',
  operation: 'video-extend',
  input: {
    prompt:
      'Continue the tracking shot smoothly past the lighthouse as evening clouds drift across the horizon.',
    sourceVideo: { assetKey: sourceAsset.assetKey },
    duration: 5,
    resolution: '720p',
    aspectRatio: 'source',
    audio: true,
  },
  routeId: 'bfl-undisclosed/bfl-flux-3-video',
  billing: 'byok',
} as const;

const estRes = await fetch(`${origin}/v1/pricing/estimate`, {
  method: 'POST',
  headers: auth,
  body: JSON.stringify(extendPayload),
});
if (!estRes.ok) throw new Error(`Estimate failed (${estRes.status}): ${await estRes.text()}`);
const estimate = await estRes.json();
console.log('Review estimate before submitting:', estimate);

const eligibility = estimate.workspaceEligibility;
const canSubmit = Boolean(
  estimate.selectedRouteId &&
  eligibility?.policyAllowed === true &&
  eligibility.hasActiveBillingHold === false &&
  eligibility.executableCandidateCount > 0 &&
  (eligibility.billingMode === 'byok' || eligibility.sufficientBalance === true) &&
  Array.isArray(eligibility.blockers) &&
  eligibility.blockers.length === 0,
);
if (canSubmit && process.env.CONFIRM_SUBMIT === '1') {
  const idempotencyKey = `vext-${randomUUID()}`;
  await writeFile(
    'video-extend-submission.json',
    JSON.stringify({ idempotencyKey, payload: extendPayload }, null, 2),
    { mode: 0o600, flag: 'wx' },
  );
  const genRes = await fetch(`${origin}/v1/generations`, {
    method: 'POST',
    headers: { ...auth, 'Idempotency-Key': idempotencyKey },
    body: JSON.stringify(extendPayload),
  });
  if (!genRes.ok) throw new Error(`Generation failed (${genRes.status}): ${await genRes.text()}`);
  const job = await genRes.json();
  console.log(job.id, job.status);
}
```

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

extend_payload = {
    "modelId": "bfl/flux-3-video",
    "operation": "video-extend",
    "input": {
        "prompt": "Continue the tracking shot smoothly past the lighthouse as evening clouds drift across the horizon.",
        "sourceVideo": {"assetKey": source_asset["assetKey"]},
        "duration": 5,
        "resolution": "720p",
        "aspectRatio": "source",
        "audio": True,
    },
    "routeId": "bfl-undisclosed/bfl-flux-3-video",
    "billing": "byok",
}

with httpx.Client(timeout=45.0) as client:
    estimate = client.post(
        f"{origin}/v1/pricing/estimate",
        headers=auth,
        json=extend_payload,
    ).raise_for_status().json()
    print("Review estimate before submitting:", estimate)

    eligibility = estimate.get("workspaceEligibility") or {}
    can_submit = (
        bool(estimate.get("selectedRouteId"))
        and eligibility.get("policyAllowed") is True
        and eligibility.get("hasActiveBillingHold") is False
        and eligibility.get("executableCandidateCount", 0) > 0
        and (eligibility.get("billingMode") == "byok" or eligibility.get("sufficientBalance") is True)
        and eligibility.get("blockers") == []
    )
    if can_submit and os.environ.get("CONFIRM_SUBMIT") == "1":
        idempotency_key = f"vext-{uuid.uuid4()}"
        fd = os.open("video-extend-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": extend_payload}, handle, indent=2)
        job = client.post(
            f"{origin}/v1/generations",
            headers={**auth, "Idempotency-Key": idempotency_key},
            json=extend_payload,
        ).raise_for_status().json()
        print(job["id"], job["status"])
```

```json tab="MCP"
{
  "tool": "generate",
  "arguments": {
    "idempotencyKey": "vext-example-001",
    "modelId": "bfl/flux-3-video",
    "operation": "video-extend",
    "input": {
      "prompt": "Continue the tracking shot smoothly past the lighthouse as evening clouds drift across the horizon.",
      "sourceVideo": {
        "assetKey": "inputs/YOUR_WORKSPACE/RETURNED_VIDEO_UUID.mp4"
      },
      "duration": 5,
      "resolution": "720p",
      "aspectRatio": "source",
      "audio": true
    },
    "routeId": "bfl-undisclosed/bfl-flux-3-video",
    "billing": "byok"
  }
}
```

```bash tab="CLI"
set -eu
umask 077
if [ -e video-extend-submission.key ]; then
  echo "Existing video-extend-submission.key found; run 'opengen job recover --idempotency-key \"\$(cat video-extend-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="vext-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > video-extend-submission.key)
opengen generate --input video-extend-request.json --idempotency-key "$IDEMPOTENCY_KEY" > video-extend-receipt.json
```

### Stateful continuation with top-level `previousJobId`

On stateful continuation models such as [Gemini Omni 1.2 Flash](/google/gemini-omni-1.2-flash) (`google/gemini-omni-1.2-flash`), you can omit `input.sourceVideo` and pass top-level `previousJobId` instead. OpenGen verifies workspace ownership and pins the continuation to the original model version and deployment (use `"billing": "byok"` while managed `video-extend` quotes remain comparison-only):

```json
{
  "modelId": "google/gemini-omni-1.2-flash",
  "operation": "video-extend",
  "previousJobId": "550e8400-e29b-41d4-a716-446655440000",
  "input": {
    "prompt": "Keep the camera gliding through the archway as lantern light warms the courtyard.",
    "duration": 5,
    "resolution": "720p",
    "aspectRatio": "source"
  },
  "routeId": "google-undisclosed/google-gemini-omni-1.2-flash",
  "billing": "byok"
}
```

> [!NOTE]
> `google/gemini-omni-1.2-flash` caps `video-extend` duration at `3`–`10` seconds per call (even though `text-to-video` allows up to `15` seconds). Submitting `duration > 10` is rejected with `400 invalid_generation`.

## 4. Follow progress and retrieve privately

Poll `GET /v1/generations/{id}/status?waitMs=25000` (or `GET /v1/generations/{id}/events` / MCP `job_get`) until `deliveryStatus: "available"`, then fetch fresh signed output links via `GET /v1/generations/{id}`.

## Next steps

- Need to restyle an existing clip rather than lengthen it? See [Video Editing](/docs/guides/video-edit).
- Deliver video completion events to your Next.js backend via [Next.js Webhook Verification](/docs/guides/webhooks-nextjs).

## Supported Models

Live catalog variants supporting `video-extend` (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 | 6 | $0.041256 / sec | Closed | `GET /v1/models/alibaba/wan-3.0?operation=video-extend` |
| [Wan 3.0 Prime](https://opengen.dev/alibaba/wan-3.0#variant-alibaba-wan-3.0-prime) | `alibaba/wan-3.0-prime` | Alibaba | 6 | $0.0636 / sec | Closed | `GET /v1/models/alibaba/wan-3.0-prime?operation=video-extend` |
| [Grok Imagine Video · Edit / Extend](https://opengen.dev/xai/grok-imagine-video#variant-xai-grok-imagine-video) | `xai/grok-imagine-video` | xAI | 3 | $0.05 / sec | Closed | `GET /v1/models/xai/grok-imagine-video?operation=video-extend` |
| [FLUX 3 Video](https://opengen.dev/bfl/flux-3-video#variant-bfl-flux-3-video) | `bfl/flux-3-video` | Black Forest Labs | 2 | $0.17 / sec | Closed | `GET /v1/models/bfl/flux-3-video?operation=video-extend` |
| [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=video-extend` |
| [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 | 2 | ≈$0.0338 / sec | Closed | `GET /v1/models/google/gemini-omni-1.1-flash?operation=video-extend` |
| [Seedance 2.5](https://opengen.dev/bytedance/seedance-2.5#variant-bytedance-seedance-2.5) | `bytedance/seedance-2.5` | ByteDance | 1 | $0.20 / sec | Closed | `GET /v1/models/bytedance/seedance-2.5?operation=video-extend` |
| [Seedance 2.5 Flash](https://opengen.dev/bytedance/seedance-2.5#variant-bytedance-seedance-2.5-flash) | `bytedance/seedance-2.5-flash` | ByteDance | 1 | $0.13 / sec | Closed | `GET /v1/models/bytedance/seedance-2.5-flash?operation=video-extend` |
| [MiniMax H3](https://opengen.dev/minimax/h3#variant-minimax-h3) | `minimax/h3` | MiniMax | 1 | $0.08 / sec | Open weights | `GET /v1/models/minimax/h3?operation=video-extend` |
