跳转到内容
ReigniterDocs
返回网站

快速入门

本指南将带你从 API 密钥到完成的光盘 MP4 。你需要在 Agency 套餐上注册账户,并且在视频呈现时有几分钟时间。

  1. 拿把 API 密钥

    在应用里,打开 账户> API 密钥,创建一个密钥并复制它。然后把它存到环境变量里,这样它就不会出现在你的代码里:

    终端窗口
    export REIGNITER_API_KEY="emp_..."

    详情请参见认证。

  2. 检查密钥

    打电话 GET /v1/me。200 表示密钥有效。回应还显示你的积分余额。

    终端窗口
    curl https://reigniter.ai/v1/me \
    -H "Authorization: Bearer $REIGNITER_API_KEY"
    {
    "user_id": "3f1c2a9e-8b7d-4c1e-9f0a-2d6b5e4c3a21",
    "email": "dev@example.com",
    "name": "Sam",
    "credits_remaining": 42
    }
  3. 开始视频

    用 brief 呼叫 POST /v1/render。Reigniter 规划场景并开始渲染。发送一个新值的 Idempotency-Key,这样网络重试就不能重复播放同一个视频。

    终端窗口
    curl https://reigniter.ai/v1/render \
    -H "Authorization: Bearer $REIGNITER_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -d '{
    "brief": "A 20 second advert for Northwind Coffee, a small-batch roaster. Warm, early-morning mood. End on the line: Roasted this week, at your door by Friday.",
    "kind": "ad",
    "duration_sec": 20,
    "aspect": "9:16",
    "quality": "draft"
    }'

    你会得到 202 Accepted 和一个 job_id:

    {
    "job_id": "7d2e4b10-5c3a-4f8e-a1b2-9c0d8e7f6a54",
    "status": "starting",
    "title": "Northwind Coffee, at your door by Friday",
    "scenes": 4,
    "credits_used": 12,
    "watermarked": false,
    "poll_url": "/v1/job/7d2e4b10-5c3a-4f8e-a1b2-9c0d8e7f6a54",
    "note": "Render started. Poll poll_url, or subscribe to video.completed via POST /api/webhooks/hooks."
    }
  4. 等工作完成

    每隔几秒轮询 GET /v1/job/{id},直到 status``succeeded、failed或 cancelled。渲染通常需要几分钟。

    终端窗口
    JOB_ID="7d2e4b10-5c3a-4f8e-a1b2-9c0d8e7f6a54"
    while true; do
    JOB=$(curl -s "https://reigniter.ai/v1/job/$JOB_ID" \
    -H "Authorization: Bearer $REIGNITER_API_KEY")
    STATUS=$(echo "$JOB" | jq -r .status)
    echo "$STATUS $(echo "$JOB" | jq -r .progress)%"
    case "$STATUS" in succeeded|failed|cancelled) break ;; esac
    sleep 10
    done
    echo "$JOB"

    完成的作品看起来像这样:

    {
    "job_id": "7d2e4b10-5c3a-4f8e-a1b2-9c0d8e7f6a54",
    "status": "succeeded",
    "progress": 100,
    "video_url": "https://cdn.example.com/exports/7d2e4b10.mp4",
    "error": null
    }

    你可以订阅一个 video.completedwebhook,而不是轮询。

  5. 下载视频

    video_url 是 MP4的直接链接。下载并存储在你这边。

    终端窗口
    curl -L -o northwind.mp4 "$(echo "$JOB" | jq -r .video_url)"
  • 401:检查密钥和 Bearer 前缀。参见 认证。
  • 402:该账户不在Agency 套餐中,或者已经积分。请阅读 code。
  • 422 BRAND_REQUIRED 、 NO_ANCHOR或 400 PRESENTER_REQUIRED:渲染需要品牌、产品照片或演示者。参见 制作视频。
  • 429:慢点。参见 《极限》。

所有状态和 code 都列在 错误中。