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.+check-compatibility
引导用户获取Runway API密钥、安装SDK、配置项目以获取API访问权限。
前置条件: 先运行确保项目具备服务端能力。+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
文件(开发环境推荐)
.envCheck 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_hereNode.js项目注意: 确保项目支持加载文件:
.env- Next.js、Remix、Vite — 内置支持,无需额外配置
.env - Express/Fastify/原生Node项目 — 安装:
dotenv在入口文件中添加:bashnpm install dotenvjavascriptimport 'dotenv/config';
Python项目注意: 如果使用的框架没有内置支持,请确保安装了:
.envpython-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 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')
undefinedprint('Runway SDK initialized successfully')
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('Credits:', 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)
+integrate-video - — Image generation
+integrate-image - — Audio generation (TTS, sound effects, voice)
+integrate-audio - — File upload for models that require image/video input
+integrate-uploads
API密钥配置完成后,用户可以继续进行集成:
- — 视频生成(文生视频、图生视频)
+integrate-video - — 图片生成
+integrate-image - — 音频生成(TTS、音效、语音)
+integrate-audio - — 文件上传,供需要图片/视频输入的模型使用
+integrate-uploads