Runway Integration Guide
What is Runway?
@runwayml/sdk, server-side only: no webhooks, so submit, store the id, poll from a worker, re-host.
Don't call waitForTaskOutput() in a Vercel handler: it waits up to 10 minutes against a 300-second function default, and aborting it doesn't cancel the task or stop the spend (use tasks.delete). Output URLs expire in 24-48 hours, so copy them to R2 or Blob. Moderation arrives as status FAILED rather than an HTTP error, costs credits, and repeated hits can suspend the project, so screen prompts first. Narrow on status before reading failureCode. For Kenya-targeted products, buy credits in USD, quote KES after conversion, and deliver a compressed 480p or 720p copy for 2G/3G and WhatsApp.
Five Runway primitives
A task is the unit of work; everything else decides who picks the model and how many steps run.
██████╗ ██╗ ██╗███╗ ██╗██╗ ██╗ █████╗ ██╗ ██╗
██╔══██╗██║ ██║████╗ ██║██║ ██║██╔══██╗╚██╗ ██╔╝
██████╔╝██║ ██║██╔██╗ ██║██║ █╗ ██║███████║ ╚████╔╝
██╔══██╗██║ ██║██║╚██╗██║██║███╗██║██╔══██║ ╚██╔╝
██║ ██║╚██████╔╝██║ ╚████║╚███╔███╔╝██║ ██║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝Runway Integration Guide
Focus: generate video, images and audio through Runway Dev from a server, without losing work to expiring URLs or credits to moderation, and know when to use a Recipe, a Model Router, a Workflow or real-time Characters instead of a single model call.
Overview
Runway has two products that are easy to confuse:
| Runway app | Runway Dev (this guide) | |
|---|---|---|
| Who it's for | Creators, in a browser or mobile app | Developers, over an API |
| URL | app.runwayml.com | Portal: dev.runway.com · API: https://api.dev.runwayml.com |
| Pays with | Runway app plan and credits | Project credits at $0.01 each ($10 minimum purchase) |
| Agent access | Generation MCP, mcp.runwayml.com | Developer MCP, dev.runwayml.com/mcp |
The API surface has six parts:
- Direct generation: 12 core endpoints such as
/v1/text_to_video,/v1/image_to_video,/v1/video_to_video,/v1/text_to_image,/v1/character_performance, and the audio endpoints. - Recipes: one call for a known job, such as a product ad, product swap, UGC clip, multi-shot video or ad localization.
- Model Routers: a saved preference (cost, latency or quality) that picks the model for you.
- Workflows: node graphs built in the Runway app and published as private, versioned endpoints.
- Characters: real-time, WebRTC conversational avatars, with tool calling and knowledge documents.
- Organization: credit balance, tier and usage for the project that owns the key.
Which one to reach for:
| You want… | Use |
|---|---|
| A polished product ad or similar known output, in one call | Recipe |
| Not to hardcode a model ID that will age, or a hard per-generation price cap | Model Router |
| A multi-step pipeline your creative team edits without a code change | Workflow |
| Full control over one model's parameters | Direct model call |
| A live, talking agent on a page | Characters |
Official Documentation
| Resource | URL | What it covers |
|---|---|---|
| Agent primer | https://docs.dev.runwayml.com/ai-context.md | Auth, task lifecycle, the whole surface, in one short file |
| Using the API | https://docs.dev.runwayml.com/guides/using-the-api/ | Worked Node, Python and HTTP examples |
| Models | https://docs.dev.runwayml.com/guides/models/ | Current model IDs; the only safe list |
| Per-model fields | https://docs.dev.runwayml.com/api.md | Every endpoint's allowed values by model |
| OpenAPI spec | https://docs.dev.runwayml.com/openapi.json | Machine-readable OpenAPI 3.1 |
| Pricing | https://docs.dev.runwayml.com/guides/pricing/ | Credit costs; the single source of truth |
| Task failures | https://docs.dev.runwayml.com/errors/task-failures/ | failureCode values and retry rules |
| Go-live checklist | https://docs.dev.runwayml.com/guides/go-live/ | Tiers, autobilling, key handling, monitoring |
| Changelog | https://docs.dev.runwayml.com/api-details/api_changelog/ | New models and retirements |
| Product overview | https://runway.com/product | The creator-facing product |
Every docs page is also available as Markdown by appending .md to its path.
Setup
- Create a project at dev.runway.com.
- Create one API key per environment and per developer. The key is shown only once. Keys belong to the project, so removing a person does not revoke their key: disable it separately.
- Add credits ($10 minimum), then set up autobilling before launch.
npm install @runwayml/sdk
pip install runwaymlThe Node SDK needs Node 18+. The Python package requires Python 3.9+ (PyPI metadata for 5.24.0; the SDK docs page still says 3.8). Versions checked on 2026-11-01: @runwayml/sdk 4.24.0, runwayml 5.24.0, @runwayml/avatars and @runwayml/avatars-react 0.17.0.
Environment variable, read automatically by both SDKs. It is server-side only:
RUNWAYML_API_SECRET=your_api_key_hereQuickstart
import RunwayML, { TaskFailedError, TaskTimedOutError } from "@runwayml/sdk";
const client = new RunwayML(); // reads RUNWAYML_API_SECRET
try {
const task = await client.textToVideo
.create({
model: "gen4.5",
promptText: "A timelapse on a sunny day with clouds flying by",
ratio: "1280:720",
duration: 5,
})
.waitForTaskOutput({ timeout: 5 * 60 * 1000 });
console.log(task.output[0]); // temporary URL: download it
} catch (error) {
if (error instanceof TaskFailedError) {
const details = error.taskDetails;
console.error(details.status === "FAILED" ? details.failureCode : details.status);
} else if (error instanceof TaskTimedOutError) {
console.error("Still running. The task was not cancelled.");
} else {
throw error;
}
}Without an SDK, send Authorization: Bearer <key> and X-Runway-Version: 2024-11-06 on every request. A request without the version header fails.
This shape suits scripts. For a web app, use the job pattern in the next section.
Key patterns
Submit, store, poll, re-host
Runway has no webhooks: the docs never mention them and the OpenAPI callbacks object is empty. So the production flow is:
- Submit from a route handler and get back
{ id }. It does not contain the result. - Store the task id immediately, against the user and the job.
- Poll
tasks.retrieve(id)from a cron or queue worker, with backoff. - On
SUCCEEDED, copy the output to your own storage. Output URLs expire within 24-48 hours, and Runway says not to expose them in your product.
| Status | Meaning | Do |
|---|---|---|
PENDING, RUNNING | In progress | Keep polling |
THROTTLED | Queued behind your concurrency limit; not an error | Keep polling; alert if counts climb |
SUCCEEDED | Only this status has output | Re-host, then mark done |
FAILED | Has failure and optional failureCode | Classify (below) |
CANCELLED | Cancelled | Mark cancelled |
Three traps in the convenience helper:
waitForTaskOutput()waits 10 minutes by default. Vercel functions default to a 300-second limit, so don't wait inside a request handler.- A timeout or an aborted signal stops polling only. The task keeps running and billing unless you call
tasks.delete(id). DELETE /v1/tasks/{id}cancels a running task or deletes a finished one.
The docs describe no idempotency key, so treat a create call as non-idempotent. See PATTERNS.md for the full job flow.
Request fields are per model
Bodies are discriminated unions on model. Ratios, durations, prompt limits and even which fields are required all change between models:
| Model | Endpoints | Notable limits |
|---|---|---|
gen4.5 | text, image to video | ratio and duration required; ratio 1280:720 or 720:1280 on text to video; 2-10 s; 1,000-char prompt |
gen4_turbo | image to video only | No text-only mode |
aleph2 | video to video only | Edits existing footage |
seedance2_5 | text, image, video to video | 4-30 s; up to 15,000-char prompt; draft mode |
kling_4 | text, image, video to video | 3-30 s; 720p or 1080p; always has audio |
veo3.1_fast | text, image to video | duration is 4, 6 or 8 only |
Look the exact model up in api.md before building a body. Router endpoints differ again: they take aspectRatio: "16:9", not ratio: "1280:720", and the two are not interchangeable.
Retired IDs error out: gen3a_turbo (use gen4.5 or gen4_turbo) and gen4_aleph (use aleph2).
Supplying input media
| Method | Size limit | Use when |
|---|---|---|
| HTTPS URL | 16 MB image, 32 MB video or audio | Media is already hosted |
| Data URI | 5 MB encoded, about 3.3 MB of binary | Small images only |
| Ephemeral upload | 200 MB (512-byte minimum); URI valid 24 h | Local or large files; reusable |
- URLs must be HTTPS and return valid
Content-TypeandContent-Lengthheaders. Redirects are not followed: a 3XX fails the request, so don't pass a URL that redirects. - GIF images aren't supported.
- Inputs are auto-cropped to the target ratio, which can silently change the composition.
import { createReadStream } from "node:fs";
import RunwayML from "@runwayml/sdk";
const client = new RunwayML();
const { uri } = await client.uploads.createEphemeral({
file: createReadStream("./clip.mp4"),
});
// uri is runway://... and works anywhere a URL doesDocs bug, checked against SDK 4.24.0: the uploads page shows createEphemeral(myFile), but the method destructures { file }. The bare form fails type checking and has no file to upload, so always pass the object.
Failures and retries
HTTP errors: retry 429, 502, 503 and 504 with exponential backoff and up to 50% jitter (the SDKs do this for you). Never retry 400, 401, 404 or 405. A 429 on task creation means you've hit the rolling 24-hour generation limit. There is no requests-per-minute limit, and excess submissions queue as THROTTLED, so you don't need client-side rate limiting for Runway's sake.
Task failures arrive as status: "FAILED", not as an HTTP error:
failureCode | Retry? |
|---|---|
SAFETY.INPUT.*, SAFETY.OUTPUT.* | No. Credits are not refunded for SAFETY.INPUT.*. Don't show the code to users; it is diagnostic only |
INPUT_PREPROCESSING.SAFETY.TEXT | No |
ASSET.INVALID | No. Fix the input's dimensions, duration or format |
INTERNAL.BAD_OUTPUT.* | After changing the input. Common causes: logos, watermarks or overlaid text in inputs; asking for rendered text; "write a prompt for…" |
THIRD_PARTY.UNAVAILABLE | Not immediately; wait, then retry |
INPUT_PREPROCESSING.INTERNAL, INTERNAL, or null | Yes, with a delay |
Moderation
Moderated generations cost the same as successful ones, and too many moderated requests suspend the account. That one suspension would take down every app on the project, so screen user prompts before calling Runway. contentModeration.publicFigureThreshold: "low" relaxes public-figure checks; leave it at the default auto unless you have documented consent.
Costs
Reference rates from the pricing page on 2026-11-01. They change often, so check the page before quoting anyone. One credit is $0.01.
| Model | Credits | 5-second video |
|---|---|---|
grok_imagine_1_5_lite 720p | 3/s, plus 1 for a start frame | 15 ($0.15) |
gen4_turbo | 5/s | 25 ($0.25) |
wan3 480p / 720p / 1080p | 5 / 10 / 20 per s | 25 / 50 / 100 |
gen4.5 | 12/s | 60 ($0.60) |
kling_4 720p, no input video | 15.7/s; 12.56/s through 2026-11-30 UTC | 64 during the promotion |
veo3.1_fast, audio / none | 15 / 10 per s | 75 / 50 |
seedance2_5 480p / 720p / 1080p | 20 / 30 / 68 per s, 80 minimum, plus input video | 100 / 150 / 340 |
aleph2 | 28/s, 56 minimum | 140 ($1.40) |
Also: muse_image 1 credit, gen4_image_turbo 2, gen4_image 5-8 per image. A full 5-minute Characters session is 102 credits (2 upfront, then 2 per 6 seconds). Professional formats add 5 credits/s (prores, png_sequence) or 20-40 credits/s (10-bit and HDR).
Seedance 2.5 draft mode: draft: true renders a 480p preview, and draftTaskId enhances a chosen one to 1080p within 7 days. For a 5-second clip, one preview plus enhance is 440 credits against 340 for going straight to 1080p. Drafts win only once you iterate: two attempts cost 540 against 680.
Limits
Limits are per model, per project, and set by a usage tier that rises automatically with spend. Most models in a modality use the same limit values, each counted separately, and Characters uses the video values. In the docs' example, Tier 3 runs 5 concurrent Gen-4.5 and 5 concurrent Veo 3.1 generations at once. Check your tier before launch: a low one will quietly queue users behind THROTTLED rather than fail.
Model Routers
Create a router in the Developer Portal, then send its configId instead of a model. You pay the chosen model's standard rate, with no surcharge, and each response reports the model and realized cost. Use /v1/generate/video, /image or /audio. A request nothing can satisfy fails with a no-eligible-model error.
import RunwayML from "@runwayml/sdk";
const client = new RunwayML();
const task = await client.generate.video
.create({
configId: "preview-fast",
input: { promptText: "A red panda in a lantern-lit alley", aspectRatio: "16:9", duration: 5 },
})
.waitForTaskOutput();Workflows
workflows.run(id, { nodeOutputs })starts an invocation. Keys are node ID, then output key (prompt,image,video,audio).- Poll
workflowInvocations.retrieve(id), nottasks.retrieve. - Unknown node IDs and keys are ignored silently, so typos don't error.
- A
SUCCEEDEDinvocation can still contain failed nodes. ChecknodeErrorsand confirm every node you expect is inoutput. - A 400 can mean a node uses a retired model; a 404 can mean the key belongs to a different project.
Characters (real-time avatars)
An Avatar is a saved persona: one reference image, a voice, a personality and knowledge. A Session is one live WebRTC call, capped at 5 minutes.
npm install @runwayml/avatars-reactThe server creates the session and polls until READY, then your client connects. Session credentials can be retrieved only once; if the connection fails afterwards, create a new session. The server-side flow is in PATTERNS.md.
import { AvatarCall } from "@runwayml/avatars-react";
import "@runwayml/avatars-react/styles.css";
export function Call() {
return <AvatarCall avatarId="your-avatar-id" connectUrl="/api/avatar/connect" />;
}The connectUrl route can return either { sessionId, sessionKey }, and the SDK consumes the session for you, or { sessionId, serverUrl, token, roomName } if you consume it on the server, which saves a round trip.
MCP and agent tooling
| Server | URL | Purpose | Billing |
|---|---|---|---|
| Runway Dev MCP | https://dev.runwayml.com/mcp (Claude: /mcp/claude) | Look up tasks, manage routers, read docs | Developer account |
| Runway MCP | https://mcp.runwayml.com | Create media in chat | Runway app credits |
Both use OAuth with no API key in the client config. For Claude Code:
claude mcp add --transport http --scope user runway-dev-mcp https://dev.runwayml.com/mcp/claudeThen run /mcp, select the server and authenticate in your own browser; Runway asks that agents not automate sign-in. Call whoami to confirm. The /mcp/claude endpoint can't create Characters. Runway also publishes a Runway Dev plugin and an agent skills repo.
codeAmani notes
- Secrets:
RUNWAYML_API_SECRETis server-side only, neverNEXT_PUBLIC_*, and lives in Hazina or Vercel env. Use a separate key per environment and developer. If one leaks, disable it in the portal right away. Runway suggestsgit grep "key_"as a check; our gitleaks gate still runs first. - AI routing: Runway is a media provider, next to Claude for reasoning, OpenAI for structured output and HuggingFace for open models. Have Claude draft or clean a prompt, then send it to Runway. See
ai-video/for choosing among video providers, and put Runway behind that guide's adapter when a product may switch. - Direct vs AI SDK: use
@runwayml/sdkdirectly for Runway-only features such as Aleph 2.0, Recipes, Routers, Workflows and Characters. - Hosting: store finished media in R2 or Vercel Blob. Vercel function bodies cap at 4.5 MB, so upload large inputs straight to storage, then pass Runway a non-redirecting HTTPS URL. Poll with a cron or queue, and never from a request handler.
- Abuse: a public "generate" button spends real money. Require sign-in with Clerk, cap per-user spend, screen prompts, and watch the credit balance through
organization.retrieve(). - Data handling: the developer docs don't describe input retention or training. Confirm this in Runway's terms or an enterprise agreement before sending client-confidential footage. Never send PHI or patient images.
- US-first default: Stripe charges your customers, and your Runway credits are a cost of goods. Price from the realized credits on the job, including re-renders and moderated attempts.
- Kenya-targeted projects: the docs make no language claims for Swahili, so test any speech with native speakers. Runway generation is priced in credits bought in USD, so convert and cap costs before quoting KES prices through M-Pesa. Deliver a compressed 480p or 720p rendition with a poster image for 2G/3G and WhatsApp, and keep the master in storage.
- Provenance: tell clients when a deliverable is AI-generated, and keep the prompt, model, task id and date with each asset. Moderation decisions and third-party model terms can change, so re-check before reusing an old pipeline.