10 10
11> [!WARNING]11> [!WARNING]
12 12
13Refer to reference images in the prompt by their position in the list, starting at `<IMAGE_0>` for the first image, then `<IMAGE_1>`, and so on.
14
13```python customLanguage="pythonXAI"15```python customLanguage="pythonXAI"
14import os16import os
15import xai_sdk17import xai_sdk
17client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))19client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))
18 20
19response = client.video.generate(21response = client.video.generate(
20 prompt="slow zoom in on the white fashion runway stage. then, the model from <IMAGE_1> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_2> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",22 prompt="slow zoom in on the white fashion runway stage. then, the model from <IMAGE_0> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_1> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",
21 model="grok-imagine-video-1.5",23 model="grok-imagine-video-1.5",
22 reference_image_urls=[24 reference_image_urls=[
23 "<IMAGE_URL_1>",25 "<IMAGE_URL_1>",
47 headers=headers,49 headers=headers,
48 json={50 json={
49 "model": "grok-imagine-video-1.5",51 "model": "grok-imagine-video-1.5",
50 "prompt": "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_1> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_2> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",52 "prompt": "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_0> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_1> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",
51 "reference_images": [53 "reference_images": [
52 {"url": "<IMAGE_URL_1>"},54 {"url": "<IMAGE_URL_1>"},
53 {"url": "<IMAGE_URL_2>"},55 {"url": "<IMAGE_URL_2>"},
82 84
83const result = await generateVideo({85const result = await generateVideo({
84 model: xai.video("grok-imagine-video-1.5"),86 model: xai.video("grok-imagine-video-1.5"),
85 prompt: "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_1> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_2> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",87 prompt: "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_0> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_1> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",
86 duration: 10,88 duration: 10,
87 aspectRatio: "16:9",89 aspectRatio: "16:9",
88 providerOptions: {90 providerOptions: {
110 -H "Authorization: Bearer $XAI_API_KEY" \112 -H "Authorization: Bearer $XAI_API_KEY" \
111 -d '{113 -d '{
112 "model": "grok-imagine-video-1.5",114 "model": "grok-imagine-video-1.5",
113 "prompt": "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_1> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_2> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",115 "prompt": "slow zoom in on the white fashion runway stage. then, the model from <IMAGE_0> walks in from the back of the shot from the white opening, and gracefully walk out onto the front of the white stage platform. they wear the shirt from <IMAGE_1> and black flared jeans. they look dramatically at the camera. high quality slow motion shot. fun, playful. skin pores. highly detailed faces. perfect shot. they reach the end of the runway and look at the camera as the camera slowly zooms. subtle smile.",
114 "reference_images": [116 "reference_images": [
115 {"url": "<IMAGE_URL_1>"},117 {"url": "<IMAGE_URL_1>"},
116 {"url": "<IMAGE_URL_2>"},118 {"url": "<IMAGE_URL_2>"},
154client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))156client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))
155 157
156response = client.video.generate(158response = client.video.generate(
157 prompt="The person from <IMAGE_1> presents the product from <IMAGE_2> on the set from <IMAGE_3>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",159 prompt="The person from <IMAGE_0> presents the product from <IMAGE_1> on the set from <IMAGE_2>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",
158 model="grok-imagine-video-1.5",160 model="grok-imagine-video-1.5",
159 reference_image_urls=[161 reference_image_urls=[
160 "<IMAGE_URL_1>",162 "<IMAGE_URL_1>",
188 headers=headers,190 headers=headers,
189 json={191 json={
190 "model": "grok-imagine-video-1.5",192 "model": "grok-imagine-video-1.5",
191 "prompt": "The person from <IMAGE_1> presents the product from <IMAGE_2> on the set from <IMAGE_3>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",193 "prompt": "The person from <IMAGE_0> presents the product from <IMAGE_1> on the set from <IMAGE_2>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",
192 "reference_images": [194 "reference_images": [
193 {"url": "<IMAGE_URL_1>"},195 {"url": "<IMAGE_URL_1>"},
194 {"url": "<IMAGE_URL_2>"},196 {"url": "<IMAGE_URL_2>"},
227 -H "Authorization: Bearer $XAI_API_KEY" \229 -H "Authorization: Bearer $XAI_API_KEY" \
228 -d '{230 -d '{
229 "model": "grok-imagine-video-1.5",231 "model": "grok-imagine-video-1.5",
230 "prompt": "The person from <IMAGE_1> presents the product from <IMAGE_2> on the set from <IMAGE_3>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",232 "prompt": "The person from <IMAGE_0> presents the product from <IMAGE_1> on the set from <IMAGE_2>, speaking with the voice from <AUDIO_0>. A second speaker with the voice from <AUDIO_1> replies.",
231 "reference_images": [233 "reference_images": [
232 {"url": "<IMAGE_URL_1>"},234 {"url": "<IMAGE_URL_1>"},
233 {"url": "<IMAGE_URL_2>"},235 {"url": "<IMAGE_URL_2>"},