Communitygithub.com

Kling AI テキストから動画生成

Kling AI を使用してテキストプロンプトから動画を生成します。説明文から動画を作成したり、プロンプト技術を学習したり、T2V パイプラインを構築する際に使用します。

Kling AI テキストから動画生成 とは?

このスキルは、Kling AI の Text-to-Video API(エンドポイント: POST /v1/videos/text2video)を利用して、テキストプロンプトから動画を生成するためのツールです。モデル v1 から v2.6 までをサポートし、標準/プロフェッショナルモード、カメラ制御、ネガティブプロンプト、v2.6 以降ではネイティブオーディオ生成など、豊富な機能を提供します。Python サンプルコードが含まれており、JWT 認証、タスク作成、ポーリングによる完了確認の一連の流れを実装できます。また、プロンプトエンジニアリングのヒントやエラーハンドリング、コスト表も提供しており、開発者がすぐに動画生成パイプラインを構築・運用できるように設計されています。このスキールは Claude Code, Cursor, Codex などの AI エージェントプラットフォームで利用できます。

対応✓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に質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Kling AI テキストから動画生成 は何をしますか?

概要

テキストプロンプトから /v1/videos/text2video エンドポイントを使用して動画を生成します。モデル v1 から v2.6、標準/プロフェッショナルモード、カメラ制御、ネガティブプロンプト、ネイティブオーディオ(v2.6+)をサポートしています。

エンドポイント: POST https://api.klingai.com/v1/videos/text2video

リクエストパラメータ

パラメータ型必須説明
model_namestringはいモデルバージョン(モデルカタログを参照)
promptstringはい動画の説明、最大2500文字
negative_promptstringいいえ生成から除外する内容
durationstringはい"5" または "10" 秒
aspect_ratiostringいいえ"16:9"(デフォルト)、"9:16"、"1:1" など
modestringいいえ"standard"(デフォルト)または "professional"
cfg_scalefloatいいえプロンプトへの忠実度(0.0~1.0、デフォルト 0.5)
camera_controlobjectいいえカメラ移動設定
callback_urlstringいいえ完了通知用の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"Video URL: {video['url']}")
        print(f"Duration: {video['duration']}s")
        break
    elif status == "failed":
        raise RuntimeError(result["data"]["task_status_msg"])
    # else: 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 内のフィールドは1つだけ非ゼロにします。

ネイティブオーディオを使用する場合(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. ポリシー、権利、品質について、透かし入りのカナリアレンダリングを1つレビューします。ポリシーまたは帰属に関する懸念がある場合は停止し、公開せずにドラフトを削除します。
  4. 所有者の承認後にのみ公開し、編集済みの本番レシートを保持します。承認された保存期間の終了時に一時的なアセットを削除します。

出力

ブリーフID、承認されたソース分類、モデル/モード、時間、クレジット見積もり、ポリシーおよび権利レビュー結果、ドラフト出力先、承認者、保存/削除の参照、タスク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".

関連スキル