Communitygithub.com

Kling AI 文字轉影片

根據文字提示生成影片。適用於從描述建立影片、學習提示詞技巧或建立 T2V 管線。可透過「kling ai text to video」、「klingai prompt」、「generate video from text」、「text2video kling」等短語觸發。

Kling AI 文字轉影片 是什麼?

這是一個以 Kling AI Text-to-Video API 為基礎的技能,能將文字提示轉換為影片。它支援多種模型版本(v1 到 v2.6)、標準與專業模式、攝影機控制、反向提示詞,以及 v2.6 以上的原生音訊功能。開發者可以透過標準 HTTP 請求呼叫 `/v1/videos/text2video` 端點,並使用 JWT 認證。請求參數包含 `model_name`、`prompt`、`duration`、`aspect_ratio`、`mode`、`cfg_scale` 等。回傳的任務 ID 可用於輪詢狀態,直到完成。此技能特別適用於 AI 代理工具,例如 Claude Code 或 Cursor,讓它們能夠在開發流程中直接產生影片。本文件提供完整的 Python 範例、攝影機控制配置、音訊功能、提示詞工程技巧、定價參考與錯誤處理說明。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/HEAD/plugins/saas-packs/klingai-pack/skills/klingai-text-to-video

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Kling AI 文字轉影片 是做什麼的?

概述

使用 /v1/videos/text2video 端點,根據文字提示生成影片。支援模型 v1 至 v2.6、標準/專業模式、攝影機控制、反向提示詞,以及原生音訊(v2.6 以上)。

端點: POST https://api.klingai.com/v1/videos/text2video

請求參數

參數類型必要說明
model_name字串是模型版本(請參閱模型目錄)
prompt字串是影片描述,最多 2500 個字元
negative_prompt字串否要排除的內容
duration字串是"5" 或 "10" 秒
aspect_ratio字串否"16:9"(預設)、"9:16"、"1:1" 等
mode字串否"standard"(預設)或 "professional"
cfg_scale浮點數否提示詞遵循度(0.0-1.0,預設 0.5)
camera_control物件否攝影機移動配置
callback_url字串否完成通知的 Webhook URL

完整範例 — Python

import jwt, time, os, requests

BASE = "https://api.klingai.com/v1"

def get_headers():
    ak, sk = os.environ["KLING_ACCESS_KEY"], os.environ["KLING_SECRET_KEY"]
    token = jwt.encode(
        {"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5},
        sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}
    )
    return {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}

# 建立文字轉影片任務
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
    "model_name": "kling-v2-6",
    "prompt": "Aerial drone shot of a coral reef at golden hour, "
              "tropical fish swimming through crystal clear water, "
              "sun rays penetrating the surface, cinematic 4K",
    "negative_prompt": "blurry, low quality, distorted, watermark",
    "duration": "5",
    "aspect_ratio": "16:9",
    "mode": "professional",
    "cfg_scale": 0.5,
})

task = response.json()
task_id = task["data"]["task_id"]

# 輪詢完成狀態
while True:
    time.sleep(15)
    result = requests.get(
        f"{BASE}/videos/text2video/{task_id}", headers=get_headers()
    ).json()

    status = result["data"]["task_status"]
    if status == "succeed":
        video = result["data"]["task_result"]["videos"][0]
        print(f"影片 URL: {video['url']}")
        print(f"時長: {video['duration']}s")
        break
    elif status == "failed":
        raise RuntimeError(result["data"]["task_status_msg"])
    # 其他狀態:submitted/processing — 持續輪詢

搭配攝影機控制

# 攝影機移動類型:pan, tilt, zoom, roll
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
    "model_name": "kling-v2-6",
    "prompt": "A medieval castle on a cliff at sunrise, fog in the valley",
    "duration": "5",
    "mode": "standard",
    "camera_control": {
        "type": "simple",
        "config": {
            "horizontal": 5,    # 向右平移(負值向左),範圍 -10 至 10
            "vertical": 0,      # 俯仰(負值向下,正值向上)
            "zoom": 3,          # 縮放(正值放大,負值縮小)
            "roll": 0,          # 旋轉
            "pan": 0,           # 左右橫移
            "tilt": -2,         # 上下橫移
        }
    },
})

規則: 對於 type: "simple",config 中只能有一個非零欄位。

搭配原生音訊(僅 v2.6)

response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
    "model_name": "kling-v2-6",
    "prompt": "A jazz band performing in a dimly lit club, saxophone solo, "
              "audience clapping, warm amber lighting",
    "duration": "10",
    "mode": "professional",
    "motion_has_audio": True,  # 生成同步音訊
})

提示詞工程技巧

技巧範例
場景 + 動作 + 風格"A samurai walking through cherry blossoms, cinematic slow motion"
光線提示"golden hour", "neon-lit", "overcast diffused light"
鏡頭語言"close-up", "wide establishing shot", "tracking shot"
反向提示詞"blurry, watermark, text overlay, distorted faces"
材質/質感"brushed steel", "hand-painted watercolor", "photorealistic"

費用參考

時長標準模式專業模式
5 秒10 點數35 點數
10 秒20 點數70 點數

錯誤處理

錯誤原因解決方法
400 無效提示詞為空或超過 2500 字元檢查提示詞長度
400 無效模型不支援的 model_name使用目錄中的有效模型 ID
402 點數不足點數不足充值
task_status: failed違反內容政策或複雜度過高簡化提示詞,移除受限內容

先決條件

  • 審核通過的簡報、權利已清除或合成的參考素材、授權的工作區與預算、內容政策審查,以及指派的擁有者負責發布與刪除。

操作說明

  1. 根據審核通過的簡報建立沙盒草稿;請勿在提示詞或上傳中包含私人個體、受保護素材或未經證實的聲明。
  2. 在提交前確認請求的時長、風格、目的地、點數預算、內容政策狀態,以及僅限草稿設定。
  3. 審查一個帶浮水印的預覽渲染,確認政策、權利與品質;若發現政策或歸屬問題,請停止操作並刪除草稿,不要發布。
  4. 僅在獲得擁有者批准後才發布,並保留一份去敏的製作收據;在核准的保留期限到後移除暫存資源。

輸出

產生一份渲染收據,包含簡報 ID、已審核的來源分類、模型/模式、時長、點數估算、政策與權利審查結果、草稿目的地、核准者、保留/刪除參考資訊,以及任務 ID。排除提示詞文字、身分資訊與憑證。

範例

brief=synthetic-product-demo; source=rights-cleared; mode=standard; duration=5s; policy=pass; destination=draft-only; approval=pending; cleanup=24h 為一個安全的預覽請求。

資源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

jeremylongshore/tons-of-skills-marketplace

Use when asked to structure a landing page for positioning, plan a conversion-optimized page layout, or design a launch page. Examples: "landing page for product launch", "conversion-optimized layout for SaaS

jeremylongshore/tons-of-skills-marketplace

Use when asked to design growth-optimized landing pages, activation funnel layouts, or experiment-friendly page structures. Examples: "growth-optimized landing", "activation funnel layout", "A/B testable page

jeremylongshore/tons-of-skills-marketplace

Use when asked to structure a landing page, design page layout for conversion, or plan landing page information architecture. Examples: "landing page structure for SaaS", "conversion-optimized layout

jeremylongshore/tons-of-skills-marketplace

Generate polished demo videos from a single prompt. Use when the user asks to create a demo video, product walkthrough, feature showcase, or animated presentation. Trigger with "make a demo video", "create a product video", "demo walkthrough", or "feature showcase video".

jeremylongshore/tons-of-skills-marketplace

Track cryptocurrency portfolio with real-time valuations, allocation analysis, and P&L tracking. Use when checking portfolio value, viewing holdings breakdown, analyzing allocations, or exporting portfolio data. Trigger with phrases like "show my portfolio", "check crypto holdings", "portfolio allocation", "track my crypto", or "export portfolio".

jeremylongshore/tons-of-skills-marketplace

Runs the full release workflow for the current project. Commits any uncommitted changes, pushes to remote, creates and merges a PR if on a feature branch, determines the next semver version from conventional commits, creates an annotated git tag and GitHub release with generated notes, cleans up merged branches, and returns to a clean main. Use when the user says promote, ship, release, commit and push, tag and release, or get back to main.

jeremylongshore/tons-of-skills-marketplace

Agent skill at plugins/productivity/content-multiplier/skills/channel-formats/SKILL.md

jeremylongshore/tons-of-skills-marketplace

Operate an evidence-backed editorial queue, balance topic and format coverage, schedule approved drafts, and reconcile backlog state with the publishing system. Use when choosing or scheduling the next blog work. Trigger with "show the editorial calendar" or "pick the next topic".

jeremylongshore/tons-of-skills-marketplace

Configure CI/CD pipeline for AppFolio property management integrations. Trigger: "appfolio CI".

jeremylongshore/tons-of-skills-marketplace

Diagnose and fix common AppFolio API integration errors. Trigger: "appfolio error".

jeremylongshore/tons-of-skills-marketplace

Build property management dashboard with AppFolio API data. Trigger: "appfolio property dashboard".

jeremylongshore/tons-of-skills-marketplace

Automate tenant management and lease operations with AppFolio. Trigger: "appfolio tenant management".

jeremylongshore/tons-of-skills-marketplace

Collect AppFolio API debug evidence for support tickets. Trigger: "appfolio debug".

jeremylongshore/tons-of-skills-marketplace

Deploy AppFolio integration service to cloud infrastructure. Trigger: "deploy appfolio".

jeremylongshore/tons-of-skills-marketplace

Query AppFolio properties, units, and tenants via REST API. Trigger: "appfolio hello world".

jeremylongshore/tons-of-skills-marketplace

Configure AppFolio Stack API authentication with OAuth 2.0. Use when setting up property management API access, registering as an AppFolio Stack partner, or configuring client credentials for API calls. Trigger: "install appfolio", "setup appfolio", "appfolio auth", "appfolio API key".

jeremylongshore/tons-of-skills-marketplace

Set up local development for AppFolio property management API integration. Trigger: "appfolio local dev".

jeremylongshore/tons-of-skills-marketplace

Production readiness checklist for AppFolio integrations. Trigger: "appfolio production checklist".

jeremylongshore/tons-of-skills-marketplace

Handle AppFolio API rate limits with throttling and backoff. Trigger: "appfolio rate limit".

jeremylongshore/tons-of-skills-marketplace

Reference architecture for AppFolio property management integration. Trigger: "appfolio architecture".

相關技能