> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Choose a Video Generation Model

> Select an OpenRouter video model by matching clip requirements and scoring priorities

Use this guide when you need to add video model selection based on the clip your app needs to generate.

By the end, your implementation should have a small model-selection helper that filters models by capability and scores them by priority before submitting a video job.

> [!TIP]
>
> Not sure what model to use? Copy this prompt to run a model-selection process.
>
> For reusable agent knowledge across projects, install the [openrouter-video skill](https://github.com/OpenRouterTeam/skills/tree/main/skills/openrouter-video).

## Before you start

You need:

* Node.js 20 or newer
* For the Python tabs, Python 3 with `requests` (`pip install requests`)
* For the Go tabs, Go 1.21 or newer
* For the cURL tabs, bash, `curl`, and `jq`
* An OpenRouter API key available as `OPENROUTER_API_KEY` only if you submit the optional generation request
* A stable, directly downloadable image URL if you test an image-to-video request

Use the API reference pages as the source of truth for exact fields:

* [Create video generation request](https://openrouter.ai/docs/api/api-reference/video-generation/submit-a-video-generation-request.md)
* [List video generation models](https://openrouter.ai/docs/api/api-reference/video-generation/list-all-video-generation-models.md)
* [TypeScript SDK video generation reference](https://openrouter.ai/docs/client-sdks/typescript/sdks/videogeneration/README.md)

> [!WARNING]
>
> Submitting `POST /api/v1/videos` starts a real video generation job and may spend OpenRouter credits. Use the model-selection and request-preview steps first, then submit only when the request is ready.

## Step 1: Fetch the video model list

Call the dedicated video model endpoint:

```js lines theme={null}
const response = await fetch("https://openrouter.ai/api/v1/videos/models");

if (!response.ok) {
  throw new Error(await response.text());
}

const { data } = await response.json();
const models = data;

console.log(models.map((model) => model.id));
```

```python title="Python" lines theme={null}
import json
import math

import requests

response = requests.get("https://openrouter.ai/api/v1/videos/models")

if not response.ok:
    raise Exception(response.text)

models = response.json()["data"]

print(json.dumps([model["id"] for model in models], indent=2))

```

```go title="Go" lines theme={null}
// The fields the later steps filter and score on. Declare this at package level.
type VideoModel struct {
	ID                    string         `json:"id"`
	SupportedResolutions  []string       `json:"supported_resolutions"`
	SupportedAspectRatios []string       `json:"supported_aspect_ratios"`
	SupportedDurations    []int          `json:"supported_durations"`
	SupportedFrameImages  []string       `json:"supported_frame_images"`
	PricingSkus           map[string]any `json:"pricing_skus"`
}

resp, err := http.Get("https://openrouter.ai/api/v1/videos/models")
if err != nil {
	log.Fatal(err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
	body, _ := io.ReadAll(resp.Body)
	log.Fatal(string(body))
}

// Keep the full model objects: later steps read their capabilities and pricing
var result struct {
	Data []VideoModel `json:"data"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
	log.Fatal(err)
}
models := result.Data

ids := make([]string, len(models))
for i, model := range models {
	ids[i] = model.ID
}
out, err := json.MarshalIndent(ids, "", "  ")
if err != nil {
	log.Fatal(err)
}
fmt.Println(string(out))
```

```bash title="cURL" lines theme={null}
set -o pipefail # a failed request fails the pipeline instead of leaving models empty

# Keep the full model objects: later steps read their capabilities and pricing
models=$(curl -sSf https://openrouter.ai/api/v1/videos/models \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  | jq -c '.data') || exit 1

echo "$models" | jq '[.[].id]'
```

Actual output from the model-list call:

```text lines theme={null}
[
  "x-ai/grok-imagine-video-1.5-lite",
  "heygen/heygen-video-1",
  "black-forest-labs/flux-video-edit",
  "minimax/hailuo-3-max",
  "alibaba/wan-3.0-prime",
  "alibaba/wan-3.0",
  "heygen/avatar-iv",
  "black-forest-labs/flux-video-upscale",
  "bytedance/seedance-2.0-mini",
  "bytedance/seedance-2.5",
  "black-forest-labs/flux-3-video",
  "minimax/hailuo-3",
  "runway/aleph-2",
  "runway/gen-4.5",
  "x-ai/grok-imagine-video-1.5",
  "alibaba/happyhorse-1.1",
  "alibaba/happyhorse-1.0",
  "x-ai/grok-imagine-video",
  "kwaivgi/kling-v3.0-pro",
  "kwaivgi/kling-v3.0-std",
  "google/veo-3.1-fast",
  "google/veo-3.1-lite",
  "kwaivgi/kling-video-o1",
  "minimax/hailuo-2.3",
  "bytedance/seedance-2.0",
  "alibaba/wan-2.7",
  "bytedance/seedance-2.0-fast",
  "alibaba/wan-2.6",
  "bytedance/seedance-1-5-pro",
  "google/veo-3.1"
]
```

Each model includes the values you need for routing decisions. Use the [List video generation models API reference](https://openrouter.ai/docs/api/api-reference/video-generation/list-all-video-generation-models.md) as the source of truth for the endpoint response and model metadata fields. If your app uses the TypeScript SDK, see the generated [`listVideosModels` SDK reference](https://openrouter.ai/docs/client-sdks/typescript/sdks/videogeneration/README#listvideosmodels) for the SDK method shape.

## Step 2: Filter by the job you want to run

Start by translating the product request into model requirements: clip length, output shape, generation mode, audio, deterministic retries, provider-specific controls, and cost. Use the API reference above for the exact metadata fields to inspect before filtering.

For example, this helper finds models that can generate a 720p, vertical, image-to-video clip with first-frame support:

```js expandable lines theme={null}
function findVideoModels(models) {
  return models.filter((model) => {
    const supportsRequest =
      model.supported_resolutions?.includes("720p") &&
      model.supported_aspect_ratios?.includes("9:16") &&
      model.supported_durations?.includes(5) &&
      model.supported_frame_images?.includes("first_frame");

    return supportsRequest;
  });
}

function getLowestAdvertisedPrice(model) {
  const prices = Object.values(model.pricing_skus ?? {})
    .map((price) => Number(price))
    .filter((price) => Number.isFinite(price));

  return prices.length > 0 ? Math.min(...prices) : Number.POSITIVE_INFINITY;
}

const matchingModels = findVideoModels(models).sort((first, second) => {
  return getLowestAdvertisedPrice(first) - getLowestAdvertisedPrice(second);
});

if (matchingModels.length === 0) {
  throw new Error("No matching video model found.");
}

console.log(
  JSON.stringify(
    matchingModels.map((match) => ({
      id: match.id,
      lowest_advertised_price: getLowestAdvertisedPrice(match),
    })),
    null,
    2,
  ),
);
```

```python title="Python" lines theme={null}
def find_video_models(models):
    return [
        model
        for model in models
        if "720p" in (model.get("supported_resolutions") or [])
        and "9:16" in (model.get("supported_aspect_ratios") or [])
        and 5 in (model.get("supported_durations") or [])
        and "first_frame" in (model.get("supported_frame_images") or [])
    ]


def get_lowest_advertised_price(model):
    prices = []
    for price in (model.get("pricing_skus") or {}).values():
        try:
            value = float(price)
        except (TypeError, ValueError):
            continue
        if math.isfinite(value):
            prices.append(value)

    return min(prices) if prices else math.inf


def displayed_price(model):
    # math.inf marks a model with no usable price. Print null, which strict JSON readers accept.
    price = get_lowest_advertised_price(model)
    return price if math.isfinite(price) else None


matching_models = sorted(find_video_models(models), key=get_lowest_advertised_price)

if not matching_models:
    raise Exception("No matching video model found.")

print(
    json.dumps(
        [
            {
                "id": match["id"],
                "lowest_advertised_price": displayed_price(match),
            }
            for match in matching_models
        ],
        indent=2,
    )
)

```

```go title="Go" lines theme={null}
findVideoModels := func(models []VideoModel) []VideoModel {
	var matches []VideoModel
	for _, model := range models {
		supportsRequest := slices.Contains(model.SupportedResolutions, "720p") &&
			slices.Contains(model.SupportedAspectRatios, "9:16") &&
			slices.Contains(model.SupportedDurations, 5) &&
			slices.Contains(model.SupportedFrameImages, "first_frame")

		if supportsRequest {
			matches = append(matches, model)
		}
	}
	return matches
}

getLowestAdvertisedPrice := func(model VideoModel) float64 {
	lowest := math.Inf(1)
	for _, raw := range model.PricingSkus {
		var price float64
		switch v := raw.(type) {
		case float64:
			price = v
		case string:
			parsed, err := strconv.ParseFloat(v, 64)
			if err != nil {
				continue
			}
			price = parsed
		default:
			continue
		}
		if !math.IsInf(price, 0) && !math.IsNaN(price) {
			lowest = math.Min(lowest, price)
		}
	}
	return lowest
}

matchingModels := findVideoModels(models)
sort.SliceStable(matchingModels, func(i, j int) bool {
	return getLowestAdvertisedPrice(matchingModels[i]) < getLowestAdvertisedPrice(matchingModels[j])
})

if len(matchingModels) == 0 {
	log.Fatal("No matching video model found.")
}

// +Inf marks a model with no usable price. JSON cannot encode it, so print null instead.
type match struct {
	ID                    string   `json:"id"`
	LowestAdvertisedPrice *float64 `json:"lowest_advertised_price"`
}
summary := make([]match, len(matchingModels))
for i, m := range matchingModels {
	summary[i] = match{ID: m.ID}
	if price := getLowestAdvertisedPrice(m); !math.IsInf(price, 0) {
		summary[i].LowestAdvertisedPrice = &price
	}
}
out, err := json.MarshalIndent(summary, "", "  ")
if err != nil {
	log.Fatal(err)
}
fmt.Println(string(out))
```

```bash title="cURL" lines theme={null}
matching_models=$(echo "$models" | jq -c '
  def has($field; $value): (.[$field] // []) | index([$value]) != null;
  def lowest_price:
    [(.pricing_skus // {})[] | tonumber? | select(isfinite)]
    | if length > 0 then min else infinite end;

  [.[] | select(
      has("supported_resolutions"; "720p") and
      has("supported_aspect_ratios"; "9:16") and
      has("supported_durations"; 5) and
      has("supported_frame_images"; "first_frame"))]
  | sort_by(lowest_price)
  | if length == 0 then error("No matching video model found.") else . end
') || exit 1

# A model with no usable price sorts last above and prints null here
echo "$matching_models" | jq '
  def lowest_price:
    [(.pricing_skus // {})[] | tonumber? | select(isfinite)]
    | if length > 0 then min else null end;
  map({id, lowest_advertised_price: lowest_price})
'
```

Example output:

```json expandable lines theme={null}
[
  {
    "id": "bytedance/seedance-1-5-pro",
    "lowest_advertised_price": 0.0000012
  },
  {
    "id": "bytedance/seedance-2.0-mini",
    "lowest_advertised_price": 0.0000021
  },
  {
    "id": "bytedance/seedance-2.0",
    "lowest_advertised_price": 0.0000024
  },
  {
    "id": "bytedance/seedance-2.0-fast",
    "lowest_advertised_price": 0.000002475
  },
  {
    "id": "bytedance/seedance-2.5",
    "lowest_advertised_price": 0.0000064
  },
  {
    "id": "alibaba/wan-2.6",
    "lowest_advertised_price": 0.04
  },
  {
    "id": "alibaba/wan-3.0",
    "lowest_advertised_price": 0.05
  },
  {
    "id": "alibaba/wan-3.0-prime",
    "lowest_advertised_price": 0.068
  },
  {
    "id": "kwaivgi/kling-v3.0-std",
    "lowest_advertised_price": 0.084
  },
  {
    "id": "alibaba/happyhorse-1.1",
    "lowest_advertised_price": 0.0988
  },
  {
    "id": "alibaba/happyhorse-1.0",
    "lowest_advertised_price": 0.0988
  },
  {
    "id": "alibaba/wan-2.7",
    "lowest_advertised_price": 0.1
  },
  {
    "id": "kwaivgi/kling-v3.0-pro",
    "lowest_advertised_price": 0.112
  },
  {
    "id": "kwaivgi/kling-video-o1",
    "lowest_advertised_price": 0.112
  },
  {
    "id": "x-ai/grok-imagine-video",
    "lowest_advertised_price": 0.2
  },
  {
    "id": "x-ai/grok-imagine-video-1.5-lite",
    "lowest_advertised_price": 1
  },
  {
    "id": "x-ai/grok-imagine-video-1.5",
    "lowest_advertised_price": 1
  },
  {
    "id": "runway/gen-4.5",
    "lowest_advertised_price": 12
  },
  {
    "id": "black-forest-labs/flux-3-video",
    "lowest_advertised_price": 17
  }
]
```

At this point, you have models that satisfy the hard requirements. Score the matching set before selecting one.

## Step 3: Score the matching models by priority

Use weighted priorities to make the final choice. For example, a draft workflow might prioritize speed and cost, while a production render might prioritize quality and cost:

```js expandable lines theme={null}
const priorityProfiles = {
  fastAndCheap: {
    speed: 0.55,
    cost: 0.35,
    quality: 0.1,
  },
  qualityAndCost: {
    speed: 0.15,
    cost: 0.3,
    quality: 0.55,
  },
  balanced: {
    speed: 0.33,
    cost: 0.33,
    quality: 0.34,
  },
};

const resolutionRanks = new Map([
  ["480p", 1],
  ["720p", 2],
  ["1080p", 3],
  ["4K", 4],
]);

function getResolutionRank(model) {
  return Math.max(
    0,
    ...(model.supported_resolutions ?? []).map((resolution) => {
      return resolutionRanks.get(resolution) ?? 0;
    }),
  );
}

function getSpeedScore(model) {
  const id = model.id.toLowerCase();

  if (id.includes("fast")) return 1;
  if (id.includes("lite") || id.includes("std")) return 0.8;
  if (id.includes("pro") || id.includes("o1")) return 0.35;

  return 0.55;
}

function normalize(value, min, max, invert = false) {
  if (!Number.isFinite(value) || max === min) {
    return 0.5;
  }

  const score = (value - min) / (max - min);

  return invert ? 1 - score : score;
}

function scoreVideoModels(models, weights) {
  const prices = models.map(getLowestAdvertisedPrice).filter(Number.isFinite);
  const minPrice = prices.length > 0 ? Math.min(...prices) : 0;
  const maxPrice = prices.length > 0 ? Math.max(...prices) : 0;
  const maxResolutionRank = Math.max(0, ...models.map(getResolutionRank));

  return models
    .map((model) => {
      const price = getLowestAdvertisedPrice(model);
      const speedScore = getSpeedScore(model);
      const costScore = Number.isFinite(price)
        ? normalize(price, minPrice, maxPrice, true)
        : 0;
      const qualityScore =
        maxResolutionRank === 0 ? 0.5 : getResolutionRank(model) / maxResolutionRank;
      const score =
        weights.speed * speedScore +
        weights.cost * costScore +
        weights.quality * qualityScore;

      return {
        model,
        id: model.id,
        score: Number(score.toFixed(3)),
        lowest_advertised_price: price,
        speed_score: Number(speedScore.toFixed(3)),
        cost_score: Number(costScore.toFixed(3)),
        quality_score: Number(qualityScore.toFixed(3)),
      };
    })
    .sort((first, second) => second.score - first.score);
}

function summarizeScores(rankedModels) {
  return rankedModels.slice(0, 4).map(({ model: _model, ...summary }) => {
    return summary;
  });
}

const fastAndCheapModels = scoreVideoModels(
  matchingModels,
  priorityProfiles.fastAndCheap,
);
const qualityAndCostModels = scoreVideoModels(
  matchingModels,
  priorityProfiles.qualityAndCost,
);
const model = fastAndCheapModels[0]?.model;

if (!model) {
  throw new Error("No scored video model found.");
}

console.log(
  JSON.stringify(
    {
      fast_and_cheap: summarizeScores(fastAndCheapModels),
      quality_and_cost: summarizeScores(qualityAndCostModels),
    },
    null,
    2,
  ),
);
console.log(`Use ${model.id}`);
```

```python title="Python" lines theme={null}
priority_profiles = {
    "fast_and_cheap": {"speed": 0.55, "cost": 0.35, "quality": 0.1},
    "quality_and_cost": {"speed": 0.15, "cost": 0.3, "quality": 0.55},
    "balanced": {"speed": 0.33, "cost": 0.33, "quality": 0.34},
}

resolution_ranks = {"480p": 1, "720p": 2, "1080p": 3, "4K": 4}


def get_resolution_rank(model):
    return max(
        [0]
        + [
            resolution_ranks.get(resolution, 0)
            for resolution in (model.get("supported_resolutions") or [])
        ]
    )


def get_speed_score(model):
    model_id = model["id"].lower()

    if "fast" in model_id:
        return 1
    if "lite" in model_id or "std" in model_id:
        return 0.8
    if "pro" in model_id or "o1" in model_id:
        return 0.35

    return 0.55


def normalize(value, min_value, max_value, invert=False):
    if not math.isfinite(value) or max_value == min_value:
        return 0.5

    score = (value - min_value) / (max_value - min_value)

    return 1 - score if invert else score


def score_video_models(models, weights):
    prices = [p for p in map(get_lowest_advertised_price, models) if math.isfinite(p)]
    min_price = min(prices) if prices else 0
    max_price = max(prices) if prices else 0
    max_resolution_rank = max([0] + [get_resolution_rank(m) for m in models])

    ranked = []
    for model in models:
        price = get_lowest_advertised_price(model)
        speed_score = get_speed_score(model)
        cost_score = (
            normalize(price, min_price, max_price, invert=True)
            if math.isfinite(price)
            else 0
        )
        quality_score = (
            0.5
            if max_resolution_rank == 0
            else get_resolution_rank(model) / max_resolution_rank
        )
        score = (
            weights["speed"] * speed_score
            + weights["cost"] * cost_score
            + weights["quality"] * quality_score
        )

        ranked.append(
            {
                "model": model,
                "id": model["id"],
                "score": round(score, 3),
                "lowest_advertised_price": price if math.isfinite(price) else None,
                "speed_score": round(speed_score, 3),
                "cost_score": round(cost_score, 3),
                "quality_score": round(quality_score, 3),
            }
        )

    return sorted(ranked, key=lambda entry: entry["score"], reverse=True)


def summarize_scores(ranked_models):
    return [
        {key: value for key, value in entry.items() if key != "model"}
        for entry in ranked_models[:4]
    ]


fast_and_cheap_models = score_video_models(
    matching_models, priority_profiles["fast_and_cheap"]
)
quality_and_cost_models = score_video_models(
    matching_models, priority_profiles["quality_and_cost"]
)
model = fast_and_cheap_models[0]["model"] if fast_and_cheap_models else None

if not model:
    raise Exception("No scored video model found.")

print(
    json.dumps(
        {
            "fast_and_cheap": summarize_scores(fast_and_cheap_models),
            "quality_and_cost": summarize_scores(quality_and_cost_models),
        },
        indent=2,
    )
)
print(f"Use {model['id']}")
```

```go title="Go" lines theme={null}
type priorityWeights struct{ Speed, Cost, Quality float64 }

priorityProfiles := map[string]priorityWeights{
	"fastAndCheap":   {Speed: 0.55, Cost: 0.35, Quality: 0.1},
	"qualityAndCost": {Speed: 0.15, Cost: 0.3, Quality: 0.55},
	"balanced":       {Speed: 0.33, Cost: 0.33, Quality: 0.34},
}

resolutionRanks := map[string]int{"480p": 1, "720p": 2, "1080p": 3, "4K": 4}

getResolutionRank := func(model VideoModel) int {
	rank := 0
	for _, resolution := range model.SupportedResolutions {
		rank = max(rank, resolutionRanks[resolution])
	}
	return rank
}

getSpeedScore := func(model VideoModel) float64 {
	id := strings.ToLower(model.ID)
	switch {
	case strings.Contains(id, "fast"):
		return 1
	case strings.Contains(id, "lite") || strings.Contains(id, "std"):
		return 0.8
	case strings.Contains(id, "pro") || strings.Contains(id, "o1"):
		return 0.35
	}
	return 0.55
}

normalize := func(value, lo, hi float64, invert bool) float64 {
	if math.IsInf(value, 0) || math.IsNaN(value) || hi == lo {
		return 0.5
	}
	score := (value - lo) / (hi - lo)
	if invert {
		return 1 - score
	}
	return score
}

round3 := func(v float64) float64 { return math.Round(v*1000) / 1000 }

type scoredModel struct {
	Model                 VideoModel `json:"-"`
	ID                    string     `json:"id"`
	Score                 float64    `json:"score"`
	LowestAdvertisedPrice *float64   `json:"lowest_advertised_price"` // nil prints null when no price is usable
	SpeedScore            float64    `json:"speed_score"`
	CostScore             float64    `json:"cost_score"`
	QualityScore          float64    `json:"quality_score"`
}

scoreVideoModels := func(models []VideoModel, weights priorityWeights) []scoredModel {
	minPrice, maxPrice := math.Inf(1), math.Inf(-1)
	maxResolutionRank := 0
	for _, model := range models {
		if price := getLowestAdvertisedPrice(model); !math.IsInf(price, 0) {
			minPrice, maxPrice = math.Min(minPrice, price), math.Max(maxPrice, price)
		}
		maxResolutionRank = max(maxResolutionRank, getResolutionRank(model))
	}
	if math.IsInf(minPrice, 0) {
		minPrice, maxPrice = 0, 0
	}

	ranked := make([]scoredModel, 0, len(models))
	for _, model := range models {
		price := getLowestAdvertisedPrice(model)
		speedScore := getSpeedScore(model)
		costScore := 0.0
		var displayedPrice *float64
		if !math.IsInf(price, 0) {
			costScore = normalize(price, minPrice, maxPrice, true)
			displayedPrice = &price
		}
		qualityScore := 0.5
		if maxResolutionRank != 0 {
			qualityScore = float64(getResolutionRank(model)) / float64(maxResolutionRank)
		}
		score := weights.Speed*speedScore + weights.Cost*costScore + weights.Quality*qualityScore

		ranked = append(ranked, scoredModel{
			Model:                 model,
			ID:                    model.ID,
			Score:                 round3(score),
			LowestAdvertisedPrice: displayedPrice,
			SpeedScore:            round3(speedScore),
			CostScore:             round3(costScore),
			QualityScore:          round3(qualityScore),
		})
	}
	sort.SliceStable(ranked, func(i, j int) bool { return ranked[i].Score > ranked[j].Score })
	return ranked
}

summarizeScores := func(ranked []scoredModel) []scoredModel {
	return ranked[:min(4, len(ranked))]
}

fastAndCheapModels := scoreVideoModels(matchingModels, priorityProfiles["fastAndCheap"])
qualityAndCostModels := scoreVideoModels(matchingModels, priorityProfiles["qualityAndCost"])

if len(fastAndCheapModels) == 0 {
	log.Fatal("No scored video model found.")
}
model := fastAndCheapModels[0].Model

result, err := json.MarshalIndent(struct {
	FastAndCheap   []scoredModel `json:"fast_and_cheap"`
	QualityAndCost []scoredModel `json:"quality_and_cost"`
}{summarizeScores(fastAndCheapModels), summarizeScores(qualityAndCostModels)}, "", "  ")
if err != nil {
	log.Fatal(err)
}
fmt.Println(string(result))
fmt.Printf("Use %s\n", model.ID)
```

```bash title="cURL" lines theme={null}
ranked=$(echo "$matching_models" | jq -c '
  def lowest_price:
    [(.pricing_skus // {})[] | tonumber? | select(isfinite)]
    | if length > 0 then min else infinite end;
  def res_rank:
    [(.supported_resolutions // [])[] as $r
      | {"480p": 1, "720p": 2, "1080p": 3, "4K": 4} | .[$r] // 0] + [0] | max;
  def speed:
    (.id | ascii_downcase) as $id
    | if ($id | contains("fast")) then 1
      elif ($id | contains("lite")) or ($id | contains("std")) then 0.8
      elif ($id | contains("pro")) or ($id | contains("o1")) then 0.35
      else 0.55 end;
  def round3: (. * 1000 | round) / 1000;
  def score($w):
    [.[] | lowest_price | select(isfinite)] as $prices
    | ($prices | min // 0) as $min | ($prices | max // 0) as $max
    | ([.[] | res_rank] + [0] | max) as $max_rank
    | map(lowest_price as $p | speed as $s
        | (if ($p | isfinite | not) then 0
           elif $max == $min then 0.5
           else 1 - ($p - $min) / ($max - $min) end) as $c
        | (if $max_rank == 0 then 0.5 else res_rank / $max_rank end) as $q
        | {id,
           score: ($w.speed * $s + $w.cost * $c + $w.quality * $q | round3),
           lowest_advertised_price: (if ($p | isfinite) then $p else null end),
           speed_score: ($s | round3),
           cost_score: ($c | round3),
           quality_score: ($q | round3)})
    | sort_by(-.score);

  {fast_and_cheap: score({speed: 0.55, cost: 0.35, quality: 0.1})[:4],
   quality_and_cost: score({speed: 0.15, cost: 0.3, quality: 0.55})[:4]}
') || exit 1

model_id=$(echo "$ranked" | jq -er '.fast_and_cheap[0].id') || {
  echo "No scored video model found." >&2
  exit 1
}

echo "$ranked" | jq .
echo "Use $model_id"
```

Actual output from the scoring helper:

```json expandable lines theme={null}
{
  "fast_and_cheap": [
    {
      "id": "bytedance/seedance-2.0-fast",
      "score": 0.95,
      "lowest_advertised_price": 0.000002475,
      "speed_score": 1,
      "cost_score": 1,
      "quality_score": 0.5
    },
    {
      "id": "x-ai/grok-imagine-video-1.5-lite",
      "score": 0.844,
      "lowest_advertised_price": 1,
      "speed_score": 0.8,
      "cost_score": 0.941,
      "quality_score": 0.75
    },
    {
      "id": "kwaivgi/kling-v3.0-std",
      "score": 0.838,
      "lowest_advertised_price": 0.084,
      "speed_score": 0.8,
      "cost_score": 0.995,
      "quality_score": 0.5
    },
    {
      "id": "bytedance/seedance-2.0",
      "score": 0.752,
      "lowest_advertised_price": 0.0000024,
      "speed_score": 0.55,
      "cost_score": 1,
      "quality_score": 1
    }
  ],
  "quality_and_cost": [
    {
      "id": "bytedance/seedance-2.0",
      "score": 0.932,
      "lowest_advertised_price": 0.0000024,
      "speed_score": 0.55,
      "cost_score": 1,
      "quality_score": 1
    },
    {
      "id": "x-ai/grok-imagine-video-1.5-lite",
      "score": 0.815,
      "lowest_advertised_price": 1,
      "speed_score": 0.8,
      "cost_score": 0.941,
      "quality_score": 0.75
    },
    {
      "id": "alibaba/wan-2.6",
      "score": 0.794,
      "lowest_advertised_price": 0.04,
      "speed_score": 0.55,
      "cost_score": 0.998,
      "quality_score": 0.75
    },
    {
      "id": "alibaba/wan-3.0",
      "score": 0.794,
      "lowest_advertised_price": 0.05,
      "speed_score": 0.55,
      "cost_score": 0.997,
      "quality_score": 0.75
    }
  ]
}
```

```text lines theme={null}
Use bytedance/seedance-2.0-fast
```

Pick the model that best fits your product needs after capability matching. For example, you might prefer the lowest compatible price, audio support, seed support, provider-specific controls, a specific provider, or a known latency profile. The speed score is a slug-based heuristic, and the quality score uses resolution support as a proxy. Pricing SKU units can differ by provider, so treat the helper as a quick starting point and inspect the matching model's `pricing_skus` before routing production traffic.

## Step 4: Preview the generation request

Before submitting, have the implementation build the exact request body it will send. This makes capability mismatches visible before starting a paid job. Steps 4 and 5 have no Python or Go tab: the preview is shown in JavaScript and cURL, and the submission in JavaScript only. If you followed the Python or Go tabs, switch to one of those tabs here, or build the same request body in your language from the fields shown below.

```js expandable lines theme={null}
const firstFrameUrl = process.env.FIRST_FRAME_URL;

if (!firstFrameUrl) {
  throw new Error("Set FIRST_FRAME_URL to a directly downloadable image URL.");
}

const requestBody = {
  model: model.id,
  prompt:
    "A handheld vertical product shot of a ceramic mug on a sunny kitchen counter",
  duration: 5,
  resolution: "720p",
  aspect_ratio: "9:16",
  frame_images: [
    {
      type: "image_url",
      image_url: {
        url: firstFrameUrl,
      },
      frame_type: "first_frame",
    },
  ],
};

console.log(JSON.stringify(requestBody, null, 2));
```

```bash title="cURL" lines theme={null}
: "${FIRST_FRAME_URL:?Set FIRST_FRAME_URL to a directly downloadable image URL.}"

request_body=$(jq -n --arg model "$model_id" --arg url "$FIRST_FRAME_URL" '{
  model: $model,
  prompt: "A handheld vertical product shot of a ceramic mug on a sunny kitchen counter",
  duration: 5,
  resolution: "720p",
  aspect_ratio: "9:16",
  frame_images: [
    {type: "image_url", image_url: {url: $url}, frame_type: "first_frame"}
  ]
}')

echo "$request_body"
```

Before submitting, check that your image URL returns `200` with an image content type:

```bash lines theme={null}
curl -I "$FIRST_FRAME_URL"
```

Example output:

```text lines theme={null}
HTTP/2 200
content-type: image/jpeg
```

## Step 5: Submit when ready

```js lines theme={null}
const apiKey = process.env.OPENROUTER_API_KEY;

if (!apiKey) {
  throw new Error("Set OPENROUTER_API_KEY before submitting a video job.");
}

const generation = await fetch("https://openrouter.ai/api/v1/videos", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(requestBody),
});

if (!generation.ok) {
  throw new Error(await generation.text());
}

console.log(await generation.json());
```

The submission response contains the job `id`, `polling_url`, and an initial status. In a completed run, that submitted job later reached this final state:

```json lines theme={null}
{
  "id": "S2wge1oFOBzIj1PpFcFu",
  "status": "completed",
  "polling_url": "https://openrouter.ai/api/v1/videos/S2wge1oFOBzIj1PpFcFu",
  "has_unsigned_urls": true
}
```

## Check your work

Before submission, you should see a request body whose model supports every capability you filtered for. If you submit the request, you should see a response with a video job `id`, a `polling_url`, and an initial status such as `pending`. To wait for the playable MP4, use the polling and download helper from [Generate and Download a Video from Text](https://openrouter.ai/docs/cookbook/video-generation/text-to-video.md).
