Makernice
← 全部文章
桌上一台打开终端的笔记本电脑,旁边放着一小卷胶片和一把挂锁指南

用 Claude Code、Codex、Gemini 或 Grok 批量出片

Makernice 团队 · ·

价格截至 2026 年 11 月 2 日(价表 v12)。

让 Claude Code、Codex、Gemini、Grok 这类编码 agent 批量出片,先给它一个单独设了花费上限和有效期的 Makernice API Key,再让它对每条视频依次报价、带 Idempotency-Key 创建、轮询结果。用 seedance-2.0-fast 跑 10 条 10 秒的测试批次共 $10.27(价表 v12,2026 年 11 月 2 日),而且这个 Key 花不出它的上限。

为什么要给 agent 单独一个 API Key?

  • 在控制台给这个 Key 设花费上限和有效期。Key 的花费 = 它创建的生成已扣金额加冻结金额;失败和取消的不计入。
  • 把 Key 放在 MAKERNICE_API_KEY 这类环境变量里,从 agent 的终端或你的服务器调用 API。API 不接受浏览器跨域请求(没有 CORS)。
  • 用量页会按 Key 和模型拆分 API 花费,事后很容易找到 agent 这一批。
  • 停用或删除 Key 从下一个请求起生效,可以立刻止住失控的循环。

agent 在花钱之前能先查什么?

GET /v1/models 列出每个模型的模式、时长、分辨率和可选字段,GET /v1/pricing 列出单价,两者都不需要 Key。报价也是免费的,它只给输入算价。先让 agent 读这些,免得它猜一个模型不收的字段。

# Public, no API key needed
curl https://api.makernice.com/v1/models
curl https://api.makernice.com/v1/pricing

该给 agent 什么指令?

Generate one 10-second video for each line of prompts.txt with the Makernice API.

API base: https://api.makernice.com/v1
Key: the MAKERNICE_API_KEY environment variable. Never print it or write it to a file.
Model: seedance-2.0-fast, mode t2v, duration 10. Do not send a resolution field.

1. Quote line 1 (POST /generations/quote). Show me the amount
   (micro-USD, millionths of a US dollar) and wait for my OK.
2. For each line N: quote it, then POST /generations with
   {"quote_id": ..., "input": ...} and the header Idempotency-Key: prompts-line-N.
3. Poll GET /generations/{id} every 5 seconds until succeeded, failed or canceled.
4. Download outputs[0].url (a path on the API host) with the key into out/line-N.mp4.

On 429: wait the Retry-After seconds, then retry the same request.
On any 402: stop the whole batch and report the error code.
On 400 or 422: stop and show me the error body. Do not switch models.
At the end, print a table: line, generation id, status, billing, amount.

第一次创建前先报一次价、等你确认,就多了一道价格检查,又不拖慢整批。每一行都有自己的 Idempotency-Key,重跑时复用幂等键只会拿回原来的生成或得到 422 idempotency_conflict,同一行绝不会扣第二次。

agent 跑一批测试要花多少钱?

批次`model`每条合计
10 条 × 10 秒seedance-2.0-fast$1.03$10.27
100 条 × 10 秒seedance-2.0-fast$1.03$102.72

价格取自价表 v12(2026 年 11 月 2 日);seedance-2.0-fast 只有一个固定档位,按 720p 计价,agent 不会误选更贵的分辨率。如果一批加起来超过默认的每日上限 100 美元,agent 会在中途收到 402 daily_spend_limit_reached,除非客服提高了上限。在计算器里换别的模型算 →

一只机械臂按下印着胶片画格的按钮,按钮由电缆连到一把钥匙,钥匙上的小仪表限制着花费
按按钮的是 agent,能走多远由 Key 的花费上限决定。

哪些错误 agent 该等待,哪些该停下?

响应含义agent 应该
429 rate_limited本分钟请求过多等 Retry-After 秒后重试
429 concurrency_limit_reached已有 2 个生成在进行等 Retry-After 秒后重试
402 key_spend_limit_reachedKey 的花费上限已用完停下并报告
402 insufficient_balance余额不够付这次报价停下并报告
402 daily_spend_limit_reached达到每日上限,UTC 零点重置停下并报告
400 invalid_request传了模型不收的字段,如 resolution停下;改输入,不换模型
410 quote_expired报价已超过 12 分钟重新报价

生成失败或超时,冻结金额全额释放,agent 可以用新报价和新的 Idempotency-Key 重试。注:如果成品因内容违规被输出审核拦截,这次生成仍会扣费。可联系客服申请人工复核。完整请求流程见 API 文档 和 API 集成最佳实践。

常见问题

编码 agent 会在 Makernice 上花超我允许的钱吗?
超不过 Key 的花费上限:会超出上限的创建请求在冻结任何金额之前就返回 402 key_spend_limit_reached。账户的每日上限(默认每个 UTC 日 100 美元)同时生效。
agent 能在浏览器代码里调用 Makernice API 吗?
不能。API 不接受浏览器跨域请求,而且写进前端代码的 Key 会被人复制。把 Key 放在环境变量里,从终端、脚本或服务器调用 API。
agent 把同一个创建请求发了两次会怎样?
同一个 Idempotency-Key、同一份报价和输入,第二次请求以 200 返回原来那个生成,不会扣费。幂等键相同但报价或输入不同,会得到 422 idempotency_conflict。

本文涉及的模型