feat(provider/xai): add video extension and reference-to-video (R2V) support#13887
Conversation
609acb7 to
964ce85
Compare
71cfb3a to
15e8fe0
Compare
felixarntz
left a comment
There was a problem hiding this comment.
@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 { |
There was a problem hiding this comment.
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
15e8fe0 to
109d4b0
Compare
felixarntz
left a comment
There was a problem hiding this comment.
@Jaaneek Thanks, everything working great now. Good to merge, and then I'll backport to v6!
|
|
…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>
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/generationswithreference_images) were missing. The xAI provider docs were also outdated, still referencinggrok-4-fast-non-reasoningand missinggrok-4.20models,grok-imagine-image-pro, and the new video modes.Summary
Provider (
@ai-sdk/xai):extensionUrlprovider option →POST /v1/videos/extensionsreferenceImageUrlsprovider option (1–7 images) →POST /v1/videos/generations.progressfield in provider metadataerrorto response schema (defensive)prompt: options.prompt ?? ''for image-to-video without textDocumentation:
extensionUrlandreferenceImageUrlsprovider optionsgrok-imagine-image-prowithresolution(1k/2k) andqualityoptionsgrok-4.20-reasoning/grok-4.20-non-reasoning{ videos }to{ video }(singular). I feel like this is better since xAI does not allow multiple videos generation but let me know.Examples:
extend.ts,extend-warnings.ts,reference-images.tsbasic.ts,edit-concurrent.ts,edit-warnings.tswith null-safe metadata access and{ video }patternTests: 62 total (up from ~25), covering all new modes, validation, edge cases, polling, and metadata.
Checklist
pnpm changesetin the project root)Future Work
error.messagefrom API infailedstatus handler (xAI doesn't document this field yet)urlproperty to coreGeneratedFileto avoidproviderMetadatadance for chaining