CheaperGen

入门指南

快速入门

创建 API 密钥、充值,并在两分钟内使用 JavaScript、Python 或 cURL 生成第一个 AI 视频。

本指南将带你从零开始,使用 Seedance 2.0 Fast 生成视频。所有模型的步骤都相同,只需更换端点和输入字段。

正在使用编程智能体?

将这段内容粘贴到 Claude Code、Cursor、Codex 或任意编程智能体中。它会将 API 接入你的项目,把密钥保存在 CHEAPERGEN_API_KEY 中,并在开始任何付费操作前先用免费报价进行测试。

Add Seedance 2.0 Fast (CheaperGen endpoint bytedance/seedance-2.0-fast/text-to-video) to this project by following https://cheapergen.com/agents/integrate.md
智能体读取的内容
  1. 创建账户和 API 密钥

    登录:Google 账号或电子邮箱均可。然后打开 控制面板 → API 密钥 创建密钥。密钥以 cg_live_… 开头,只显示一次,请复制并妥善保存。

  2. 充值

    CheaperGen 采用预付费模式。前往 控制面板 → 账单。下方示例的费用为 $0.45 — $0.605 位于 the official price。生成失败会自动退款。参见 计费与余额.

  3. 设置 API 密钥

    请勿将密钥写入代码。本文档中的所有示例都会从环境变量中读取密钥:

    export CHEAPERGEN_API_KEY="cg_live_..."
  4. 提交生成任务

    将模型输入发送到 POST /api/v1/run/bytedance/seedance-2.0-fast/text-to-video。下方脚本会提交任务、持续轮询直到完成,并打印视频 URL。

    const API = "https://cheapergen.com/api/v1";
    const headers = {
      Authorization: `Bearer ${process.env.CHEAPERGEN_API_KEY}`,
      "Content-Type": "application/json",
    };
    
    // 1. Submit the job
    let job = await fetch(`${API}/run/bytedance/seedance-2.0-fast/text-to-video`, {
      method: "POST",
      headers,
      body: JSON.stringify({
        "prompt": "黄金时刻,陶艺家缓缓将陶土塑成花瓶,光线中尘埃浮动,浅景深,镜头缓慢推进",
        "aspect_ratio": "16:9",
        "resolution": "720p",
        "duration": 5
      }),
    }).then((r) => r.json());
    
    // 2. Poll until it finishes (or pass webhook_url and skip polling)
    while (job.status === "queued" || job.status === "running") {
      await new Promise((r) => setTimeout(r, 3000));
      job = await fetch(`${API}/generations/${job.id}`, { headers }).then((r) => r.json());
    }
    
    console.log(job.status === "succeeded" ? job.output.video.url : job.error);

    API 会立即返回 202 Accepted,并将生成任务设为 queued 状态。任务运行期间,cost.amount_usd 中显示的冻结金额会从余额中保留。

    202 Accepted
    {
      "id": "gen_8c2QmX1nq0k4Lw7Z",
      "object": "generation",
      "model": "bytedance/seedance-2.0-fast",
      "endpoint": "bytedance/seedance-2.0-fast/text-to-video",
      "mode": "text-to-video",
      "status": "queued",
      "input": {
        "prompt": "黄金时刻,陶艺家缓缓将陶土塑成花瓶,光线中尘埃浮动,浅景深,镜头缓慢推进",
        "aspect_ratio": "16:9",
        "resolution": "720p",
        "duration": 5,
        "generate_audio": true
      },
      "output": null,
      "error": null,
      "cost": {
        "amount_usd": 0.4494,
        "currency": "usd",
        "estimated": true
      },
      "source": "api",
      "created_at": "2026-10-15T09:21:04.512Z",
      "started_at": null,
      "completed_at": null,
      "retention": "1d",
      "expires_at": null,
      "purged_at": null,
      "urls": {
        "get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z",
        "cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z/cancel"
      }
    }
  5. 获取结果

    持续轮询生成任务,直到 status 的状态变为 succeeded 或 failed。视频任务通常需要几分钟;图像只需几秒。

    curl https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z \
      -H "Authorization: Bearer $CHEAPERGEN_API_KEY"
    200 OK
    {
      "id": "gen_8c2QmX1nq0k4Lw7Z",
      "object": "generation",
      "model": "bytedance/seedance-2.0-fast",
      "endpoint": "bytedance/seedance-2.0-fast/text-to-video",
      "mode": "text-to-video",
      "status": "succeeded",
      "input": {
        "prompt": "黄金时刻,陶艺家缓缓将陶土塑成花瓶,光线中尘埃浮动,浅景深,镜头缓慢推进",
        "aspect_ratio": "16:9",
        "resolution": "720p",
        "duration": 5,
        "generate_audio": true
      },
      "output": {
        "video": {
          "url": "https://cdn.cheapergen.com/outputs/gen_8c2QmX1nq0k4Lw7Z.mp4",
          "content_type": "video/mp4"
        }
      },
      "error": null,
      "cost": {
        "amount_usd": 0.4494,
        "currency": "usd",
        "estimated": false
      },
      "source": "api",
      "created_at": "2026-10-15T09:21:04.512Z",
      "started_at": "2026-10-15T09:21:09.031Z",
      "completed_at": "2026-10-15T09:22:31.870Z",
      "retention": "1d",
      "expires_at": "2026-10-16T09:22:31.870Z",
      "purged_at": null
    }

    使用 Webhook 跳过轮询

    在请求正文中添加 "webhook_url": "https://your-app.com/hooks/cheapergen",任务完成后我们会通过 POST 将结果发送给你。参见 Webhooks。

后续步骤#

有不清楚或缺少的内容?发邮件至 support@cheapergen.com——我们会认真阅读每一封邮件。