# 文生视频

## 创建任务

### POST `/v1/videos/text2video`

```bash
curl --request POST \
  --url https://api-beijing.klingai.com/v1/videos/text2video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model_name": "kling-v2-6",
    "prompt": "一只可爱的小兔子，戴着眼镜，坐在桌边，看报纸，桌上放着一杯卡布奇诺",
    "negative_prompt": "",
    "duration": "5",
    "mode": "pro",
    "sound": "on",
    "aspect_ratio": "1:1",
    "callback_url": "",
    "external_task_id": ""
  }'
```

### 200

```json
{
  "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
  }
}
```

### 请求头

- Content-Type: string 必填 默认值 application/json

- Authorization: string 必填

### 请求体

- model_name: string 可选 默认值 kling-v1

- multi_shot: boolean 可选 默认值 false

- shot_type: string 可选

- prompt: string 可选

- multi_prompt: array 可选

- negative_prompt: string 可选

- sound: string 可选 默认值 off

- cfg_scale: float 可选 默认值 0.5

- mode: string 可选 默认值 std

- camera_control: object 可选

### 更多场景调用示例

#### 多镜头效果的文生视频

```bash
curl --location 'https://xxx/v1/videos/text2video' \
--header 'Authorization: Bearer xxx' \
--header 'Content-Type: application/json' \
--data '{
    "model_name": "kling-v3",
    "prompt": "",
    "multi_prompt": [
        {
            "index": 1,
            "prompt": "Two friends talking under a streetlight at night.  Warm glow, casual poses, no dialogue.",
            "duration": "2"
        },
        {
            "index": 2,
            "prompt": "A runner sprinting through a forest, leaves flying.  Low-angle shot, focus on movement.",
            "duration": "3"
        },
        {
            "index": 3,
            "prompt": "A woman hugging a cat, smiling.  Soft sunlight, cozy home setting, emphasize warmth.",
            "duration": "3"
        },
        {
            "index": 4,
            "prompt": "A door creaking open, shadowy hallway.  Dark tones, minimal details, eerie mood.",
            "duration": "3"
        },
        {
            "index": 5,
            "prompt": "A man slipping on a banana peel, shocked expression.  Exaggerated pose, bright colors.",
            "duration": "3"
        },
        {
            "index": 6,
            "prompt": "A sunset over mountains, small figure walking away.  Wide angle, peaceful atmosphere.",
            "duration": "1"
        }
    ],
    "multi_shot": true,
    "shot_type": "customize",
    "duration": "15",
    "mode": "pro",
    "sound": "on",
    "aspect_ratio": "9:16",
    "callback_url": "",
    "external_task_id": ""
}'
```

## 查询任务（单个）

GET `/v1/videos/text2video/{id}`

### cURL

```bash
curl --request GET \
  --url https://api-beijing.klingai.com/v1/videos/text2video/{task_id} \
  --header 'Authorization: Bearer <token>'
```

### 200

```json
{
  "code": 0, // 错误码；具体定义见错误码
  "message": "string", // 错误信息
  "request_id": "string", // 请求ID，系统生成，用于跟踪请求、排查问题
  "data": {
    "task_id": "string", // 任务ID，系统生成
    "task_status": "string", // 任务状态
    //... 其他参数
  }
}
```

## 查询任务（列表）

GET `/v1/videos/text2video`

### cURL

```bash
curl --request GET \
  --url 'https://api-beijing.klingai.com/v1/videos/text2video?pageNum=1&pageSize=30' \
  --header 'Authorization: Bearer <token>'
```

### 200

```json
{
  "code": 0, // 错误码；具体定义见错误码
  "message": "string", // 错误信息
  "request_id": "string", // 请求ID，系统生成，用于跟踪请求、排查问题
  "data": [
    {
      "task_id": "string", // 任务ID，系统生成
      "task_status": "string", // 任务状态
      //... 其他参数
    }
  ]
}
```

---

可灵视频3.0系列模型再次迎来升级，支持一键生成原生4K视频，轻松解锁大屏高清终端展示、专业商业交付等核心商用场景，助力企业提升内容竞争力。
