---
title: &quot;透過 RunAPI 在 Hermes Agent 中使用 Kling — 影片 API 指南&quot;
url: &quot;https://runapi.ai/zh-HK/hermes-kling.md&quot;
canonical: &quot;https://runapi.ai/zh-HK/hermes-kling&quot;
locale: &quot;zh-HK&quot;
model: &quot;kling&quot;
---

# 在 Hermes Agent 中使用 Kling。

Kling 3.0 由 Kuaishou 開發，可從文字或圖片生成最高 1080p 的影片，支援原生音訊、多鏡頭場景及 3–15 秒時長。Hermes Agent 透過 RunAPI 的 custom:runapi provider 呼叫 Kling — 使用與聊天相同的 key 和 base URL。

## API example

```bash
curl -X POST https://runapi.ai/api/v1/kling/text_to_video \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;kling-3.0&quot;,
    &quot;prompt&quot;: &quot;A drone shot pulling back from a mountain lake at sunrise, mist rising off the water, cinematic lighting&quot;,
    &quot;duration_seconds&quot;: 5,
    &quot;aspect_ratio&quot;: &quot;16:9&quot;,
    &quot;enable_sound&quot;: true,
    &quot;output_resolution&quot;: &quot;1080p&quot;
  }&#39;

```

### Response

```json
{
  &quot;task_id&quot;: &quot;tsk_abc123&quot;,
  &quot;status&quot;: &quot;pending&quot;,
  &quot;model&quot;: &quot;kling-3.0&quot;
}

```

## How it works

1. **設定 RunAPI** — 設定 RUNAPI_API_KEY 環境變數。如果你已在 Hermes Agent 中新增 RunAPI 為 custom:runapi provider 用於聊天，同一把 key 和 base_url 即可用於影片生成 — 無需額外設定。
2. **呼叫 Kling text_to_video** — 發送 POST 請求至 /api/v1/kling/text_to_video，將 model 設為 kling-3.0。加入 prompt、duration_seconds（3–15）、aspect_ratio，並可選擇啟用 enable_sound 取得原生音訊。若要以圖片驅動生成，改用 /api/v1/kling/image_to_video 並提供 first_frame_image_url。
3. **輪詢取得結果** — 端點會立即回傳 task_id。輪詢任務狀態端點，直到 status 變為 completed，然後從回應中取得影片 URL。生成時間通常為 30–120 秒，取決於時長和解析度。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | 必填。kling-3.0 為最新版本。 |
| `prompt` | `string` | 影片描述。除非啟用 multi_shots，否則為必填。 |
| `duration_seconds` | `integer` | 影片長度。Kling 3.0 支援 3–15 秒。舊版本僅接受 5 或 10 秒。 |
| `aspect_ratio` | `string` | 輸出長寬比：16:9、9:16 或 1:1。 |
| `output_resolution` | `string` | 解析度：720p、1080p 或 4k。解析度越高，每秒費用越高。 |
| `enable_sound` | `boolean` | 與影片同時生成原生音訊。會增加每秒費用。 |
| `negative_prompt` | `string` | 要從生成結果中排除的元素。 |
| `first_frame_image_url` | `string` | 用作開頭畫面的圖片 URL（單鏡頭模式）。 |
| `cfg_scale` | `number` | 引導係數（0–1）。數值越高，生成結果越貼近 prompt。 |
| `multi_shots` | `boolean` | 啟用多鏡頭場景生成，每個片段可使用不同 prompt。 |

## FAQ

### RunAPI 上的 Kling 按秒計費如何運作？

Kling 按生成影片的秒數收費。費率取決於 output_resolution 以及是否啟用 enable_sound。5 秒 720p 不含音訊的影片是最便宜的選項；1080p 加音訊的每秒費用大約是前者的兩倍。請查看 RunAPI 定價頁面了解確切費率。

### text_to_video 和 image_to_video 有什麼差別？

text_to_video 僅從文字 prompt 生成影片。image_to_video 需要提供 first_frame_image_url，並從該圖片向外延伸生成動態。兩個端點都回傳非同步 task_id，並支援相同的時長和解析度選項。

### 除了 3.0 之外，可以使用其他 Kling 版本嗎？

可以。RunAPI 也提供 kling-v2.5-turbo-text-to-video-pro 和 kling-v2.5-turbo-image-to-video-pro，可用於更快、更低成本的 5 或 10 秒影片生成。將 model 參數設為你想要的版本 slug 即可。

### Hermes Agent 需要為 Kling 影片設定單獨的 provider 嗎？

不需要。如果你已在 Hermes Agent 中設定 custom:runapi provider 用於聊天或圖片生成，同一個 base_url 和 API key 即可用於 Kling 影片端點。只需更改請求路徑和 model 參數。

### 如果 Kling 生成失敗，還會被收費嗎？

不會。RunAPI 只對已完成的生成收費。如果任務失敗或在上游逾時，預留的額度會退回到你的帳戶餘額。


## Links

- [Hermes Agent 設定指南 →](https://runapi.ai/zh-HK/hermes-agent)
- [Kling 模型 →](https://runapi.ai/zh-HK/models/kling)
- [Model catalog](https://runapi.ai/zh-HK/models)
- [API docs](https://runapi.ai/zh-HK/docs)
