Skip to main content

Video operations

ai.ExperimentalStartVideo starts a video generation and returns without waiting. ai.ExperimentalGetVideoStatus checks the operation later, from any process. Use them for long-running generations. The model must implement provider.VideoModelStarter.

func ExperimentalStartVideo(ctx context.Context, opts StartVideoOptions) (*StartVideoResult, error)
func ExperimentalGetVideoStatus(ctx context.Context, model provider.VideoModelV3, opts GetVideoStatusOptions) (*GetVideoStatusResult, error)

StartVideoOptions​

FieldTypeDescription
Modelprovider.VideoModelV3Model to use. Must implement provider.VideoModelStarter.
PromptVideoPromptPrompt can be text-only or image+text for image-to-video.
NintNumber of videos to generate (default: 1). Must not exceed the model's MaxVideosPerCall — fan out with multiple StartVideo calls.
MaxVideosPerCall*intMaximum videos per API call (provider-specific). If not set, uses the model's MaxVideosPerCall() value for the limit check.
AspectRatiostringAspect ratio in format "width:height", or "adaptive".
ResolutionstringResolution in format "widthxheight".
Duration*float64Duration in seconds.
FPS*intFrames per second.
Seed*intSeed for reproducible generation.
FrameImages[]VideoFrameImageInputFrameImages are role-tagged image inputs for image-to-video and first-last-frame generation.
InputReferences[]VideoReferenceInputInputReferences are reference image or video inputs for reference-to-video generation.
GenerateAudio*boolGenerateAudio requests that the model generate audio alongside the video, when supported.
ProviderOptionsmap[string]interface{}Provider-specific options.
MaxRetries*intMaximum retries for the start call (default: 2). Set to 0 to disable.
Headersmap[string]stringAdditional HTTP headers.
WebhookURLstringWebhookURL, when set, asks the provider to notify this URL when the generation reaches a terminal state.

StartVideoResult​

Operation is an opaque JSON value. Persist it and pass it to ExperimentalGetVideoStatus.

FieldTypeDescription
Operationjson.RawMessageOperation is a JSON-serializable opaque reference to the started generation. Persist it and pass it to ExperimentalGetVideoStatus to retrieve the status and result later, from any process.
Warnings[]types.WarningWarnings for the call, e.g. unsupported settings.
ProviderMetadatamap[string]interface{}ProviderMetadata is passed through from the provider. Carries the provider's own job identifiers (e.g. the AI Gateway's providerMetadata.gateway.asyncJob.jobId).
ResponseVideoModelResponseMetadataResponse is response metadata from the provider.

GetVideoStatusOptions​

FieldTypeDescription
Operationjson.RawMessageOperation is the opaque reference returned by ExperimentalStartVideo.
Headersmap[string]stringAdditional HTTP headers.
MaxRetries*intMaximum retries for the status call (default: 2). Set to 0 to disable.

GetVideoStatusResult​

Status is one of the provider.VideoOperationStatus* constants. Videos is set when the status is completed. Error is set when the status is error.

FieldTypeDescription
Statusstring
Videos[]provider.VideoModelV3VideoDataVideos is set when Status is provider.VideoOperationStatusCompleted.
ErrorstringError is set when Status is provider.VideoOperationStatusError.
Warnings[]types.Warning
ProviderMetadatamap[string]interface{}
ResponseVideoModelResponseMetadata

VideoFrameImageInput​

A role-tagged image for image-to-video and first-and-last-frame generation.

FieldTypeDescription
ImageVideoPromptImageImage is the file used for this frame.
FrameTypestringFrameType is provider.VideoFrameTypeFirstFrame or provider.VideoFrameTypeLastFrame.

Errors​

ai.IsNoVideoGeneratedError(err) reports whether err is a *ai.NoVideoGeneratedError.