Skip to content

Video Generation

Introduction

As artificial intelligence technology continues to advance, video generation models are gradually becoming an essential tool in the field of content creation. These models transform input text into dynamic videos, endowing words with visual effects and expanding the dimensions of expression. Not only do they help creators save significant time, but they also generate high-quality, creative visual content. The potential of Text-to-Video models has been fully demonstrated in various application scenarios, including education, advertising, and entertainment.

Next, we will explore some best practices for Text-to-Video models to help you better utilize this cutting-edge technology in practical operations.

Best Practices

Using MaaS_KL as an example

MaaS_KL provides a video generation method, which includes 2 APIs in total:

  1. First, use the video generation interface to create a video generation task, returning a task_id.

  2. Then, use the query task status interface to check the status of the task based on the task_id. When the status is successful, the URL of the generated video will be obtained.

Generate Video

Image-to-Video
curl --location 'https://genaiapi.cloudsway.net/v1/ai/xxx/kling/videos/image2video' \ 
--header 'Authorization: Bearer xxx' \ 
--header 'Content-Type: application/json' \ 
--data '{ "model_name":"kling-v1", 
"image":"https://pic1.zhimg.com/v2-0cbb2efa5a55f2e716eebe2d6a6eef67_r.jpg?source=12a79843", 
"prompt":"哪吒在练武"
Text-to-Video
curl --location 'https://genaiapi.cloudsway.net/v1/ai/XXX/kling/videos/text2video' \ 
--header 'Authorization: Bearer XXX' \ 
--header 'Content-Type: application/json' \ 
--data '{ "model_name":"kling-v1", 
"prompt":"小狗在草地上奔跑"

Return TaskID

The above requests will return a taskid

{
"code": 0, //错误码;具体定义见错误码
"message": "string", //错误信息
"request_id": "string", //请求ID,系统生成,用于跟踪请求、排查问题
"data": {
"task_id": "string", //任务ID,系统生成
"task_info": {
//任务创建时的参数信息
"external_task_id": "string" //客户自定义任务ID
},
"task_status": "string", //任务状态,枚举值:submitted(已提交)、processing(处理中)、succeed(成功)、failed(失败
"created_at": 1722769557708, //任务创建时间,Unix时间戳、单位ms
"updated_at": 1722769557708 //任务更新时间,Unix时间戳、单位ms
}
}

Query Video Task Result

Use the returned taskid to query the video task result.

Query Image-Based Video Task Status

curl -X GET "https://genaiapi.cloudsway.net/v1/ai/XXXX/kling/videos/image2video/{id}" \
  -H "Authorization: Bearer RWxxxxxxxx0Gd"

Query Text-Based Video Task Status

curl -X GET "https://genaiapi.cloudsway.net/v1/ai/XXXX/kling/videos/text2video/{id}" \
  -H "Authorization: Bearer RWxxxxxxxx0Gd"

Response

{
"code": 0, //错误码;具体定义见错误码
"message": "string", //错误信息
"request_id": "string", //请求ID,系统生成,用于跟踪请求、排查问题
"data":{
"task_id": "string", //任务ID,系统生成
"task_status": "string", //任务状态,枚举值:submitted(已提交)、processing(处理中)、succeed(成功)、failed(失败
"task_status_msg": "string", //任务状态信息,当任务失败时展示失败原因(如触发平台的内容风控等)
"task_info": { //任务创建时的参数信息
"external_task_id": "string"//客户自定义任务ID
},
"task_result":{
"videos":[
{
"id": "string", //生成的视频ID;全局唯一
"url": "string", //生成视频的URL,例如https://p1.a.kwimgs.com/bs2/upload-ylab-stunt/special-effect/
"duration": "string" //视频总时长,单位s
}
]
}
"created_at": 1722769557708, //任务创建时间,Unix时间戳、单位ms
"updated_at": 1722769557708, //任务更新时间,Unix时间戳、单位ms
}
}