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
+check-compatibility
first to ensure the project has server-side capability.
引导用户获取Runway API密钥、安装SDK、配置项目以获取API访问权限。
前置条件: 先运行
+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项目注意: 如果使用的框架没有内置
.env
支持,请确保安装了
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 initialized successfully');

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 initialized successfully')
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('Credits:', 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:
  • +integrate-video
    — Video generation (text-to-video, image-to-video)
  • +integrate-image
    — Image generation
  • +integrate-audio
    — Audio generation (TTS, sound effects, voice)
  • +integrate-uploads
    — File upload for models that require image/video input
API密钥配置完成后,用户可以继续进行集成:
  • +integrate-video
    — 视频生成(文生视频、图生视频)
  • +integrate-image
    — 图片生成
  • +integrate-audio
    — 音频生成(TTS、音效、语音)
  • +integrate-uploads
    — 文件上传,供需要图片/视频输入的模型使用