rw-setup-api-key

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Setup API Key

设置API密钥

Guide the user through obtaining a Runway API key, installing the SDK, and configuring their project for API access.
PREREQUISITE: Run
+rw-check-compatibility
first to ensure the project has server-side capability.
引导用户获取Runway API密钥、安装SDK并配置项目以实现API访问。
前提条件: 先运行
+rw-check-compatibility
以确保项目具备服务端能力。

Step 1: Create a Runway Developer Account

步骤1:创建Runway开发者账户

Direct the user to:
  1. Go to https://dev.runwayml.com/
  2. Create an organization (or use an existing one)
  3. Navigate to Organization Settings → API Keys
  4. Click Create API Key
  5. Copy the key immediately — it is only shown once and cannot be recovered
Important warnings to tell the user:
  • Lost keys cannot be retrieved. If lost, disable the old key and create a new one.
  • API keys are organization-scoped, not user-scoped.
  • You must prepay for credits before the API will work. Minimum purchase is $10 (1,000 credits at $0.01/credit). Do this at https://dev.runwayml.com/ under billing.
引导用户执行以下操作:
  1. 访问https://dev.runwayml.com/
  2. 创建一个组织(或使用现有组织)
  3. 导航至组织设置 → API密钥
  4. 点击创建API密钥
  5. 立即复制密钥——密钥仅显示一次,无法找回
需告知用户的重要警告:
  • 丢失的密钥无法找回。若丢失,请禁用旧密钥并创建新密钥。
  • API密钥为组织级,而非用户级。
  • 在API可用前,您必须预付费购买额度。最低购买金额为10美元(1000额度,单价0.01美元/额度)。请前往https://dev.runwayml.com/的账单页面进行操作。

Step 2: Install the SDK

步骤2:安装SDK

Node.js

Node.js

bash
npm install @runwayml/sdk
Requires Node.js 18+. The SDK includes TypeScript type definitions.
bash
npm install @runwayml/sdk
要求Node.js 18+。SDK包含TypeScript类型定义。

Python

Python

bash
pip install runwayml
Requires Python 3.8+. Includes MyPy type annotations.
bash
pip install runwayml
要求Python 3.8+。包含MyPy类型注解。

Step 3: Configure the Environment Variable

步骤3:配置环境变量

The SDK automatically reads the API key from the
RUNWAYML_API_SECRET
environment variable.
SDK会自动从
RUNWAYML_API_SECRET
环境变量中读取API密钥。

Option A:
.env
file (recommended for development)

选项A:.env文件(开发环境推荐)

Check if the project already has a
.env
file. If so, append to it. If not, create one.
RUNWAYML_API_SECRET=your_api_key_here
For Node.js projects: Ensure the project loads
.env
files:
  • Next.js, Remix, Vite — built-in
    .env
    support, no extra setup needed
  • Express/Fastify/plain Node — install
    dotenv
    :
    bash
    npm install dotenv
    Add to the entry point:
    javascript
    import 'dotenv/config';
For Python projects: Ensure
python-dotenv
is installed if not using a framework with built-in support:
bash
pip install python-dotenv
Add to the entry point:
python
from dotenv import load_dotenv
load_dotenv()
检查项目是否已有
.env
文件。若有,则追加内容;若无,则创建该文件。
RUNWAYML_API_SECRET=your_api_key_here
对于Node.js项目: 确保项目加载
.env
文件:
  • Next.js、Remix、Vite——内置
    .env
    支持,无需额外设置
  • Express/Fastify/纯Node项目——安装
    dotenv
    bash
    npm install dotenv
    在入口文件中添加:
    javascript
    import 'dotenv/config';
对于Python项目: 若使用的框架无内置支持,请确保已安装
python-dotenv
bash
pip install python-dotenv
在入口文件中添加:
python
from dotenv import load_dotenv
load_dotenv()

Option B: System environment variable

选项B:系统环境变量

bash
export RUNWAYML_API_SECRET=your_api_key_here
bash
export RUNWAYML_API_SECRET=your_api_key_here

Option C: Pass directly to the client (not recommended)

选项C:直接传入客户端(不推荐)

javascript
// Node.js
const client = new RunwayML({ apiKey: 'your_api_key_here' });
python
undefined
javascript
// Node.js
const client = new RunwayML({ apiKey: 'your_api_key_here' });
python
undefined

Python

Python

client = RunwayML(api_key='your_api_key_here')

**Warn the user:** Never hardcode keys in source code. Use environment variables or a secrets manager.
client = RunwayML(api_key='your_api_key_here')

**警告用户:** 切勿在源代码中硬编码密钥。请使用环境变量或密钥管理器。

Step 4: Update .gitignore

步骤4:更新.gitignore

Ensure
.env
is in
.gitignore
to prevent accidentally committing the API key:
.env
.env.local
.env.*.local
Check the existing
.gitignore
and add the entry if it's missing.
确保
.env
已添加到
.gitignore
中,防止意外提交API密钥:
.env
.env.local
.env.*.local
检查现有
.gitignore
,若缺少上述条目则添加。

Step 5: Verify the Setup

步骤5:验证设置

Suggest the user run a quick verification:
建议用户运行快速验证:

Node.js

Node.js

javascript
import RunwayML from '@runwayml/sdk';

const client = new RunwayML();
// If no error is thrown, the API key is configured correctly
console.log('Runway SDK initialized successfully');
javascript
import RunwayML from '@runwayml/sdk';

const client = new RunwayML();
// 若未抛出错误,则API密钥配置正确
console.log('Runway SDK初始化成功');

Python

Python

python
from runwayml import RunwayML

client = RunwayML()
python
from runwayml import RunwayML

client = RunwayML()

If no error is thrown, the API key is configured correctly

若未抛出错误,则API密钥配置正确

print('Runway SDK initialized successfully')
undefined
print('Runway SDK初始化成功')
undefined

Step 6: Confirm Credit Balance

步骤6:确认额度余额

Remind the user:
  • The API requires prepaid credits to function
  • Minimum purchase: $10 (1,000 credits)
  • Purchase at: https://dev.runwayml.com/ → Billing
  • They can check their balance via the API:
javascript
// Node.js - check organization info
const response = await fetch('https://api.dev.runwayml.com/v1/organization', {
  headers: {
    'Authorization': `Bearer ${process.env.RUNWAYML_API_SECRET}`,
    'X-Runway-Version': '2024-11-06'
  }
});
const org = await response.json();
console.log('Credits:', org.creditBalance);
提醒用户:
  • API需要预付费额度才能运行
  • 最低购买金额:10美元(1000额度)
  • 购买地址:https://dev.runwayml.com/ → 账单页面
  • 他们可通过API查询余额:
javascript
// Node.js - 查询组织信息
const response = await fetch('https://api.dev.runwayml.com/v1/organization', {
  headers: {
    'Authorization': `Bearer ${process.env.RUNWAYML_API_SECRET}`,
    'X-Runway-Version': '2024-11-06'
  }
});
const org = await response.json();
console.log('额度:', org.creditBalance);

Security Checklist

安全检查清单

Before moving on, verify:
  • API key is stored in an environment variable, not hardcoded
  • .env
    file is in
    .gitignore
  • API calls will only happen server-side (not in browser-executed code)
  • User has purchased credits
继续操作前,请验证:
  • API密钥存储在环境变量中,未硬编码
  • .env
    文件已添加到
    .gitignore
  • API调用仅在服务端执行(不在浏览器运行的代码中)
  • 用户已购买额度

Next Steps

下一步

Once the API key is configured, the user can proceed with integration:
  • +rw-integrate-video
    — Video generation (text-to-video, image-to-video)
  • +rw-integrate-image
    — Image generation
  • +rw-integrate-audio
    — Audio generation (TTS, sound effects, voice)
  • +rw-integrate-uploads
    — File upload for models that require image/video input
API密钥配置完成后,用户可继续进行集成:
  • +rw-integrate-video
    —— 视频生成(文本转视频、图像转视频)
  • +rw-integrate-image
    —— 图像生成
  • +rw-integrate-audio
    —— 音频生成(文本转语音、音效、语音)
  • +rw-integrate-uploads
    —— 为需要图像/视频输入的模型上传文件