# RunwayML

[RunwayML](https://docs.dev.runwayml.com/) provides APIs for generating videos with Runway Gen and Runway-hosted models. AISIX lets applications submit and manage those tasks through the gateway's video API while managing the Runway credential, caller access, rate limits, and usage accounting.

This guide configures RunwayML for the AISIX [video-generation API](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md). Runway does not provide a chat-completions API, so use Runway-backed model aliases only for video tasks.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before starting, prepare the following:

* One AISIX setup:

  <!-- -->

  * For AISIX Enterprise or AISIX Cloud, an environment with an attached gateway and a write-scoped admin token. For AISIX Enterprise, follow the [AISIX Enterprise getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/aisix-cloud-quickstart.md). To request AISIX Cloud access, [contact API7](https://api7.ai/contact).
  * For the open-source AISIX gateway, prepare either a local AISIX installation or the Docker setup from the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Configure the gateway to load a declarative resources file.

* A Runway API key from the [Runway developer portal](https://dev.runwayml.com/).

* `curl` and `jq`.

The developer portal is a separate surface from the `runwayml.com` web app. API keys exist only in the portal, and API credits are a separate pool from web-app credits — a web-app subscription does not fund API calls. See the [Runway API FAQs](https://help.runwayml.com/hc/en-us/articles/21668552945171-Runway-API-FAQs).

## Configure with AISIX Enterprise or AISIX Cloud[​](#configure-with-aisix-enterprise-or-aisix-cloud "Direct link to Configure with AISIX Enterprise or AISIX Cloud")

Export the control-plane connection details:

```
# AISIX_CP is the Admin API base URL; include /api and omit a trailing slash

# The local AISIX Enterprise quickstart uses http://localhost:8080/api

export AISIX_CP="YOUR_AISIX_CONTROL_PLANE_API_URL"

export AISIX_TOKEN="YOUR_ADMIN_TOKEN"

export ENV_ID="YOUR_ENVIRONMENT_ID"
```

Create a provider key, model alias, and caller API key for the Runway-backed video route.

### Create a Provider Key[​](#create-a-provider-key "Direct link to Create a Provider Key")

Create the provider key that stores the Runway credential and API root:

```
# Replace with your value

export RUNWAY_API_KEY="YOUR_PROVIDER_API_KEY"



PROVIDER_KEY_ID=$(curl -sS -X POST "$AISIX_CP/provider_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "runwayml-prod",

    "provider": "runwayml",

    "api_key": "'"${RUNWAY_API_KEY}"'",

    "api_base": "https://api.dev.runwayml.com",

    "allowed_environments": ["'"${ENV_ID}"'"]

  }' | jq -r '.provider_key.id')



echo "$PROVIDER_KEY_ID"
```

❶ `provider` is `runwayml`, the provider value the AISIX video routes recognize. The AISIX Cloud Admin API derives the `openai` adapter for this provider; the `adapter` field is only accepted on BYO provider keys. The derived adapter applies only to chat-style routes that Runway does not serve.

❷ `api_key` stores the Runway API key and is sent as a bearer token on upstream calls. It follows the credential-handling behavior in [Provider Keys](https://docs.api7.ai/ai-gateway/models/provider-keys.md#credential-handling).

❸ `api_base` is the bare host. Runway's documented API base carries no version segment — the `/v1` belongs to the endpoint paths, so AISIX composes `/v1/text_to_video` and `/v1/tasks/{id}` onto this root as written. The field is optional for this provider — when it is omitted, the AISIX Cloud Admin API fills in the same value. Set it explicitly so the upstream root stays visible on the resource. Do not append `/v1`: AISIX strips no version suffix from this provider's base, so `https://api.dev.runwayml.com/v1` builds `/v1/v1/…` paths and fails upstream.

The command captures the returned provider key ID in `PROVIDER_KEY_ID`.

### Create a Model[​](#create-a-model "Direct link to Create a Model")

Runway's text-to-video endpoint — the endpoint the gateway submits to — currently serves `gen4.5`, `veo3.1`, `veo3.1_fast`, `veo3`, `happyhorse_1_0`, `seedance2`, `seedance2_fast`, `seedance2_mini`, and `gemini_omni_flash`. Other Runway model IDs, such as the image-to-video model `gen4_turbo`, are rejected by this endpoint, so an alias naming them fails at submission. Check the [Runway API reference](https://docs.dev.runwayml.com/api/#text-to-video) for the current catalog and each model's accepted parameters before creating a model alias.

Create the model alias callers will send in requests:

```
MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "runway-video-prod",

    "model_name": "gen4.5",

    "provider_key_id": "'"${PROVIDER_KEY_ID}"'"

  }' | jq -r '.model.id')



echo "$MODEL_ID"
```

❶ `display_name` is the alias callers send in `model`.

❷ `model_name` is the Runway model ID, for example `gen4.5` or `veo3.1`.

❸ `provider_key_id` attaches the alias to the RunwayML provider key.

### Create a Caller API Key[​](#create-a-caller-api-key "Direct link to Create a Caller API Key")

Create the caller API key that can access the model alias. The plaintext key is server-generated and returned once in the response, so capture it now:

```
AISIX_API_KEY=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/api_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "runwayml-caller",

    "allowed_models": ["'"${MODEL_ID}"'"]

  }' | jq -r '.plaintext')



echo "$AISIX_API_KEY"
```

The `allowed_models` value must reference the model ID captured in the previous step, so the key can only access the alias you created. After the write, the configuration projects to attached gateways automatically.

## Configure with AISIX OSS[​](#configure-with-aisix-oss "Direct link to Configure with AISIX OSS")

Export the upstream credential and choose the caller API key that applications will send to the gateway:

```
export RUNWAY_API_KEY="YOUR_PROVIDER_API_KEY"

export CALLER_API_KEY="YOUR_CALLER_API_KEY"

export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"
```

For a new gateway, use this complete resources file. For an existing gateway, merge the entries into its [current file](https://docs.api7.ai/ai-gateway/reference/resources-file.md#apply-resource-examples-safely), preserving its other resources:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 66c1ee47-f97c-46e4-80fb-dc9a428d1a3a

    display_name: "runwayml-prod"

    provider: "runwayml"

    adapter: "openai"

    api_key: ${RUNWAY_API_KEY}

    api_base: "https://api.dev.runwayml.com"



models:

  - id: aa8a40e4-f5e5-482f-b7c4-da67c4ffc6fe

    display_name: "runway-video-prod"

    provider: "runwayml"

    model_name: "gen4.5"

    provider_key_id: 66c1ee47-f97c-46e4-80fb-dc9a428d1a3a



api_keys:

  - id: fbc2480b-faa0-4884-8983-b1060e245c1b

    display_name: "runwayml-caller"

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - "runway-video-prod"
```

If AISIX is installed locally, validate the file before loading it:

```
aisix validate --resources resources.yaml
```

After validation, start the gateway with the referenced environment variables in its process environment. Reload an existing gateway only if those variables are already available to the process; otherwise, restart it with the updated environment.

If you use Docker, adapt the validation and startup commands in the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Mount this `resources.yaml` file and pass every environment variable it references with `-e` in both commands. After the resources load, prepare the shared verification request below:

```
export AISIX_API_KEY="$CALLER_API_KEY"
```

## Verify the Provider Connection[​](#verify-the-provider-connection "Direct link to Verify the Provider Connection")

Export the AISIX gateway origin:

```
# AISIX_PROXY has no trailing slash or endpoint path

# The local quickstarts use http://127.0.0.1:3000

export AISIX_PROXY="YOUR_AISIX_GATEWAY_URL"
```

Because this provider serves no chat surface, verify the connection with a video task. Submit it through the AISIX proxy:

```
curl -sS -X POST "$AISIX_PROXY/v1/videos" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "runway-video-prod",

    "prompt": "A lighthouse beam sweeps across a foggy harbor at night.",

    "seconds": 5,

    "size": "1280x720"

  }'
```

The gateway returns a video job object whose `status` is `queued` — Runway's create response confirms only that the task was accepted — and whose `id` is the gateway-issued video ID for the follow-up calls. Poll the task until it completes, then download the result:

```
curl -sS "$AISIX_PROXY/v1/videos/YOUR_VIDEO_ID" \

  -H "Authorization: Bearer ${AISIX_API_KEY}"



curl -sS -L -o video.mp4 \

  "$AISIX_PROXY/v1/videos/YOUR_VIDEO_ID/content" \

  -H "Authorization: Bearer ${AISIX_API_KEY}"
```

If the submission fails, check the provider key `api_key`, the bare-host `api_base`, and the Runway model ID in `model_name`. Four provider-specific behaviors are worth knowing before you script around this route:

* **The gateway sends the mandatory API version header itself.** Runway requires an `X-Runway-Version` header on every API call and rejects requests without it. AISIX sets `X-Runway-Version: 2024-11-06` — the [API version](https://docs.dev.runwayml.com/api-details/versions/2024-11-06/) its request and response handling is written against — on both the submit and the poll calls. The header is not operator-configurable and never appears in gateway configuration.
* **`size` maps to Runway's `ratio` and is required in practice.** AISIX converts the unified `WIDTHxHEIGHT` value to Runway's `WIDTH:HEIGHT` resolution string by swapping the separator, so `1280x720` reaches Runway as `"1280:720"`. Runway validates the result against a per-model list of supported pixel resolutions, and its text-to-video endpoint requires `ratio`, so a request without `size` is rejected by the provider rather than defaulted by the gateway. `seconds` is forwarded as the provider's integer `duration`; accepted durations are also model-specific. Check the model's entry in the [Runway API documentation](https://docs.dev.runwayml.com/) for both lists.
* **The normalized route models only common text-to-video fields.** AISIX sends the upstream model ID, `promptText`, and the optional `ratio` and `duration` mappings described above. Additional JSON fields are ignored, including Runway-specific controls such as negative prompts, generated-audio options, and reference media. To use those fields, call `/passthrough/runwayml/v1/text_to_video` with Runway's native request body, the exact upstream model ID, and the required `X-Runway-Version: 2024-11-06` header. The `/passthrough/runwayml` paths on this page assume a [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) claiming that prefix with Runway's API root as its `target_url`; grant the route name on the caller key's `allowed_routes`.
* **`THROTTLED` is a queued state.** AISIX maps Runway's `PENDING` and `THROTTLED` task states to `queued` — both mean the task is accepted but not yet running — with `RUNNING` reported as `in_progress`, `SUCCEEDED` as `completed`, and `FAILED` or `CANCELLED` as `failed`. A failed task carries Runway's machine-readable `failureCode` and human-readable `failure` text in the unified `error` object.
* **Finished videos are delivered by redirect.** A completed Runway task reports its output as a list of signed URLs, and `GET /v1/videos/{id}/content` returns `302` with a `Location` header pointing at the first of them. The bytes travel from Runway's storage to the client and do not pass through the gateway, so use `curl -L` when downloading.

For the full submit, poll, and download workflow, including status semantics and rate-limit behavior on polling, see [Video Generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md).

## Model IDs and Cost Metadata[​](#model-ids-and-cost-metadata "Direct link to Model IDs and Cost Metadata")

RunwayML is not listed on models.dev, the public catalog that supplies the control plane's model suggestions and pricing. That has two consequences for this provider:

* The dashboard suggests no model IDs. Take IDs from the [Runway API documentation](https://docs.dev.runwayml.com/) and enter them in `model_name` directly.
* The pricing catalog carries no prices for Runway models. The control plane supports [pricing overrides](https://docs.api7.ai/ai-gateway/cloud/model-pricing.md), but video submissions record zero tokens and do not apply duration-based cost to budgets, so an override does not price this workflow. See [Video Generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md#endpoint-behavior).

## Endpoint Coverage[​](#endpoint-coverage "Direct link to Endpoint Coverage")

A RunwayML provider key exists for the video routes. Every chat-shaped route resolves a URL under the same bare host, and Runway serves none of them:

| Route                                          | Behavior with a `runwayml` model alias                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/v1/videos` and its status and content routes | Supported. This is the only modeled route the provider serves. See [Verify the Provider Connection](#verify-the-provider-connection).                                                                                                                                                                                                                                                                                               |
| `/v1/chat/completions`                         | Fails upstream. Runway publishes no chat-completions API; AISIX appends `/chat/completions` to the provider key base and the resulting path does not exist at the upstream.                                                                                                                                                                                                                                                         |
| `/v1/embeddings`                               | Fails upstream. Runway publishes no embeddings API.                                                                                                                                                                                                                                                                                                                                                                                 |
| `/v1/responses`                                | Fails upstream. The Responses bridge issues a chat-completions call, which Runway does not serve.                                                                                                                                                                                                                                                                                                                                   |
| `/v1/images/generations`                       | Not supported. The route accepts only models whose provider is `openai` or whose provider key uses the `azure-openai` adapter (see [Provider Requirement](https://docs.api7.ai/ai-gateway/endpoints/image-generation.md#provider-requirement)). Reach Runway's image endpoints through a passthrough route instead.                                                                                                                 |
| `/v1/rerank`                                   | Not supported. The route accepts only the `openai`, `cohere`, and `jina` provider values.                                                                                                                                                                                                                                                                                                                                           |
| `/passthrough/runwayml/*rest`                  | Available through a configured [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) for Runway APIs and fields the gateway has not modeled, including image-to-video and provider-specific text-to-video controls. The route forwards caller headers and injects only the credential, so the caller must set `X-Runway-Version` itself — AISIX adds that header only on the modeled video routes. |

See [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md) for the full endpoint and provider matrix.

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have now connected AISIX to RunwayML and verified the model alias with a video task. Continue with these guides:

* [Model Aliases](https://docs.api7.ai/ai-gateway/models/model-aliases.md): configure routing, retry behavior, or cost metadata for this alias.
* [Video Generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md): follow the full submit, poll, and download workflow.
* [Passthrough Routes](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md): reach Runway APIs the gateway has not modeled.
* [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md): review supported proxy endpoints and provider-specific boundaries.
