---
title: Kling 文字轉影片 | RunAPI
description: 使用文字轉影片端點以建立非同步任務。
url: https://runapi.ai/zh-HK/docs/api/kling/text-to-video.md
canonical: https://runapi.ai/zh-HK/docs/api/kling/text-to-video
locale: zh-HK
---

> HTML 版本: https://runapi.ai/zh-HK/docs/api/kling/text-to-video
> 智能代理網站索引: https://runapi.ai/llms.txt

# Kling 文字轉影片

## 概覽

使用文字轉影片端點配合受支援的模型。使用返回的任務 ID 來檢索其狀態，或提供 callback_url 以接收以下記錄的推送通知。

### 快速入門

1. 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
2. 選擇支援的模型，並發送主體符合該模型結構的 POST 請求。
3. 儲存返回的任務 ID，然後輪詢直至達到終止狀態，或處理下方說明的回呼。

## 端點

POST /api/v1/kling/text_to_video

基礎 URL: https://runapi.ai

API 版本: v1

身份驗證: Authorization: Bearer YOUR_API_TOKEN

## 支援的模型

開啟模型頁面以查看當前定價、速率限制及商業用途詳情。

- [kling-3.0](https://runapi.ai/zh-HK/models/kling/3.0)
- [kling-o1](https://runapi.ai/zh-HK/models/kling/o1)
- [kling-v2.1-master-text-to-video](https://runapi.ai/zh-HK/models/kling/v2.1-master-text-to-video)
- [kling-v2.5-turbo-text-to-video-pro](https://runapi.ai/zh-HK/models/kling/v2.5-turbo-text-to-video-pro)
- [kling-v2.6](https://runapi.ai/zh-HK/models/kling/v2.6)
- [kling-v3-omni](https://runapi.ai/zh-HK/models/kling/v3-omni)
- [kling-v3-omni-reference](https://runapi.ai/zh-HK/models/kling/v3-omni-reference)
- [kling-v3-turbo-text-to-video](https://runapi.ai/zh-HK/models/kling/v3-turbo-text-to-video)

## 請求結構

欄位及允許的值取決於所選模型。提供後，callback_url 將接收以下記錄的 Task 交付內容。

### kling-3.0

```json
{
  "aspect_ratio": {
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "cfg_scale": {
    "description": "引導比例（0-1）。",
    "type": "number"
  },
  "duration_seconds": {
    "description": "持續時間（秒）。",
    "enum": [
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15
    ],
    "type": "integer"
  },
  "enable_sound": {
    "description": "啟用聲音生成。",
    "type": "boolean"
  },
  "first_frame_image_url": {
    "description": "首幀圖像 URL。",
    "type": "string"
  },
  "kling_elements": {
    "description": "包含圖像、影片或音訊素材的元素參考。",
    "type": "array"
  },
  "last_frame_image_url": {
    "description": "單鏡頭模式的最後一幀圖片 URL。",
    "type": "string"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "multi_prompt": {
    "description": "多鏡頭模式的提示詞片段。",
    "type": "array"
  },
  "multi_shots": {
    "description": "啟用多鏡頭生成。",
    "type": "boolean"
  },
  "negative_prompt": {
    "description": "負面提示。",
    "type": "string"
  },
  "output_resolution": {
    "description": "輸出解析度。",
    "enum": [
      "720p",
      "1080p",
      "4k"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。除非已啟用 multi_shots，否則為必填項目。",
    "type": "string"
  }
}
```

### kling-o1

```json
{
  "aspect_ratio": {
    "default": "16:9",
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "duration_seconds": {
    "default": 5,
    "description": "持續時間（秒）。",
    "enum": [
      5
    ],
    "type": "integer"
  },
  "enable_sound": {
    "default": false,
    "description": "聲音生成必須保持停用狀態。",
    "type": "boolean"
  },
  "mode": {
    "default": "std",
    "description": "生成模式。",
    "enum": [
      "std",
      "pro"
    ],
    "type": "string"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "preserve_reference_video_audio": {
    "default": false,
    "description": "保留參考視訊的原始音訊。",
    "type": "boolean"
  },
  "prompt": {
    "description": "影片描述；使用對應編號標記引用媒體。",
    "length": true,
    "max": 2500,
    "min": 1,
    "required": true,
    "type": "string"
  },
  "reference_image_urls": {
    "description": "有序的公開 HTTP(S) JPG、JPEG 或 PNG 參考圖片 URL。",
    "items": {
      "type": "string"
    },
    "max_items": 7,
    "min_items": 1,
    "type": "array"
  },
  "reference_video_type": {
    "default": "base",
    "description": "將影片用作基礎編輯或特徵參考。",
    "enum": [
      "base",
      "feature"
    ],
    "type": "string"
  },
  "reference_video_url": {
    "description": "公開 HTTP(S) MP4 或 MOV 參考視訊 URL。",
    "type": "string"
  }
}
```

### kling-v2.1-master-text-to-video

```json
{
  "aspect_ratio": {
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "cfg_scale": {
    "description": "引導比例（0-1）。",
    "type": "number"
  },
  "duration_seconds": {
    "description": "持續時間（秒）。",
    "enum": [
      5,
      10
    ],
    "type": "integer"
  },
  "enable_sound": {
    "description": "啟用聲音生成。",
    "type": "boolean"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "negative_prompt": {
    "description": "負面提示。",
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "type": "string"
  }
}
```

### kling-v2.5-turbo-text-to-video-pro

```json
{
  "aspect_ratio": {
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "cfg_scale": {
    "description": "引導比例（0-1）。",
    "type": "number"
  },
  "duration_seconds": {
    "description": "持續時間（秒）。",
    "enum": [
      5,
      10
    ],
    "type": "integer"
  },
  "enable_sound": {
    "description": "啟用聲音生成。",
    "type": "boolean"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "negative_prompt": {
    "description": "負面提示。",
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "type": "string"
  }
}
```

### kling-v2.6

```json
{
  "aspect_ratio": {
    "default": "16:9",
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "duration_seconds": {
    "default": 5,
    "description": "持續時間（秒）。",
    "enum": [
      5,
      10
    ],
    "type": "integer"
  },
  "enable_sound": {
    "default": false,
    "description": "啟用聲音生成；需要 pro 模式。",
    "type": "boolean"
  },
  "mode": {
    "default": "std",
    "description": "生成模式。",
    "enum": [
      "std",
      "pro"
    ],
    "type": "string"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "length": true,
    "max": 2500,
    "min": 1,
    "required": true,
    "type": "string"
  }
}
```

### kling-v3-omni

```json
{
  "aspect_ratio": {
    "default": "16:9",
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "duration_seconds": {
    "default": 5,
    "description": "持續時間（秒）。",
    "enum": [
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15
    ],
    "type": "integer"
  },
  "enable_sound": {
    "default": false,
    "description": "啟用同步聲音生成。",
    "type": "boolean"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "output_resolution": {
    "default": "720p",
    "description": "輸出解析度。",
    "enum": [
      "720p",
      "1080p",
      "4k"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "length": true,
    "max": 2500,
    "min": 1,
    "required": true,
    "type": "string"
  }
}
```

### kling-v3-omni-reference

```json
{
  "aspect_ratio": {
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "required": true,
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "duration_seconds": {
    "default": 5,
    "description": "輸出時長（秒）。",
    "enum": [
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15
    ],
    "type": "integer"
  },
  "enable_sound": {
    "default": false,
    "description": "啟用同步聲音生成。",
    "type": "boolean"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "output_resolution": {
    "default": "720p",
    "description": "輸出解析度。",
    "enum": [
      "720p",
      "1080p",
      "4k"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "length": true,
    "max": 2500,
    "min": 1,
    "required": true,
    "type": "string"
  },
  "reference_image_urls": {
    "description": "有序的參考圖片 URL。",
    "items": {
      "type": "string"
    },
    "max_items": 7,
    "min_items": 1,
    "required": true,
    "type": "array"
  }
}
```

### kling-v3-turbo-text-to-video

```json
{
  "aspect_ratio": {
    "default": "16:9",
    "description": "輸出長寬比。",
    "enum": [
      "16:9",
      "9:16",
      "1:1"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "用於非同步通知的 Webhook URL。",
    "type": "string"
  },
  "duration_seconds": {
    "default": 5,
    "description": "持續時間（秒）。",
    "enum": [
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15
    ],
    "type": "integer"
  },
  "model": {
    "description": "模型標識符。",
    "required": true,
    "type": "string"
  },
  "output_resolution": {
    "default": "720p",
    "description": "輸出解析度。",
    "enum": [
      "720p",
      "1080p"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "影片描述。",
    "length": true,
    "max": 2500,
    "min": 1,
    "required": true,
    "type": "string"
  }
}
```

#### 條件規則

當所有列出的條件均符合時，這些要求方才適用。

- **當**: `model` = `kling-3.0`; **不接受**: `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`
- **當**: `model` = `kling-o1`; **不接受**: `output_resolution`, `negative_prompt`, `cfg_scale`, `multi_shots`, `multi_prompt`, `first_frame_image_url`, `last_frame_image_url`, `kling_elements`
- **當**: `model` = `kling-v2.1-master-text-to-video`; **不接受**: `mode`, `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`
- **當**: `model` = `kling-v2.5-turbo-text-to-video-pro`; **不接受**: `mode`, `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`
- **當**: `model` = `kling-v2.6`; **不接受**: `output_resolution`, `negative_prompt`, `cfg_scale`, `multi_shots`, `multi_prompt`, `first_frame_image_url`, `last_frame_image_url`, `kling_elements`, `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`
- **當**: `model` = `kling-v3-omni`; **不接受**: `negative_prompt`, `cfg_scale`, `multi_shots`, `multi_prompt`, `first_frame_image_url`, `last_frame_image_url`, `kling_elements`, `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`
- **當**: `model` = `kling-v3-turbo-text-to-video`; **不接受**: `enable_sound`, `negative_prompt`, `cfg_scale`, `multi_shots`, `multi_prompt`, `first_frame_image_url`, `last_frame_image_url`, `kling_elements`, `reference_image_urls`, `reference_video_url`, `reference_video_type`, `preserve_reference_video_audio`

## 建立接受

HTTP 202 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    },
    "task_replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## 輪詢處理中

HTTP 200 - GET /api/v1/kling/text_to_video/:id

### 回應結構

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## 輪詢已完成

HTTP 200 - GET /api/v1/kling/text_to_video/:id

### 回應結構

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
```

## 輪詢失敗

HTTP 200 - GET /api/v1/kling/text_to_video/:id

### 回應結構

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "error": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "error": "Task processing failed.",
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## 客戶回呼：已完成

HTTP 200 - POST callback_url

### 回應結構

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
```

## 客戶回呼：已失敗

HTTP 200 - POST callback_url

### 回應結構

```json
{
  "properties": {
    "error": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "properties": {
            "code": {
              "type": "string"
            },
            "limit_cents": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            },
            "reset_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "used_cents": {
              "type": "integer"
            },
            "window": {
              "enum": [
                "1h",
                "1d",
                "7d",
                "daily",
                "weekly",
                "monthly",
                "lifetime"
              ],
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object",
          "unevaluatedProperties": false
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": {
    "code": "generation_failed",
    "message": "Task processing failed."
  },
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## 錯誤

HTTP 401 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Authentication required"
}
```

## 錯誤

HTTP 401 - GET /api/v1/kling/text_to_video/:id

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Authentication required"
}
```

## 錯誤

HTTP 400 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "人類可讀的錯誤訊息。",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "人類可讀的驗證摘要。",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "以公開請求欄位為鍵的驗證訊息，每個欄位對應一組人類可讀的字串陣列。",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### 回應範例

```json
{
  "error": "model must be one of: kling-3.0, kling-o1, kling-v2.1-master-text-to-video, kling-v2.5-turbo-text-to-video-pro, kling-v2.6, kling-v3-omni, kling-v3-omni-reference, kling-v3-turbo-text-to-video"
}
```

## 錯誤

HTTP 402 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Insufficient balance"
}
```

## 錯誤

HTTP 429 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "API key credit limit exceeded"
}
```

## 錯誤

HTTP 409 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "The request uses features that are not supported for the selected model"
}
```

## 錯誤

HTTP 429 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Rate limit reached. Please retry later."
}
```

## 錯誤

HTTP 503 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Service under maintenance, please try again later"
}
```

## 錯誤

HTTP 504 - POST /api/v1/kling/text_to_video

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "The request timed out"
}
```

## 錯誤

HTTP 404 - GET /api/v1/kling/text_to_video/:id

### 回應結構

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Task with id 'tsk_reference_demo' not found"
}
```

## 已生成的程式碼範例

直接使用 cURL，或為您的語言安裝 SDK。每個範例均提交本參考中所示的已驗證請求。

### curl

```curl
curl -X POST https://runapi.ai/api/v1/kling/text_to_video \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"kling-v3-turbo-text-to-video","prompt":"A paper kite flying above a quiet coastal town at sunrise","duration_seconds":5,"aspect_ratio":"16:9","output_resolution":"720p"}'
```

### javascript

#### 安裝

```bash
npm install @runapi.ai/kling
```

```javascript
import { KlingClient } from "@runapi.ai/kling";

const client = new KlingClient({ apiKey: process.env.RUNAPI_API_KEY });
const task = await client.textToVideo.create({
  "model": "kling-v3-turbo-text-to-video",
  "prompt": "A paper kite flying above a quiet coastal town at sunrise",
  "duration_seconds": 5,
  "aspect_ratio": "16:9",
  "output_resolution": "720p"
});
```

### python

#### 安裝

```bash
pip install runapi-kling
```

```python
import os
from runapi.kling import KlingClient

client = KlingClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
  model="kling-v3-turbo-text-to-video",
  prompt="A paper kite flying above a quiet coastal town at sunrise",
  duration_seconds=5,
  aspect_ratio="16:9",
  output_resolution="720p"
)
```

### go

#### 安裝

```bash
go get github.com/runapi-ai/kling-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  kling "github.com/runapi-ai/kling-sdk/go/kling"
)

func main() {
  client, err := kling.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
  if err != nil {
    log.Fatal(err)
  }

  task, err := client.TextToVideo.Create(context.Background(), kling.TextToVideoParams{
    Model: kling.TextToVideoModel("kling-v3-turbo-text-to-video"),
    Prompt: "A paper kite flying above a quiet coastal town at sunrise",
    DurationSeconds: 5,
    AspectRatio: "16:9",
    OutputResolution: kling.KlingTextToVideoOutputResolution("720p"),
  })
  if err != nil {
    log.Fatal(err)
  }
  _ = task
}
```

### ruby

#### 安裝

```bash
gem install runapi-kling
```

```ruby
require "runapi/kling"

client = RunApi::Kling::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
task = client.text_to_video.create(
  model: "kling-v3-turbo-text-to-video",
  prompt: "A paper kite flying above a quiet coastal town at sunrise",
  duration_seconds: 5,
  aspect_ratio: "16:9",
  output_resolution: "720p"
)
```

### java

#### 安裝

```kotlin
implementation("ai.runapi:runapi-kling")
```

```java
import ai.runapi.kling.KlingClient;
import ai.runapi.kling.types.TextToVideoParams;
import ai.runapi.core.polling.TaskCreateResponse;

public final class Example {
  public static void main(String[] args) {
    KlingClient client = KlingClient.builder()
        .apiKey(System.getenv("RUNAPI_API_KEY"))
        .build();
    TaskCreateResponse task = client.textToVideo().create(
        TextToVideoParams.builder()
        .model("kling-v3-turbo-text-to-video")
        .prompt("A paper kite flying above a quiet coastal town at sunrise")
        .durationSeconds(5)
        .aspectRatio("16:9")
        .outputResolution("720p")
            .build()
    );
  }
}
```

### php

#### 安裝

```bash
composer require runapi-ai/kling
```

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use RunApi\Core\ClientOptions;
use RunApi\Kling\KlingClient;

$client = new KlingClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$task = $client->textToVideo->create([
  "model" => "kling-v3-turbo-text-to-video",
  "prompt" => "A paper kite flying above a quiet coastal town at sunrise",
  "duration_seconds" => 5,
  "aspect_ratio" => "16:9",
  "output_resolution" => "720p"
]);
```

## 相關指南

- [身份驗證](https://runapi.ai/zh-HK/docs/guides/authentication.md)
- [快速入門](https://runapi.ai/zh-HK/docs/guides/task-api/quickstart.md)

---

## RunAPI 的更多內容

- [首頁](https://runapi.ai/zh-HK/.md)
- [模型目錄](https://runapi.ai/zh-HK/models.md)
- [收費](https://runapi.ai/zh-HK/pricing.md)
- [服務商](https://runapi.ai/zh-HK/models)
- [文件](https://runapi.ai/zh-HK/docs/guides)
- [SDK](https://runapi.ai/zh-HK/sdk.md)
- [CLI](https://runapi.ai/zh-HK/cli.md)
- [MCP Server](https://runapi.ai/zh-HK/mcp.md)
- [Claude Code 與 Cursor](https://runapi.ai/zh-HK/claude-code-vs-cursor.md)
- [Cursor API 設定](https://runapi.ai/zh-HK/cursor-api-setup.md)
- [RunAPI 與 OpenRouter](https://runapi.ai/zh-HK/openrouter-alternative.md)
- [企業版](https://runapi.ai/zh-HK/contact.md)
- [聯絡](https://runapi.ai/zh-HK/contact.md)
- [條款](https://runapi.ai/zh-HK/terms.md)
- [私隱](https://runapi.ai/zh-HK/privacy.md)
- [智能代理網站索引](https://runapi.ai/llms.txt)

聯絡我們: contact@runapi.ai

## 結構化資料

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-HK",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-HK/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-HK",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-HKicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "TechArticle",
    "headline": "Kling 文字轉影片",
    "description": "使用文字轉影片端點以建立非同步任務。",
    "url": "https://runapi.ai/zh-HK/docs/api/kling/text-to-video",
    "mainEntityOfPage": "https://runapi.ai/zh-HK/docs/api/kling/text-to-video"
  }
]
```
