Communitygithub.com

Runway ML API スキル

Runway ML API を使用してAIによる動画生成と編集を行います — Gen-3 Alpha Turbo、画像から動画、動画から動画。テキストや画像からの動画生成、AI動画エフェクトの適用、クリエイティブな動画制作パイプラインの自動化に使用します。

Runway ML API スキル とは?

このスキルは、Runway ML の Gen-3 Alpha Turbo モデルにアクセスし、テキストプロンプトや画像から高品質な動画を生成するためのREST API操作を提供します。非同期タスクパターン(タスク作成 → ポーリング → 結果ダウンロード)に基づいて動作し、映画のようなクリップの作成、画像のアニメーション、自動動画コンテンツパイプラインの構築を可能にします。主に Claude Code、Cursor、Codex などのAIエージェントから使用することを想定しており、Python クライアントコード、タスク管理関数、パラメータリファレンスが含まれています。このスキルを使用すると、開発者はテキストから動画、画像から動画の生成をスクリプト化し、生成された動画をローカルにダウンロードし、シード値を使って再現性を確保できます。Gen-3 Alpha Turbo は最速のモデルであり、本番パイプラインに最適で、5秒または10秒の動画を生成し、ランドスケープ、ポートレート、スクエアなど複数のアスペクト比をサポートします。

対応✓Claude Code✓Codex CLI✓Cursor✓Gemini CLI
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/runway-ml

お気に入りのAIに質問する

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

ドキュメント

Runway ML API

概要

Runway の Gen-3 Alpha Turbo モデルは、テキストプロンプトまたは画像から高品質な動画を生成します。REST API は非同期タスクパターン(タスク作成、完了をポーリング、結果をダウンロード)に従います。映画のようなクリップの作成、画像のアニメーション、自動動画コンテンツパイプラインの構築に使用します。

セットアップ

pip install requests python-dotenv
export RUNWAY_API_KEY="your_api_key_here"

ベースURL: https://api.dev.runwayml.com/v1
APIドキュメント: https://docs.runwayml.com

コアコンセプト

  • タスク: 非同期の動画生成ジョブ。すぐに task_id が返されます。
  • Gen-3 Alpha Turbo: 最速の Gen-3 モデル — 本番パイプラインに最適です。
  • 画像から動画 (gen3a_turbo): 静止画像を動きのある映像に変換します。
  • テキストから動画: テキストプロンプトのみから動画を生成します。
  • 長さ: 5 秒または 10 秒。
  • 比率: 1280:720 (横長), 720:1280 (縦長), 1104:832, 832:1104, 960:960 (正方形)。

手順

ステップ 1: クライアントのセットアップ

import os
import time
import requests

API_KEY = os.environ["RUNWAY_API_KEY"]
BASE_URL = "https://api.dev.runwayml.com/v1"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
    "X-Runway-Version": "2024-11-06"
}

ステップ 2: テキストから動画の生成

def text_to_video(
    prompt_text: str,
    duration: int = 5,
    ratio: str = "1280:720",
    seed: int = None
) -> str:
    """テキストから動画のタスクを送信し、task_id を返します。"""
    payload = {
        "model": "gen3a_turbo",
        "promptText": prompt_text,
        "duration": duration,
        "ratio": ratio
    }
    if seed is not None:
        payload["seed"] = seed

    r = requests.post(f"{BASE_URL}/image_to_video", json=payload, headers=HEADERS)
    r.raise_for_status()
    return r.json()["id"]

task_id = text_to_video(
    prompt_text="A drone shot flying over a misty mountain valley at golden hour, cinematic, slow motion",
    duration=5,
    ratio="1280:720"
)
print(f"Task submitted: {task_id}")

ステップ 3: 画像から動画の生成

import base64
from pathlib import Path

def image_to_video(
    image_path: str,
    prompt_text: str = "",
    duration: int = 5,
    ratio: str = "1280:720",
    seed: int = None
) -> str:
    """画像を動画にアニメーションします。image_path はローカルファイルまたはURLです。"""

    if image_path.startswith("http"):
        prompt_image = image_path
    else:
        # ローカルファイルをデータURIとしてエンコード
        img_bytes = Path(image_path).read_bytes()
        ext = Path(image_path).suffix.lstrip(".").lower()
        mime = {"jpg": "image/jpeg", "jpeg": "image/jpeg", "png": "image/png", "webp": "image/webp"}.get(ext, "image/png")
        b64 = base64.b64encode(img_bytes).decode()
        prompt_image = f"data:{mime};base64,{b64}"

    payload = {
        "model": "gen3a_turbo",
        "promptImage": prompt_image,
        "promptText": prompt_text,
        "duration": duration,
        "ratio": ratio
    }
    if seed is not None:
        payload["seed"] = seed

    r = requests.post(f"{BASE_URL}/image_to_video", json=payload, headers=HEADERS)
    r.raise_for_status()
    return r.json()["id"]

task_id = image_to_video(
    image_path="product_shot.png",
    prompt_text="The product slowly rotates, sparkling particles float around it, luxury feel",
    duration=5,
    ratio="1280:720"
)
print(f"Task submitted: {task_id}")

ステップ 4: タスクステータスのポーリング

def get_task(task_id: str) -> dict:
    r = requests.get(f"{BASE_URL}/tasks/{task_id}", headers=HEADERS)
    r.raise_for_status()
    return r.json()

def wait_for_task(task_id: str, poll_interval: int = 5, timeout: int = 600) -> list[str]:
    """タスクが完了するまでポーリングし、出力動画URLのリストを返します。"""
    start = time.time()
    while True:
        task = get_task(task_id)
        status = task["status"]
        progress = task.get("progress", 0)
        print(f"[{int(time.time()-start)}s] Status: {status} ({int(progress*100)}%)")

        if status == "SUCCEEDED":
            return task["output"]  # 動画URLのリスト
        elif status in ("FAILED", "CANCELLED"):
            raise RuntimeError(f"Task {status}: {task.get('failure', '')}")
        elif time.time() - start > timeout:
            raise TimeoutError(f"Task not done after {timeout}s")

        time.sleep(poll_interval)

output_urls = wait_for_task(task_id)
print(f"Video(s) ready: {output_urls}")

ステップ 5: 結果のダウンロード

def download_video(url: str, output_path: str = "output.mp4") -> str:
    r = requests.get(url, stream=True)
    r.raise_for_status()
    with open(output_path, "wb") as f:
        for chunk in r.iter_content(chunk_size=8192):
            f.write(chunk)
    size_mb = os.path.getsize(output_path) / 1024 / 1024
    print(f"Saved: {output_path} ({size_mb:.1f} MB)")
    return output_path

download_video(output_urls[0], "mountain_valley.mp4")

完全なパイプライン例

def generate_and_download(prompt: str, output_path: str = "output.mp4", **kwargs) -> str:
    """ワンショット: テキストから動画を生成しダウンロードします。"""
    print(f"Generating: {prompt[:80]}...")
    task_id = text_to_video(prompt, **kwargs)
    urls = wait_for_task(task_id)
    return download_video(urls[0], output_path)

# 製品広告クリップを生成
生成_and_download(
    prompt="Close-up of a sleek smartphone on a white desk, screen lights up, smooth camera pull-back",
    output_path="product_ad.mp4",
    duration=5,
    ratio="1280:720"
)

パラメータリファレンス

パラメータ値説明
modelgen3a_turboGen-3 Alpha Turbo(最速)を使用
duration5, 10動画の長さ(秒)
ratio1280:720, 720:1280, 1104:832, 832:1104, 960:960解像度のアスペクト比
seed整数決定論的な出力のための再現性シード
promptText文字列希望する動画を説明するテキストプロンプト
promptImageURLまたはデータURI画像から動画の開始画像

ガイドライン

  • Runway タスクは、長さと負荷に応じて30〜120秒かかります。
  • 出力URLは一定期間で期限切れになります — 生成後すぐに動画をダウンロードしてください。
  • プロンプトは説明的で映画的に保ちましょう:カメラの動き、照明、雰囲気を含めます。
  • プロンプトを調整する際に同じ結果を再現するには seed を使用します。
  • バッチ生成の場合は、タスクを並行してキューに入れますが、レート制限を尊重してください(HTTP 429を確認し、Retry-After ヘッダーの値の後に再試行します)。
  • APIキーは環境変数に保存し、ハードコードしないでください。
  • 最新のモデル名とエンドポイントは急速に進化するため、https://docs.runwayml.com で確認してください。

Individual skills in this repo

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

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

関連スキル