SpyBara
Go Premium

Documentation 2026-10-08 23:58 UTC to 2026-10-09 23:59 UTC

4 files changed +26 −36. View all changes and history on the product overview
2026
Sun 11 03:59 Sat 10 23:59 Fri 9 23:59 Thu 8 23:58 Wed 7 23:59 Tue 6 22:57 Mon 5 22:59 Sun 4 23:58 Sat 3 23:58 Fri 2 23:57 Thu 1 23:57
Details

20 20 

21## Concurrent Requests21## Concurrent Requests

22 22 

23When you need to apply several edits to the same source video, run requests concurrently. This is useful for branching multiple edits from the same intermediate result.23When you need to apply several edits to the same source video, run requests concurrently.

24 24 

25```javascript customLanguage="javascriptAISDK"25```javascript customLanguage="javascriptAISDK"

26import { xai, type XaiVideoModelOptions } from "@ai-sdk/xai";26import { xai, type XaiVideoModelOptions } from "@ai-sdk/xai";

27import { experimental_generateVideo as generateVideo } from "ai";27import { experimental_generateVideo as generateVideo } from "ai";

28 28 

29const providerOptions = {29const sourceVideo = "https://media.x.ai/v1/docs/i2v-portrait-wave-4cb4c17c.mp4";

30 xai: {

31 mode: "edit-video",

32 videoUrl: "https://example.com/source-video.mp4",

33 pollTimeoutMs: 600000,

34 } satisfies XaiVideoModelOptions,

35};

36 

37const step1 = await generateVideo({

38 model: xai.video("grok-imagine-video"),

39 prompt: "Add a party hat to the person",

40 providerOptions,

41});

42 30 

43const step1VideoUrl = step1.providerMetadata?.xai?.videoUrl as string;31const prompts = [

32 "Give the woman a silver necklace",

33 "Change the color of the woman's outfit to red",

34 "Give the woman a wide-brimmed black hat",

35];

44 36 

45const [withSunglasses, withScarf] = await Promise.all([37const results = await Promise.all(

38 prompts.map(prompt =>

46 generateVideo({39 generateVideo({

47 model: xai.video("grok-imagine-video"),40 model: xai.video("grok-imagine-video"),

48 prompt: "Add sunglasses",41 prompt,

49 providerOptions: {42 providerOptions: {

50 xai: {43 xai: {

51 mode: "edit-video",44 mode: "edit-video",

52 videoUrl: step1VideoUrl,45 videoUrl: sourceVideo,

53 pollTimeoutMs: 600000,46 pollTimeoutMs: 600000,

54 } satisfies XaiVideoModelOptions,47 } satisfies XaiVideoModelOptions,

55 },48 },

56 }),49 }),

57 generateVideo({50 ),

58 model: xai.video("grok-imagine-video"),51);

59 prompt: "Add a scarf",

60 providerOptions: {

61 xai: {

62 mode: "edit-video",

63 videoUrl: step1VideoUrl,

64 pollTimeoutMs: 600000,

65 } satisfies XaiVideoModelOptions,

66 },

67 }),

68]);

69 52 

70console.log(withSunglasses.providerMetadata?.xai?.videoUrl);53prompts.forEach((prompt, i) => {

71console.log(withScarf.providerMetadata?.xai?.videoUrl);54 console.log(`${prompt}: ${results[i].providerMetadata?.xai?.videoUrl}`);

55});

72```56```

73 57 

74```python customLanguage="pythonXAI"58```python customLanguage="pythonXAI"

Details

134print(response.url)134print(response.url)

135```135```

136 136 

137Video editing uses the `/v1/videos/edits` endpoint and `client.video.generate(video_url=...)` in the Python SDK. In the AI SDK, set `providerOptions.xai.mode` to `"edit-video"` or `"extend-video"` and pass `providerOptions.xai.videoUrl`. The same asynchronous polling pattern applies to both flows, and the AI SDK returns the SpaceXAI-hosted output URL in `providerMetadata.xai.videoUrl`.137Extension runs asynchronously:

138 

139* **REST API** — `POST /v1/videos/extensions` returns a `request_id`. Poll `GET /v1/videos/{request_id}` until `status` is `done`.

140* **Python SDK** — `client.video.extend()` polls for you and returns the finished video.

141* **AI SDK** — Set `providerOptions.xai.mode` to `"extend-video"` and pass the source in `providerOptions.xai.videoUrl`. The result URL is in `providerMetadata.xai.videoUrl`.

142 

143To change what happens inside a video instead of continuing it, see [Video Editing](/developers/model-capabilities/video/editing).

138 144 

139## Related145## Related

140 146 

Details

8 8 

9In the Vercel AI SDK, set `providerOptions.xai.mode` to `"reference-to-video"` and pass the images with `providerOptions.xai.referenceImageUrls`.9In the Vercel AI SDK, set `providerOptions.xai.mode` to `"reference-to-video"` and pass the images with `providerOptions.xai.referenceImageUrls`.

10 10 

11Prompts are capped at 4,096 bytes. With many references, give each one a single role and a fixed place in the scene, keep the cast small, and keep props static.11With many references, give each one a single role and a fixed place in the scene, keep the cast small, and keep props static.

12 12 

13| Limit | Value |13| Limit | Value |

14|-------|-------|14|-------|-------|

rate-limits.md +2 −2

Details

41| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |41| grok-4.20-0309-non-reasoning | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

42| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |42| grok-build-0.1 | T0: 37, T1: 50, T2: 75, T3: 125, T4: 208 | T0: 10M, T1: 15M, T2: 25M, T3: 45M, T4: 85M |

43| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |43| grok-4.20-multi-agent-0309 | T0: 9, T1: 12, T2: 18, T3: 31, T4: 56 | T0: 2.5M, T1: 3.7M, T2: 6.2M, T3: 11M, T4: 21M |

44| grok-imagine-image-2.0 | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

45| grok-imagine-image-quality | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

46| grok-imagine-image | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |44| grok-imagine-image | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

45| grok-imagine-image-quality | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

46| grok-imagine-image-2.0 | T0: 6, T1: 12, T2: 25, T3: 50, T4: 100 | — |

47| grok-imagine-video | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |47| grok-imagine-video | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

48| grok-imagine-video-1.5-lite | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |48| grok-imagine-video-1.5-lite | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |

49| grok-imagine-video-1.5 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |49| grok-imagine-video-1.5 | T0: 10, T1: 20, T2: 39, T3: 79, T4: 158 | — |