Skip to main content
Generate images and videos from an action with bijectionGateway. For installation and authentication, see Getting started. The examples below run inside an action handler.

Generate images

Image generation is in alphaThe request and response format may change during alpha.

Generate videos

Video generation is in alphaThe request and response format may change during alpha.
The call waits for the video, then downloads it. The default timeout is ten minutes; the download limit is 64 MiB. Save video.uint8Array in file storage. The AI SDK splits n > 1 into separate requests. Cancelling a request does not cancel generation. A timeout or lost response can still incur a charge. An image in the prompt becomes the first frame. Set frameImages to choose frames, inputReferences to pass image, audio, or video references, and generateAudio to include audio. fps is unsupported and returns a warning. providerOptions.bijectionGateway accepts resolution (such as 720p), generate_audio, frame_images, and input_references. Standard SDK options take precedence. Supported values depend on the OpenRouter model.

Async videos

Use experimental_startVideo when the action should return before the video is ready. If the gateway returns “Asynchronous video generation is not configured”, contact Bijection support. Completion callbacks are best effort. Save the operation handle so you can check status if a callback is missed. For local development, omit webhookUrl and use the status and download methods. Callbacks require a cloud deployment’s HTTPS bijection.site URL; localhost URLs are not accepted. Create a job in your database before submitting the request. Pass its ID as requestId so the callback handler can look up the job.
Save the returned fields on the job before the action returns. Keep webhookSecret private. maxRetries: 0 prevents automatic submission retries: a lost response can still mean a paid job was accepted. Callback URLs must use the deployment’s own HTTPS <deployment>.bijection.site origin; redirects are rejected. If BIJECTION_SITE_URL uses a custom domain, use the deployment’s default bijection.site origin in the example instead.

Receive a callback

In an HTTP action, load the job using requestId and verify the raw request body:
Save the event in a mutation. Check (event.id, event.status) in that mutation so repeated callbacks update the job once. For completed, schedule an action to download the video. failed, cancelled, and expired are terminal errors. Return 204 after saving the event. If the job’s secret has not been saved yet, return a non-2xx response.

Retrieve the video

In a later action, use the saved operation to check status and download:
getStatus returns pending, completed, or error. When the status is error, the error field contains the error message. Save the downloaded video in file storage; each download call fetches it again. Operations expire after seven days. The provider may retain the video for less time. Omit webhookUrl to use status checks alone. If a completion callback is missed, use the saved operation to check the job and retrieve its result. Applications that need automatic recovery can periodically check unfinished jobs.