REST API
工作室的 REST 端点位于 /api/v1/studio 之下,所完成的工作与 MCP 工具相同。
约定
- 所有响应均为 JSON,结果位于
data之下;错误位于error之下,包含code和message。 - 消耗点数的端点会以
200响应,返回报价和"confirm_required": true。要开始执行,请发送相同的请求并带上"confirm": true;此时的响应为202。 - 工作室无法执行的请求(点数不足、达到智能体每日限额、缺少脚本)会返回
422,错误码为STUDIO_REFUSED,并附上原因。 - 任务在后台运行。响应中包含
next,说明应调用什么来跟进进度。
端点
| 方法与路径 | 权限范围 | 作用 |
|---|---|---|
GET /api/v1/studio | ad.view | 点数、智能体限额及其剩余额度、已配置的内容以及各项数量。 |
GET /api/v1/studio/options | ad.view | 形式、可用的出镜人和声音、平台、时长、语言、档位、尺寸和版式。 |
GET /api/v1/studio/brand | workspace.view | 品牌套件。 |
GET /api/v1/studio/products | product.view | 商品,最新的在前。 |
POST /api/v1/studio/products | product.manage | 从 url 导入商品。 |
GET /api/v1/studio/products/{id} | product.view | 单个商品,包含其允许的宣称和评论切入角度。 |
POST /api/v1/studio/ads | ad.manage | 开始制作广告并撰写脚本。 |
GET /api/v1/studio/ads/{id} | ad.view | 状态、脚本、出镜人阵容,以及带文件链接的已制作版本。 |
PATCH /api/v1/studio/ads/{id} | ad.manage | 选定脚本、出镜人、声音或档位。 |
POST /api/v1/studio/ads/{id}/produce | ad.manage | 先报价,再制作选定的脚本。 |
POST /api/v1/studio/image-ads | ad.manage | 先报价,再制作批量、轮播图或商品摄影。 |
GET /api/v1/studio/image-ads/{id} | ad.view | 一组图片,包含每张图片的文字和文件。 |
POST /api/v1/studio/references | research.manage | 先报价,再研究来自 url 的广告。 |
GET /api/v1/studio/references/{id} | research.view | 已研究的广告及其模式。 |
示例:从商品到视频
为 12 号商品开始制作广告,生成三份脚本:
curl -X POST https://your-installation.example/api/v1/studio/ads \
-H "Authorization: Bearer ag_live_…" \
-H "Content-Type: application/json" \
-d '{"product_id": 12, "format": "problem-solution", "length": 30, "language": "en", "scripts": 3}'
{"data": {"started": true, "id": 41, "status": "writing", "next": "Call get_ad until scripts are written, then choose one with update_ad."}}
持续读取该广告,直到脚本写好,然后选定脚本和出镜人阵容:
curl -X PATCH https://your-installation.example/api/v1/studio/ads/41 \
-H "Authorization: Bearer ag_live_…" \
-H "Content-Type: application/json" \
-d '{"script_id": 97, "actor_id": 5, "voice_id": 3}'
请求报价:
curl -X POST https://your-installation.example/api/v1/studio/ads/41/produce \
-H "Authorization: Bearer ag_live_…" \
-H "Content-Type: application/json" \
-d '{"ratios": ["4:5", "1:1"], "captions": "bold"}'
{"data": {"quote": {"credits": 1080, "items": [...], "missing": []}, "credits": 7900, "agent_credits_left_today": 2000, "confirm_required": true, "next": "Call again with confirm: true to spend these credits."}}
发送相同的请求体并带上 "confirm": true 即可开始。响应会给出 version_id;请持续读取该广告,直到该版本完成并列出其文件。
字段
| 端点 | 字段 |
|---|---|
| 创建广告 | product_id(必填)、format、platform(meta、tiktok、youtube_shorts、generic)、length(15、30、45、60)、language、tier(budget、standard、premium)、angle、audience、scripts(1–6)。 |
| 制作 | 除 9:16 之外的 ratios(1:1、4:5、16:9)、captions(bold、boxed、clean、none)、broll、confirm。 |
| 图片广告 | product_id(必填)、kind(batch、carousel、photoshoot)、count(最多 20;轮播图为 8)、ratios(1:1、4:5、9:16)、layouts、language、note、confirm。 |
限制
请求按密钥限速,套餐包含每月一定数量的 API 请求。发送 Idempotency-Key 请求头,可使重试的 POST 请求保持安全。
Still stuck? Open a ticket and a person on the team answers by email.