# `Xai.Video`
[🔗](https://github.com/beamlab-xai/xai/blob/main/lib/xai/video.ex#L1)

Video generation (Imagine API) via gRPC.

Mirrors `client.video` in the official Python xai-sdk.
The high-level functions automatically handle the deferred/poll pattern.

## Options

Option names follow the Python SDK's `client.video.generate`.

  * `:prompt` (required), `:model`, `:duration`
  * `:aspect_ratio` - `"16:9"`, `"9:16"`, `"1:1"`, `"4:3"`, `"3:4"`, `"3:2"`, `"2:3"`
    (or the proto atom, e.g. `:VIDEO_ASPECT_RATIO_16_9`)
  * `:resolution` - `"480p"`, `"720p"`, `"1080p"` (or the proto atom)
  * `:image_url` / `:image_file_id` - first frame (image-to-video)
  * `:last_frame_url` / `:last_frame_file_id` - last frame
  * `:keyframes` - `[%{image_url: url, timestamp: 2.5}, %{image_file_id: id, timestamp: 4}]`
  * `:video_url` / `:video_file_id` - source video (editing)
  * `:reference_image_urls` / `:reference_image_file_ids` - style/content references
  * `:reference_audios` - `[%{voice_id: "ara"}]`
  * `:generate_audio` - generate audio with the video
  * `:storage_options` - store the result in the Files API:
    `%{filename: "clip.mp4", expires_after: 3600, public_url: true}`
    (`public_url` may also be `%{expires_after: seconds}`)
  * `:timeout` - per-request timeout

Within each URL/file-ID pair only one may be given; both raises `ArgumentError`.
`extend/2` accepts `:prompt`, `:model`, `:duration`, `:video_url` or
`:video_file_id`, and `:storage_options`.

# `extend`

```elixir
@spec extend(Xai.Client.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

Extend a video

# `generate`

```elixir
@spec generate(Xai.Client.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

Generate a video.

Example:

    {:ok, video} = Xai.Video.generate(client,
      prompt: "A cat on a skateboard",
      model: "grok-imagine-video",
      duration: 5
    )

---

*Consult [api-reference.md](api-reference.md) for complete listing*
