Skip to main content
Use this guide when you need to add image-to-video generation where an image becomes the first or last frame of a generated video. By the end, your implementation should submit an image-to-video job with frame_images and download the finished clip.
For reusable agent knowledge across projects, install the openrouter-video skill.

Before you start

You need:
  • An OpenRouter API key available as OPENROUTER_API_KEY
  • Node.js 20 or newer
  • A public HTTPS image URL available as FIRST_FRAME_URL
  • A model that supports frame_images, confirmed with GET /api/v1/videos/models
If you haven’t chosen a model yet, read Choose a Video Generation Model first. It helps you pick one based on clip duration, output shape, input type, audio, provider controls, and cost.
Use the API reference pages as the source of truth for exact fields:
Submitting POST /api/v1/videos starts a real video generation job and may spend OpenRouter credits.
frame_images is for exact frame control. Combining frame_images with input_references in one request is provider-specific, and GET /api/v1/videos/models does not advertise the combination policy: supported_frame_images and the input modalities describe each field on its own. Representative policies today: Alibaba, xAI, and HeyGen Video 1 reject the combination (the request fails with a 400, returned either by POST /api/v1/videos or as the job’s terminal failed status); BytePlus Seedance uses the frame images and ignores the references; Atlas Cloud does the same, except that a request with only a last_frame image takes its first frame from the first image reference; Runway uses both, applying image references as style guidance alongside the frame anchors. Other models accept each field on its own, and their combination behavior is not listed here. Send one or the other unless you have confirmed the model’s policy with a test request. Use a stable, directly downloadable image URL. Some providers cannot fetch image URLs that require cookies, redirects through HTML pages, bot checks, or unusual headers. Before submitting, check that your image URL returns 200 with an image content type:
Example output:

Step 1: Choose a model with frame-image support

Fetch the model list and choose a model whose supported_frame_images includes the frame type you want:
Example model output excerpt:
For first-frame and last-frame control, look for supported_frame_images containing first_frame and last_frame.

Step 2: Submit the image-to-video job

Build the video request with frame_images when the image should anchor an exact frame. This example uses a first frame. Put the same request shape in whatever server route, queue, or worker owns video generation in your app. Validate duration, resolution, and aspect_ratio against the selected model’s supported fields from the video models API before submitting. Unsupported values return a 400 with the supported values.
The submit call returns the job fields immediately. In the QA run, the submitted job later completed and downloaded with this final summary:

Step 3: Use a last frame when you need a transition

If the selected model supports last_frame, add both frames so the model can move from a known starting composition to a known ending composition:
Then set frame_images in the request body to frameImages. Request shape for the optional last-frame path:
This is useful when you want the video to move from a known starting composition to a known ending composition.

Step 4: Poll and download

After submission, poll from a server route, worker, or job runner instead of the browser. Poll with a limit, stop on terminal failure, then download the completed video. Example polling and download helper:
The QA run saved the finished video after polling completed:

Check your work

The first frame of the resulting video should closely match the image you provided as first_frame. If you also supplied last_frame, the clip should resolve toward that image. The implementation should produce a playable MP4 from the completed job.