Communitygithub.com

API Runway ML

API Runway ML para geração e edição de vídeo por IA — Gen-3 Alpha Turbo, imagem-para-vídeo e vídeo-para-vídeo. Use ao gerar vídeo a partir de texto ou imagens, aplicar efeitos de vídeo com IA ou automatizar pipelines de produção criativa de vídeo.

O que é API Runway ML?

Esta skill expõe a API REST do Runway ML, permitindo que agentes de IA gerem vídeos de alta qualidade a partir de prompts de texto ou imagens estáticas usando o modelo Gen-3 Alpha Turbo. Ela segue um padrão de tarefa assíncrona: criar uma tarefa, aguardar a conclusão por polling e, em seguida, baixar o resultado. É ideal para acelerar a produção de conteúdo audiovisual, como clipes cinematográficos, animação de produtos ou pipelines automatizados de geração em lote. A skill suporta plataformas como Claude Code, Cursor e Codex, e fornece exemplos completos de código Python para cada etapa, incluindo parâmetros como duração (5 ou 10 segundos), proporção de tela e semente para reprodutibilidade. O guia também inclui boas práticas, como gerenciamento de limites de taxa, armazenamento seguro de chaves de API e dicas para prompts descritivos que maximizam a qualidade do resultado.

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

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

O que API Runway ML faz?

Visão Geral

O modelo Gen-3 Alpha Turbo da Runway gera vídeos de alta qualidade a partir de prompts de texto ou imagens. A API REST segue um padrão de tarefa assíncrona: crie uma tarefa, monitore a conclusão e baixe o resultado. Use-a para produzir clipes cinematográficos, animar imagens ou construir pipelines automatizados de conteúdo de vídeo.

Configuração

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

URL base: https://api.dev.runwayml.com/v1
Documentação da API: https://docs.runwayml.com

Conceitos Principais

  • Tarefa: Um job assíncrono de geração de vídeo. Retorna um task_id imediatamente.
  • Gen-3 Alpha Turbo: O modelo Gen-3 mais rápido — ideal para pipelines de produção.
  • imagem-para-vídeo (gen3a_turbo): Anime uma imagem estática.
  • texto-para-vídeo: Gere vídeo puramente a partir de um prompt de texto.
  • Duração: 5 ou 10 segundos.
  • Proporção: 1280:720 (paisagem), 720:1280 (retrato), 1104:832, 832:1104, 960:960 (quadrado).

Instruções

Passo 1: Configurar o cliente

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"
}

Passo 2: Geração de texto para vídeo

def text_to_video(
    prompt_text: str,
    duration: int = 5,
    ratio: str = "1280:720",
    seed: int = None
) -> str:
    """Envia uma tarefa de texto para vídeo e retorna o 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="Um plano aéreo sobrevoando um vale montanhoso com névoa na hora dourada, cinematográfico, câmera lenta",
    duration=5,
    ratio="1280:720"
)
print(f"Tarefa enviada: {task_id}")

Passo 3: Geração de imagem para vídeo

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:
    """Anima uma imagem para vídeo. image_path pode ser um arquivo local ou URL."""

    if image_path.startswith("http"):
        prompt_image = image_path
    else:
        # Codifica arquivo local como data 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="foto_produto.png",
    prompt_text="O produto gira lentamente, partículas brilhantes flutuam ao redor, sensação de luxo",
    duration=5,
    ratio="1280:720"
)
print(f"Tarefa enviada: {task_id}")

Passo 4: Monitorar o status da tarefa

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]:
    """Monitora até a tarefa ser concluída; retorna lista de URLs de vídeo de saída."""
    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"]  # lista de URLs de vídeo
        elif status in ("FAILED", "CANCELLED"):
            raise RuntimeError(f"Tarefa {status}: {task.get('failure', '')}")
        elif time.time() - start > timeout:
            raise TimeoutError(f"Tarefa não concluída após {timeout}s")

        time.sleep(poll_interval)

output_urls = wait_for_task(task_id)
print(f"Vídeo(s) pronto(s): {output_urls}")

Passo 5: Baixar o resultado

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"Salvo: {output_path} ({size_mb:.1f} MB)")
    return output_path

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

Exemplo de pipeline completo

def generate_and_download(prompt: str, output_path: str = "output.mp4", **kwargs) -> str:
    """Única chamada: gera vídeo a partir de texto e baixa."""
    print(f"Gerando: {prompt[:80]}...")
    task_id = text_to_video(prompt, **kwargs)
    urls = wait_for_task(task_id)
    return download_video(urls[0], output_path)

# Gere um clipe de anúncio de produto
generate_and_download(
    prompt="Close-up de um smartphone elegante sobre uma mesa branca, tela acende, suave afastamento de câmera",
    output_path="anuncio_produto.mp4",
    duration=5,
    ratio="1280:720"
)

Referência de parâmetros

ParâmetroValoresDescrição
modelgen3a_turboUse Gen-3 Alpha Turbo (mais rápido)
duration5, 10Duração do vídeo em segundos
ratio1280:720, 720:1280, 1104:832, 832:1104, 960:960Proporção de resolução
seedinteiroSemente de reprodutibilidade para resultados determinísticos
promptTextstringPrompt de texto descrevendo o vídeo desejado
promptImageURL ou data URIImagem inicial para imagem-para-vídeo

Diretrizes

  • Tarefas do Runway levam de 30 a 120 segundos, dependendo da duração e carga.
  • As URLs de saída expiram após um período — baixe os vídeos imediatamente após a geração.
  • Mantenha os prompts descritivos e cinematográficos: inclua movimento de câmera, iluminação e clima.
  • Use seed para reproduzir o mesmo resultado ao iterar sobre prompts.
  • Para geração em lote, enfileire tarefas em paralelo, mas respeite os limites de taxa (verifique HTTP 429 e repita após o valor do cabeçalho Retry-After).
  • Armazene chaves de API em variáveis de ambiente — nunca as codifique diretamente.
  • Consulte https://docs.runwayml.com para obter os nomes e endpoints mais recentes do modelo, pois eles evoluem rapidamente.

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.

Habilidades Relacionadas