rw-setup-api-key
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSetup API Key
设置API密钥
Guide the user through obtaining a Runway API key, installing the SDK, and configuring their project for API access.
PREREQUISITE: Runfirst to ensure the project has server-side capability.+rw-check-compatibility
引导用户获取Runway API密钥、安装SDK并配置项目以实现API访问。
前提条件: 先运行以确保项目具备服务端能力。+rw-check-compatibility
Step 1: Create a Runway Developer Account
步骤1:创建Runway开发者账户
Direct the user to:
- Go to https://dev.runwayml.com/
- Create an organization (or use an existing one)
- Navigate to Organization Settings → API Keys
- Click Create API Key
- 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.
引导用户执行以下操作:
- 访问https://dev.runwayml.com/
- 创建一个组织(或使用现有组织)
- 导航至组织设置 → API密钥
- 点击创建API密钥
- 立即复制密钥——密钥仅显示一次,无法找回
需告知用户的重要警告:
- 丢失的密钥无法找回。若丢失,请禁用旧密钥并创建新密钥。
- 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/sdkRequires Node.js 18+. The SDK includes TypeScript type definitions.
bash
npm install @runwayml/sdk要求Node.js 18+。SDK包含TypeScript类型定义。
Python
Python
bash
pip install runwaymlRequires 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 environment variable.
RUNWAYML_API_SECRETSDK会自动从环境变量中读取API密钥。
RUNWAYML_API_SECRETOption A: .env
file (recommended for development)
.env选项A:.env文件(开发环境推荐)
Check if the project already has a file. If so, append to it. If not, create one.
.envRUNWAYML_API_SECRET=your_api_key_hereFor Node.js projects: Ensure the project loads files:
.env- Next.js, Remix, Vite — built-in support, no extra setup needed
.env - Express/Fastify/plain Node — install :
dotenvAdd to the entry point:bashnpm install dotenvjavascriptimport 'dotenv/config';
For Python projects: Ensure is installed if not using a framework with built-in support:
python-dotenvbash
pip install python-dotenvAdd to the entry point:
python
from dotenv import load_dotenv
load_dotenv()检查项目是否已有文件。若有,则追加内容;若无,则创建该文件。
.envRUNWAYML_API_SECRET=your_api_key_here对于Node.js项目: 确保项目加载文件:
.env- Next.js、Remix、Vite——内置支持,无需额外设置
.env - Express/Fastify/纯Node项目——安装:
dotenv在入口文件中添加:bashnpm install dotenvjavascriptimport 'dotenv/config';
对于Python项目: 若使用的框架无内置支持,请确保已安装:
python-dotenvbash
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_herebash
export RUNWAYML_API_SECRET=your_api_key_hereOption C: Pass directly to the client (not recommended)
选项C:直接传入客户端(不推荐)
javascript
// Node.js
const client = new RunwayML({ apiKey: 'your_api_key_here' });python
undefinedjavascript
// Node.js
const client = new RunwayML({ apiKey: 'your_api_key_here' });python
undefinedPython
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 is in to prevent accidentally committing the API key:
.env.gitignore.env
.env.local
.env.*.localCheck the existing and add the entry if it's missing.
.gitignore确保已添加到中,防止意外提交API密钥:
.env.gitignore.env
.env.local
.env.*.local检查现有,若缺少上述条目则添加。
.gitignoreStep 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')
undefinedprint('Runway SDK初始化成功')
undefinedStep 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
- file is in
.env.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:
- — Video generation (text-to-video, image-to-video)
+rw-integrate-video - — Image generation
+rw-integrate-image - — Audio generation (TTS, sound effects, voice)
+rw-integrate-audio - — File upload for models that require image/video input
+rw-integrate-uploads
API密钥配置完成后,用户可继续进行集成:
- —— 视频生成(文本转视频、图像转视频)
+rw-integrate-video - —— 图像生成
+rw-integrate-image - —— 音频生成(文本转语音、音效、语音)
+rw-integrate-audio - —— 为需要图像/视频输入的模型上传文件
+rw-integrate-uploads