generateVideo
Generate video, polling until the job completes.
Video generation is asynchronous at every provider. This call submits the job and polls until it finishes, so you await one result instead of managing the job yourself.
Expect it to take minutes. Give the surrounding call a generous timeout.
let result = try await generateVideo(
model: XaiVideoModel("grok-video"),
prompt: "A timelapse of clouds over a city"
)Signature
func generateVideo(
model: any VideoModel,
prompt: String,
image: ImageContent? = nil,
aspectRatio: String? = nil,
duration: Int? = nil,
providerOptions: JSONValue? = nil,
maxRetries: Int = 2
) async throws -> GenerateVideoResultDefined in Sources/AI/Core/VideoGeneration.swift.
Parameters
| Parameter | Type | Default |
|---|---|---|
model | any VideoModel | required |
prompt | String | required |
image | ImageContent? | nil |
aspectRatio | String? | nil |
duration | Int? | nil |
providerOptions | JSONValue? | nil |
maxRetries | Int | 2 |
Returns
GenerateVideoResult with the video file and providerMetadata.