指南用 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 该等待,哪些该停下?
| 响应 | 含义 | agent 应该 |
|---|---|---|
429 rate_limited | 本分钟请求过多 | 等 Retry-After 秒后重试 |
429 concurrency_limit_reached | 已有 2 个生成在进行 | 等 Retry-After 秒后重试 |
402 key_spend_limit_reached | Key 的花费上限已用完 | 停下并报告 |
402 insufficient_balance | 余额不够付这次报价 | 停下并报告 |
402 daily_spend_limit_reached | 达到每日上限,UTC 零点重置 | 停下并报告 |
400 invalid_request | 传了模型不收的字段,如 resolution | 停下;改输入,不换模型 |
410 quote_expired | 报价已超过 12 分钟 | 重新报价 |
生成失败或超时,冻结金额全额释放,agent 可以用新报价和新的 Idempotency-Key 重试。注:如果成品因内容违规被输出审核拦截,这次生成仍会扣费。可联系客服申请人工复核。完整请求流程见 API 文档 和 API 集成最佳实践。
