Skip to main content
The AI Gateway serves OpenAI-compatible video endpoints, so your app can generate video from a prompt, from a still image, or from existing media, with control over the model, duration, aspect ratio, and resolution. Requests are billed to your app’s credits, with no separate provider account or API key.
Before you begin: Call the gateway from a backend function rather than the browser, so you can check who’s calling and control usage before a request is billed to your app. Get the baseURL and token from base44.aiGateway.connection().
Video generation is asynchronous. Creating a video returns a job straight away, and you poll it until it finishes. A single video can take minutes to render, so don’t hold a request open waiting for one.

Endpoints

The create endpoint accepts JSON or multipart/form-data and follows OpenAI’s request and response format, with a few Base44 fields added. Authenticate with Authorization: Bearer {token}.

Generate a video

Send a prompt and a model to POST /videos. Unlike the image endpoints, there’s no automatic option, so model is required. Use asServiceRole for the connection. An app that restricts Core integrations rejects user-token gateway calls unless it’s shared privately or with your workspace, and most new apps have that restriction on from the start. A user-token call works while you’re building and then starts failing once you share the app publicly. The mode changes which token you get and nothing else, so guard the function with base44.auth.me() to control who can spend your credits.
Start a video job
Store the returned id on an entity so you can check the job later, after the function that started it has returned.

Check the status

Poll GET /videos/{video_id} until status is completed or failed. A completed job carries the finished video’s url and the credits it used.
Check a video job
Status moves through queued, then in_progress, then either completed or failed. Poll from a scheduled function or from the browser on an interval, rather than looping inside the function that created the job. The entity write also uses asServiceRole here, because a scheduled poll runs with no signed-in user and row-level security would otherwise block it. That bypasses your entity’s permissions, so write only the job’s own result, and keep the record’s id in the function’s own state rather than taking it from the caller. The url points to a file in your app’s storage, so you can save it on an entity and play it back like any other file. GET /videos/{video_id}/content redirects to the same file, for clients that expect OpenAI’s download endpoint. It returns 409 while the video isn’t ready yet.

Start from an image

The frame_images field pins the video’s first or last frame to a still image. Use it to animate an image your app already has, such as a product photo or a generated image.
Animate a still image
You can set first_frame, last_frame, or both, and each frame_type may appear only once. On Veo models, a last_frame needs a first_frame alongside it. Grok Imagine Video accepts a first frame only. The input_references field is the other way to supply media, and it guides the whole clip instead of a single frame. Each reference is an image_url, video_url, or audio_url, and you can pass up to 8.
Guide a video with reference media
Use either frame_images or input_references in a request, never both. Every media URL must be a public https:// URL, so private files that your app owns don’t work here, unlike the reference images on the image endpoints.

Models

Set model to one of these IDs. Video models are separate from the chat models and the image models the gateway serves. A pinned model is never swapped for another one. If the model doesn’t support an option you set, the request fails with an error that names the option.

Defaults

Veo models default to 8 seconds at 720p, 16:9, with audio on. The other models have no gateway default, so leaving seconds, resolution, or aspect_ratio out lets the provider choose. Set them explicitly when the output needs a specific shape or length.

Request parameters

Any field that isn’t listed here is rejected rather than ignored.

Response

The url and completed_at fields stay null until the job finishes, and usage appears once the credits are recorded. A failed job carries an error object with a code and message instead of a url.

Estimate the cost

Set dry_run to true to see what a request would cost, without generating a video or using credits.
Estimate the cost of a request
Video requests use your app’s credits, the same shared quota as the rest of the AI Gateway. The cost of each video depends on the model, duration, and resolution, and video is considerably more expensive than image generation. Estimate with dry_run before you expose video generation to your app’s users.

Limits

Media is passed by URL, so the create endpoint doesn’t accept file uploads, and the request body stays small.

Errors

Errors use OpenAI’s format, { "error": { "message", "type", "code", "param" } }, so client libraries report them like any other OpenAI error. A job that fails after it’s accepted reports status: "failed" with an error object, rather than an HTTP error, because the create request already succeeded.

See also

  • ai-gateway: Get connection details and use chat models through the gateway.
  • Generate images: Generate and edit images through the gateway.
  • Backend functions: Write the server-side code that calls the gateway.