1- ---
2- hidden : true
3- noIndex : true
4- ---
5-
61# v5.5/image-to-video
72
83{% columns %}
94{% column width="66.66666666666666%" %}
105{% hint style="info" %}
116This documentation is valid for the following list of our models:
127
13- * ` pixverse/v5.5/ image-to-video `
8+ * ` pixverse/v5-5- image-to-video `
149{% endhint %}
1510{% endcolumn %}
1611
@@ -19,7 +14,7 @@ This documentation is valid for the following list of our models:
1914{% endcolumn %}
2015{% endcolumns %}
2116
22-
17+ The model generates high-quality video clips from text combined with an image, delivering smooth motion and sharp visual detail.
2318
2419## Setup your API Key
2520
@@ -56,13 +51,13 @@ This endpoint creates and sends a video generation task to the server — and re
5651After sending a request for video generation, this task is added to the queue. This endpoint lets you check the status of a video generation task using its ` id ` , obtained from the endpoint described above.\
5752If the video generation task status is ` complete ` , the response will include the final result — with the generated video URL and additional metadata.
5853
59- {% openapi-operation spec="pixverse- fetch" path="/v2/generate/ video/pixverse/generation " method="get" %}
60- [ OpenAPI pixverse- fetch] ( https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/video-models/PixVerse/v5-text-to-video -pair.json )
54+ {% openapi-operation spec="universal-video-endpoint- fetch" path="/v2/video/generations " method="get" %}
55+ [ OpenAPI universal-video-endpoint- fetch] ( https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/video-models/ByteDance/omnihuman -pair.json )
6156{% endopenapi-operation %}
6257
6358## Full Example: Generating and Retrieving the Video From the Server
6459
65- The code below creates a video generation task, then automatically polls the server every ** 10 ** seconds until it finally receives the video URL.
60+ The code below creates a video generation task, then automatically polls the server every ** 15 ** seconds until it finally receives the video URL.
6661
6762{% tabs %}
6863{% tab title="Python" %}
@@ -71,23 +66,21 @@ The code below creates a video generation task, then automatically polls the ser
7166import requests
7267import time
7368
74- # replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key
69+ # Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key
7570api_key = " <YOUR_AIMLAPI_KEY>"
7671base_url = " https://api.aimlapi.com/v2"
7772
78-
7973# Creating and sending a video generation task to the server
8074def generate_video ():
81- url = f " { base_url} /generate/ video/pixverse/generation "
75+ url = f " { base_url} /video/generations "
8276 headers = {
8377 " Authorization" : f " Bearer { api_key} " ,
8478 }
8579
8680 data = {
87- " model" : " pixverse/v5/ image-to-video" ,
81+ " model" : " pixverse/v5-5- image-to-video" ,
8882 " prompt" : " Mona Lisa puts on glasses with her hands." ,
8983 " image_url" : " https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg" ,
90- " duration" : 5
9184 }
9285
9386 response = requests.post(url, json = data, headers = headers)
@@ -96,18 +89,17 @@ def generate_video():
9689 print (f " Error: { response.status_code} - { response.text} " )
9790 else :
9891 response_data = response.json()
99- print (response_data)
92+ # print(response_data)
10093 return response_data
10194
10295
10396# Requesting the result of the task from the server using the generation_id
10497def get_video (gen_id ):
105- url = f " { base_url} /generate/ video/pixverse/generation "
98+ url = f " { base_url} /video/generations "
10699 params = {
107100 " generation_id" : gen_id,
108101 }
109102
110- # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
111103 headers = {
112104 " Authorization" : f " Bearer { api_key} " ,
113105 " Content-Type" : " application/json"
@@ -118,36 +110,36 @@ def get_video(gen_id):
118110 return response.json()
119111
120112
113+
121114def main ():
122115 # Running video generation and getting a task id
123116 gen_response = generate_video()
124117 gen_id = gen_response.get(" id" )
125118 print (" Generation ID: " , gen_id)
126119
127- # Trying to retrieve the video from the server every 10 sec
120+ # Try to retrieve the video from the server every 15 sec
128121 if gen_id:
129122 start_time = time.time()
130123
131- timeout = 600
124+ timeout = 1000
132125 while time.time() - start_time < timeout:
133126 response_data = get_video(gen_id)
134127
135128 if response_data is None :
136129 print (" Error: No response from API" )
137130 break
138-
139- status = response_data.get(" status" )
140- print (" Status:" , status)
141131
142- if status == " waiting" or status == " active" or status == " queued" or status == " generating" :
143- print (" Still waiting... Checking again in 10 seconds." )
144- time.sleep(10 )
132+ status = response_data.get(" status" )
133+
134+ if status in [" waiting" , " queued" , " generating" ]:
135+ print (f " Status: { status} . Checking again in 15 seconds. " )
136+ time.sleep(15 )
145137 else :
146- print (" Processing complete:/ n" , response_data)
138+ print (" Processing complete:\ n" , response_data)
147139 return response_data
148-
140+
149141 print (" Timeout reached. Stopping." )
150- return None
142+ return None
151143
152144
153145if __name__ == " __main__" :
@@ -169,13 +161,13 @@ const baseUrl = "https://api.aimlapi.com/v2";
169161// Creating and sending a video generation task to the server
170162function generateVideo (callback ) {
171163 const data = JSON .stringify ({
172- model: " pixverse/v5/ image-to-video" ,
164+ model: " pixverse/v5-5- image-to-video" ,
173165 prompt: " Mona Lisa puts on glasses with her hands." ,
174166 image_url: " https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg" ,
175167 duration: 5 ,
176168 });
177169
178- const url = new URL (` ${ baseUrl} /generate/ video/pixverse/generation ` );
170+ const url = new URL (` ${ baseUrl} /video/generations ` );
179171 const options = {
180172 method: " POST" ,
181173 headers: {
@@ -206,7 +198,7 @@ function generateVideo(callback) {
206198
207199// Requesting the result of the task from the server using the generation_id
208200function getVideo (genId , callback ) {
209- const url = new URL (` ${ baseUrl} /generate/ video/pixverse/generation ` );
201+ const url = new URL (` ${ baseUrl} /video/generations ` );
210202 url .searchParams .append (" generation_id" , genId);
211203
212204 const options = {
@@ -230,46 +222,45 @@ function getVideo(genId, callback) {
230222 req .end ();
231223}
232224
233- // Initiates video generation and checks the status every 10 seconds until completion or timeout
225+ // Initiates video generation and checks the status every 15 seconds until completion or timeout
234226function main () {
235- generateVideo ((genResponse ) => {
236- if (! genResponse || ! genResponse .id ) {
237- console .error (" Failed to start generation" );
238- return ;
239- }
240-
241- const genId = genResponse .id ;
242- console .log (" Gen_ID:" , genId);
243-
244- const startTime = Date .now ();
245- const timeout = 600000 ;
227+ generateVideo ((genResponse ) => {
228+ if (! genResponse || ! genResponse .id ) {
229+ console .error (" No generation ID received." );
230+ return ;
231+ }
246232
247- const checkStatus = () => {
248- if (Date .now () - startTime > timeout) {
249- console .log (" Timeout reached. Stopping." );
250- return ;
251- }
233+ const genId = genResponse .id ;
234+ console .log (" Generation ID:" , genId);
252235
253- getVideo (genId, (responseData ) => {
254- if (! responseData) {
255- console .error (" Error: No response from API" );
256- return ;
257- }
236+ const timeout = 1000 * 1000 ; // 1000 sec
237+ const interval = 15 * 1000 ; // 15 sec
238+ const startTime = Date .now ();
258239
259- const status = responseData .status ;
260- console .log (" Status:" , status);
240+ const checkStatus = () => {
241+ if (Date .now () - startTime >= timeout) {
242+ console .log (" Timeout reached. Stopping." );
243+ return ;
244+ }
261245
262- if ([" waiting" , " active" , " queued" , " generating" ].includes (status)) {
263- console .log (" Still waiting... Checking again in 10 seconds." );
264- setTimeout (checkStatus, 10000 );
265- } else {
266- console .log (" Processing complete:\n " , responseData);
267- }
268- });
269- };
246+ getVideo (genId, (responseData ) => {
247+ if (! responseData) {
248+ console .error (" Error: No response from API" );
249+ return ;
250+ }
270251
271- checkStatus ();
272- });
252+ const status = responseData .status ;
253+
254+ if ([" waiting" , " queued" , " generating" ].includes (status)) {
255+ console .log (` Status: ${ status} . Checking again in 15 seconds.` );
256+ setTimeout (checkStatus, interval);
257+ } else {
258+ console .log (" Processing complete:\n " , responseData);
259+ }
260+ });
261+ };
262+ checkStatus ();
263+ })
273264}
274265
275266main ();
@@ -284,29 +275,21 @@ main();
284275
285276{% code overflow="wrap" %}
286277``` json5
287- {' id' : ' 8ac142d3-7c9f-4071-bdc6-d0f2d3d9b327:pixverse/v5/image-to-video' , ' status' : ' queued' , ' meta' : {' usage' : {' tokens_used' : 420000 }}}
288- Generation ID : 8ac142d3 - 7c9f - 4071 - bdc6- d0f2d3d9b327: pixverse/ v5/ image- to- video
289- Status: generating
290- Still waiting... Checking again in 10 seconds.
291- Status: generating
292- Still waiting... Checking again in 10 seconds.
293- Status: generating
294- Still waiting... Checking again in 10 seconds.
295- Status: generating
296- Still waiting... Checking again in 10 seconds.
297- Status: generating
298- Still waiting... Checking again in 10 seconds.
299- Status: completed
300- Processing complete: / n {'id': '8ac142d3-7c9f-4071-bdc6-d0f2d3d9b327:pixverse/ v5/ image- to- video' , ' status' : ' completed' , ' video' : {' url' : ' https: // cdn.aimlapi.com/eagle/files/elephant/uCLDKRtL_AeOrRAwiR8UH_output.mp4', 'content_type': 'video/mp4', 'file_name': 'output.mp4', 'file_size': 4259218}}
278+ Generation ID : jCajo_YQuMr5As6lN1lSg
279+ Status: queued . Checking again in 15 seconds.
280+ Status: generating . Checking again in 15 seconds.
281+ Status: generating . Checking again in 15 seconds.
282+ Processing complete:
283+ {' id' : ' jCajo_YQuMr5As6lN1lSg' , ' status' : ' succeeded' , ' video' : {' url' : ' https://cdn.aimlapi.com/panda/pixverse%2Fmp4%2Fmedia%2Fweb%2Fori%2FtFzvIwK3x79Lvz8cknMvj_seed2144515801.mp4' }}
301284```
302285{% endcode %}
303286
304287</details >
305288
306- ** Processing time** : \~ 1.5 min .
289+ ** Processing time** : \~ 50 s .
307290
308- ** Original** : [ 864x1280] ( https://drive.google.com/file/d/1kld9uy5nb-R_9D0JrbWLFhE3z171WHTw /view?usp=sharing )
291+ ** Original** : [ 864x1280] ( https://drive.google.com/file/d/1Bn6g08TSUixk_Zc3e2BQyguljle_B7Iq /view?usp=sharing )
309292
310293** Low-res GIF preview** :
311294
312- <div align =" left " ><figure ><img src =" ../../../.gitbook/assets/pixverse-v5-image-to-video_preview.gif " alt =" " ><figcaption ><p ><code >"Mona Lisa puts on glasses with her hands."</code ></p ></figcaption ></figure ></div >
295+ <div align =" left " ><figure ><img src =" ../../../.gitbook/assets/pixverse-v5-5- image-to-video_preview.gif " alt =" " ><figcaption ><p ><code >"Mona Lisa puts on glasses with her hands."</code ></p ></figcaption ></figure ></div >
0 commit comments