Skip to content

feat(provider/xai): add video extension and reference-to-video (R2V) support#13887

Merged
felixarntz merged 3 commits intovercel:mainfrom
Jaaneek:feat/xai-video-extension-r2v
Apr 2, 2026
Merged

feat(provider/xai): add video extension and reference-to-video (R2V) support#13887
felixarntz merged 3 commits intovercel:mainfrom
Jaaneek:feat/xai-video-extension-r2v

Conversation

@Jaaneek
Copy link
Copy Markdown
Contributor

@Jaaneek Jaaneek commented Mar 27, 2026

Background

The xAI video API supports five generation modes, but the SDK only implemented three (text-to-video, image-to-video, editing). Video extension (POST /v1/videos/extensions) and reference-to-video/R2V (POST /v1/videos/generations with reference_images) were missing. The xAI provider docs were also outdated, still referencing grok-4-fast-non-reasoning and missing grok-4.20 models, grok-imagine-image-pro, and the new video modes.

Summary

Provider (@ai-sdk/xai):

  • Add video extension support via extensionUrl provider option → POST /v1/videos/extensions
  • Add reference-to-video (R2V) support via referenceImageUrls provider option (1–7 images) → POST /v1/videos/generations.
  • Surface progress field in provider metadata
  • Add error to response schema (defensive)
  • Fix prompt: options.prompt ?? '' for image-to-video without text

Documentation:

  • Add Video Extension and R2V sections with code examples
  • Document extensionUrl and referenceImageUrls provider options
  • Document grok-imagine-image-pro with resolution (1k/2k) and quality options
  • Update all code examples to grok-4.20-reasoning / grok-4.20-non-reasoning
  • Update model capabilities table with grok-4.20 models
  • Update video capabilities table with Extension and R2V columns
  • Switch examples and docs from { videos } to { video } (singular). I feel like this is better since xAI does not allow multiple videos generation but let me know.

Examples:

  • New: extend.ts, extend-warnings.ts, reference-images.ts
  • Updated: basic.ts, edit-concurrent.ts, edit-warnings.ts with null-safe metadata access and { video } pattern

Tests: 62 total (up from ~25), covering all new modes, validation, edge cases, polling, and metadata.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

  • Surface error.message from API in failed status handler (xAI doesn't document this field yet)
  • Consider adding optional url property to core GeneratedFile to avoid providerMetadata dance for chaining

@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label documentation Improvements or additions to documentation feature New feature or request provider/xai Issues related to the @ai-sdk/xai provider labels Mar 27, 2026
@Jaaneek Jaaneek force-pushed the feat/xai-video-extension-r2v branch 2 times, most recently from 609acb7 to 964ce85 Compare March 30, 2026 16:08
@Jaaneek Jaaneek force-pushed the feat/xai-video-extension-r2v branch 3 times, most recently from 71cfb3a to 15e8fe0 Compare April 1, 2026 22:44
Copy link
Copy Markdown
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaaneek This looks great! almost good to go, just running into one problem with the video editing example.

| XaiLegacyEditVideoOptions
| XaiLegacyReferenceToVideoOptions;

export interface XaiParsedVideoModelOptions extends XaiVideoSharedOptions {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the name of this one. Isn't it rather the "unparsed" version? if I understand correctly, this only exists for back compat, i.e. legacy, or not? If so, maybe call it XaiLegacyVideoModelOptions and mark it as deprecated?

This way people don't have to switch right away, but they'd be encouraged to update their providerOptions usage to rely on XaiVideoModelOptions soon.

…support

feat(provider/xai): add explicit video modes
@Jaaneek Jaaneek force-pushed the feat/xai-video-extension-r2v branch from 15e8fe0 to 109d4b0 Compare April 2, 2026 18:12
Copy link
Copy Markdown
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaaneek Thanks, everything working great now. Good to merge, and then I'll backport to v6!

@felixarntz felixarntz added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 2, 2026
@felixarntz felixarntz merged commit f51c95e into vercel:main Apr 2, 2026
20 of 21 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Apr 2, 2026
@vercel-ai-sdk vercel-ai-sdk bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 2, 2026
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Apr 2, 2026

⚠️ Backport to release-v6.0 created but has conflicts: #14079

felixarntz added a commit that referenced this pull request Apr 2, 2026
…deo (R2V) support (#14079)

This is an automated backport of #13887 to the release-v6.0 branch. FYI
@Jaaneek
~~This backport has conflicts that need to be resolved manually.~~
Conflicts resolved.

### `git cherry-pick` output

```
Auto-merging content/providers/01-ai-sdk-providers/01-xai.mdx
Auto-merging packages/xai/src/xai-video-model.test.ts
Auto-merging packages/xai/src/xai-video-model.ts
CONFLICT (content): Merge conflict in packages/xai/src/xai-video-model.ts
error: could not apply f51c95e... feat(provider/xai): add video extension and reference-to-video (R2V) support (#13887)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
```

---------

Co-authored-by: Jaaneek <25470423+Jaaneek@users.noreply.github.com>
Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label documentation Improvements or additions to documentation feature New feature or request provider/xai Issues related to the @ai-sdk/xai provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants