Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# RunwayML Python API library
# Runway Dev Python API library

<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/runwayml.svg?label=pypi%20(stable))](https://pypi.org/project/runwayml/)

The RunwayML Python library provides convenient access to the RunwayML REST API from any Python 3.9+
application. The library includes type definitions for all request params and response fields,
The official Python SDK for [Runway Dev](https://dev.runway.com), Runway's API for video, image and audio generation
and real-time conversational avatars. One API key calls Runway's own models and models from other labs, listed in the
[model catalog](https://dev.runway.com/models/catalog), along with Model Routers, Recipes and published Workflows.

The library works from any Python 3.9+ application. It includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

It is generated with [Stainless](https://www.stainless.com/).
Expand All @@ -20,32 +23,53 @@ The REST API documentation can be found on [docs.dev.runwayml.com](https://docs.
pip install runwayml
```

Create an API key in [Runway Dev](https://dev.runway.com) and set it as `RUNWAYML_API_SECRET` in your server environment.

## Usage

The full API of this library can be found in [api.md](api.md).

Generation is asynchronous: a create call starts a task, and `wait_for_task_output()` polls it until the output is ready.

```python
import os
from runwayml import RunwayML
from runwayml import RunwayML, TaskFailedError

client = RunwayML(
api_key=os.environ.get("RUNWAYML_API_SECRET"), # This is the default and can be omitted
)

image_to_video = client.image_to_video.create(
model="gen4_turbo",
prompt_image="https://example.com/assets/bunny.jpg",
ratio="1280:720",
prompt_text="The bunny is eating a carrot",
)
print(image_to_video.id)
try:
task = client.image_to_video.create(
model="gen4.5",
prompt_image="https://example.com/assets/bunny.jpg",
prompt_text="The bunny is eating a carrot",
ratio="1280:720",
duration=5,
).wait_for_task_output()
# On success, task.output lists the output URLs. They are temporary, so download anything you want to keep.
print(task)
except TaskFailedError as error:
print(error.task_details)
```

To start a task without waiting, drop `.wait_for_task_output()`, keep the returned `id` and check it later with `client.tasks.retrieve(id)`.

While you can provide a `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `RUNWAYML_API_SECRET="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Build with a coding agent

Runway Dev MCP gives Claude Code, Codex or Cursor live access to your Runway Dev account while it writes code with this SDK: the models, prices and limits available to your project, your Model Routers, and the cause of a failed task. To add it to Claude Code:

```sh
claude mcp add --transport http --scope user runway-dev-mcp https://dev.runwayml.com/mcp
```

Sign-in is OAuth, so no API key goes into the configuration. Setup for other agents, and the Runway Dev skills that show your agent how to use this SDK, are in [runwayml/skills](https://github.com/runwayml/skills) and the [MCP guide](https://docs.dev.runwayml.com/guides/mcp/).

## Async usage

Simply import `AsyncRunwayML` instead of `RunwayML` and use `await` with each API call:
Expand Down
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
[project]
name = "runwayml"
version = "5.22.0"
description = "The official Python library for the runwayml API"
description = "The official Python SDK for Runway Dev, Runway's API for video, image and audio generation"
dynamic = ["readme"]
license = "Apache-2.0"
keywords = [
"runway",
"runway-dev",
"runwayml",
"ai-video",
"video-generation",
"image-generation",
"text-to-video",
"image-to-video",
"text-to-speech",
"generative-ai",
"api",
"sdk",
]
authors = [
{ name = "RunwayML", email = "dev-feedback@runwayml.com" },
]
Expand Down Expand Up @@ -37,7 +51,8 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/runwayml/sdk-python"
Homepage = "https://dev.runway.com"
Documentation = "https://docs.dev.runwayml.com"
Repository = "https://github.com/runwayml/sdk-python"

[project.optional-dependencies]
Expand Down
Loading