四种接入方式,一份契约
文档目录展开
01 · 入门
先选一种接入方式#
四种方式共用同一份价格、错误码与余额。选哪种只取决于你的宿主:给 Agent 用就选 Skill, 写代码就选 HTTP,MCP 与 CLI 也已上线,按宿主能力选择。
02 · 推荐
Skill:把一句话交给 Agent#
第一屏那句指令就是完整接入方式。Agent 会读取 https://openclub.uumit.com/SKILL.md,拿到认证、三个动词、错误码、失败退款与版本更新规则。
可直接粘贴给 Agent
set up https://openclub.uumit.com/SKILL.mdAgent 会自动对齐到线上版本:与线上不一致时拉线上覆盖本地,不按数值大小比较,不用本地版本覆盖线上。
01
读 SKILL.md
认证方式、三个动词、错误码、退款规则
02
discover / inspect
语义检索候选卡;取 schema 与价格。两个都免费
03
run
带 Idempotency-Key 执行;失败按商品声明的规则计费
03 · 已上线
MCP:客户端里加一个 server#
面向已支持 MCP 的客户端(Claude / Cursor / Codex / OpenClaw)。把下面的 Streamable HTTP 端点加进客户端配置, 工具面固定 7 个,与 Agent 面 7 个端点一一对应;鉴权用同一把平台 Key(pat_...)。
{
"mcpServers": {
"uumit-openclub": {
"type": "streamableHttp",
"url": "https://openclub.uumit.com/mcp/openclub/mcp",
"headers": {
"Authorization": "Bearer <你的 pat_ Key>"
}
}
}
}7 个工具:openclub_discover / openclub_inspect / openclub_run / openclub_runs_list / openclub_runs_get / openclub_runs_stop / openclub_balance。旧客户端可用 SSE: /mcp/openclub/sse。
同一意图只选一条通道
混用 MCP / CLI / HTTP 时,复用同一个 Idempotency-Key,避免重复扣费。
04 · 已上线
CLI:终端里探索与调试#
装一次即可在终端 / CI 里做确定性调用。run 是付费调用,需 --yes 确认;--dry-run 只预演不扣费,幂等键会在输出里回传,重试时复用。
npm install -g @uumit-ai/openclubopenclub discover -q "抖音评论采集" -l 5 --jsonopenclub inspect -s douyin-comments --jsonopenclub run -s douyin-comments --input '{"keyword":"咖啡","limit":200}' --yes --json05 · 已上线
HTTP:任何语言直接集成#
公开面匿名可读(可用于比价、行情页、目录镜像);Agent 面只要一把平台 Key(pat_...): Authorization: Bearer <pat_...>, 不需要用户 ID。所有响应都是统一信封, 写请求必须带 Idempotency-Key,字段统一使用 snake_case; 机器可读契约见 openapi.json。
公开面(无需鉴权)
| GET | /api/v1/openclub/public/categories | 一级类目与在售商品数(扁平数组) |
| GET | /api/v1/openclub/public/tags | 标签清单,按维度分组,含商品数 |
| GET | /api/v1/openclub/public/products | 工具(产品)列表:分类 / 关键词 / 游标 |
| GET | /api/v1/openclub/public/products/{slug} | 工具详情与端点列表 |
| GET | /api/v1/openclub/public/goods | 列表:品类 / kind / tags(多值 AND)/ 供给形态 / 关键词 / 游标 |
| GET | /api/v1/openclub/public/goods/{slug} | 详情:定价卡、输入输出 schema、示例、健康度、标签 |
| GET | /api/v1/openclub/public/providers | 供给方列表与商品数 |
| GET | /api/v1/openclub/public/stats | 聚合计数(商品、品类、标签、供给方) |
Agent 面(需要 API Key)
| POST | /api/v1/openclub/discover | 语义检索:按一句话找候选,返回 items 与 hints。免费 |
| POST | /api/v1/openclub/inspect | 返回输入 schema、定价卡与文档链接。免费 |
| POST | /api/v1/openclub/run | 执行调用,必须带 Idempotency-Key;失败按商品规则不计费 |
| GET | /api/v1/openclub/runs | 调用记录列表(游标分页) |
| GET | /api/v1/openclub/runs/{run_id} | 调用详情,wait=<秒> 可长轮询 |
| POST | /api/v1/openclub/runs/{run_id}/stop | 停止调用;不可停止的调用会返回 409 |
| GET | /api/v1/openclub/balance | 读取 UT 余额:可用、冻结、总额 |
三步示例
先把 Key 放进环境变量,示例里不出现真实 Key(Key 在 API Keys 页创建;完整值可随时在列表里复制):export UUMIT_API_KEY='<你的 API Key>'
1) discover(免费)
curl -sS https://openclub.uumit.com/api/v1/openclub/discover \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $UUMIT_API_KEY" \
-d '{"query":"抖音评论采集","category":"data-social","limit":5}'2) inspect(免费)
curl -sS https://openclub.uumit.com/api/v1/openclub/inspect \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $UUMIT_API_KEY" \
-d '{"slug":"douyin-comments"}'3) run(付费,失败按规则计费)
curl -sS https://openclub.uumit.com/api/v1/openclub/run \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $UUMIT_API_KEY" \
-H 'Idempotency-Key: 6f1b0c1e-6a7b-4a2b-9d4e-4b6c0f7a1d20' \
-d '{"slug":"douyin-comments","input":{"keyword":"咖啡","limit":200}}'run 响应要点
{
"run_id": 12345,
"lease_id": "b0b6f1e2-6a7b-4a2b-9d4e-4b6c0f7a1d20",
"attempt_id": "9f2c7a41-3b8e-4f6a-8c2d-1e0f9a8b7c6d",
"status": "COMPLETED",
"provider_status": 200,
"output": {
"items": [],
"total": 0
},
"price": {
"model": "PER_RESULT",
"currency": "UT",
"unit": "RESULT",
"amount": null,
"display": "0.70 UT / 条"
},
"cost": {
"amount": "0.700000",
"currency": "UT"
},
"billed_units": "1",
"error_code": null,
"error_message": null,
"hints": [
{
"kind": "get_run",
"run_id": 12345
},
{
"kind": "balance",
"message": "用 balance 确认预扣"
}
]
}hints 是契约的一部分:按它做下一步,不要靠读文档猜。 异步商品会立即返回 status=RUNNING,用 GET /runs/{id}?wait=30 长轮询。
06 · 生成式
图片 API:/v1/images/generations#
图片走两段式:POST 换 task_uuid,GET 看状态与成品。报文对齐 ToAPIs / 灵镜开放平台,从那边迁过来只改 base_url 与 Key;状态词表是 queued / running / succeeded / failed / cancelled / timed_out。
两段式端点(与 /api/v1/openclub/* 共用一把 Key、一个 UT 余额)
| POST | /v1/images/generations | 提交图片任务:202 + task_uuid;同一 Idempotency-Key 重放回 200 + reused |
| POST | /v1/videos/generations | 提交视频任务,同上 |
| GET | /v1/tasks/{task_uuid} | 任务状态、进度与成品;首次查到终态时结算 |
| GET | /v1/images/generations/{task_uuid} | 图片路径别名:同报文;任务媒体不是图片时回 400 task_media_mismatch |
| GET | /v1/videos/generations/{task_uuid} | 视频路径别名:同报文;任务媒体不是视频时回 400 task_media_mismatch |
| GET | /v1/tasks | 任务列表,游标分页(limit / cursor) |
| POST | /v1/tasks/{task_uuid}/cancel | 取消任务;终态返回 409 task_not_cancellable |
| GET | /v1/models | 在售生成式模型与价格(需 Key,不扣费) |
这组端点的字段以本节与 GET /v1/models 的返回为准( openapi.json 只导出 /api/v1/openclub/*)。
请求参数
prompt:必填,图像提示词model:兼容字段,不参与路由;实际执行该路径绑定的在售商品n:张数,默认 1,按实际成品张数结算size / resolution:比例与档位(1k / 2k / 4k,以商品 schema 为准)quality / background:透传上游image_urls:参考图公网 URL(图生图 / 改图)
计费与失败
- 提交时按价格卡预扣(
billing.estimated),不是扣款 - 终态按实际成品数结算(
billing.amount),差额释放 - 失败 / 取消 / 超时:全额释放,计 0
提交 → 轮询 → 取图
curl -sS https://openclub.uumit.com/v1/images/generations \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $UUMIT_API_KEY" \
-H 'Idempotency-Key: 6f1b0c1e-6a7b-4a2b-9d4e-4b6c0f7a1d20' \
-d '{"prompt":"雨夜霓虹街头,35mm 胶片质感,一只橘猫","size":"1:1","resolution":"1k"}'{
"task_uuid": "d82b58170ce9427b9531acf93db61058",
"status": "queued",
"task_type": "image",
"billing_state": "reserved",
"billing": {
"state": "reserved",
"estimated": "13.026000",
"amount": "0.000000",
"currency": "UT"
}
}{
"task_uuid": "d82b58170ce9427b9531acf93db61058",
"status": "succeeded",
"progress": 100,
"task_type": "image",
"billing_state": "settled",
"billing": {
"state": "settled",
"estimated": "13.026000",
"amount": "13.026000",
"currency": "UT"
},
"result": {
"items": [
{
"index": 0,
"kind": "image",
"status": "ready",
"url": "https://files.example.com/generated/xxxx.png",
"expires_at": "2026-12-20T08:09:40+00:00"
}
],
"data": [
{
"url": "https://files.example.com/generated/xxxx.png",
"expires_at": "2026-12-20T08:09:40+00:00"
}
]
}
}成品在 result.items[];ToAPIs 客户端读 result.data[],是同一份数据。expires_at 务必逐条读、不要写死 24 小时:拿到 ready 立刻下载转存,过期后不可恢复。
要按商品挑模型,走 /api/v1/openclub/run
两段式路径对应目录里配置的一个在售商品,请求体里的 model 不参与路由。先用 GET /v1/models 看当前可用模型与 openclub_slug,再按 slug 调 /run 就能指定任意图片商品(含 ToAPIs 固定价系列)。
07 · 生成式
视频 API:/v1/videos/generations#
视频与图片共用同一套两段式任务面,差别在参数与计费:按秒 × 分辨率倍率计价,提交时按时长预扣, 终态按实际时长结算;成品是 mp4,同样落在 result.items[].url。
| 模型(/v1/models 的 id) | 名称 | 时长 | 分辨率 |
|---|---|---|---|
| seedance_2.0_mini | Seedance 2.0 轻量版 | 4–15 秒 | 480p / 720p |
| seedance_2.0_fast | Seedance 2.0 极速版 | 4–15 秒 | 480p / 720p |
| seedance_2.0_standard | Seedance 2.0 标准版 | 4–15 秒 | 480p / 720p / 1080p / 4k |
| seedance_2.5 | Seedance 2.5 | 4–30 秒 | 480p / 720p / 1080p |
| seedance_2.5_v2 | Seedance 2.5 v2 | 4–15 秒 | 480p / 768p / 1080p / 2k / 4k |
具体时长上限、分辨率档位与价格以各商品 input_schema / price 为准;目录与价格会变,不要跨任务缓存。
请求参数
prompt:必填,视频提示词duration:秒数,按模型 4–15 / 4–30resolution:480p / 720p,部分模型支持 1080p 及以上ratio:1:1 / 3:4 / 4:3 / 9:16 / 16:9 / 21:9 / adaptivetask_type:text_to_video / image_to_video / first_last_frame / reference_to_video / edit_video / extend_videofirst_frame / last_frame / reference_images:公网图片 URLreturn_last_frame:额外返回尾帧
计费与失败
- 提交按「时长 × 分辨率倍率」预扣;
duration缺省或 -1 时按上限冻结 - 终态按实际时长结算,差额释放(重活贵在时长,不在请求数)
- 失败 / 取消 / 超时:全额释放,计 0
billing.estimated / amount两个口径都要读,便于对账
提交 → 轮询 → 取视频
curl -sS https://openclub.uumit.com/v1/videos/generations \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $UUMIT_API_KEY" \
-H 'Idempotency-Key: 9c2f4a71-3b8e-4f6a-8c2d-1e0f9a8b7c6d' \
-d '{"prompt":"海边日落,橘猫沿着潮线奔跑,镜头低角度跟拍","duration":4,"resolution":"480p","ratio":"16:9"}'{
"task_uuid": "4f1d7c2a90b34e55a0f2c8d1e6b7a943",
"status": "queued",
"task_type": "video",
"billing_state": "reserved",
"billing": {
"state": "reserved",
"estimated": "242.736000",
"amount": "0.000000",
"currency": "UT"
}
}{
"task_uuid": "4f1d7c2a90b34e55a0f2c8d1e6b7a943",
"status": "succeeded",
"progress": 100,
"task_type": "video",
"billing_state": "settled",
"billing": {
"state": "settled",
"estimated": "242.736000",
"amount": "242.762000",
"currency": "UT"
},
"result": {
"items": [
{
"index": 0,
"kind": "video",
"status": "ready",
"url": "https://files.example.com/generated/xxxx.mp4",
"expires_at": "2026-12-20T08:09:40+00:00"
}
]
}
}轮询节奏建议 5~10 秒;任务可能要几分钟,别用提交请求同步等。停止用 POST /v1/tasks/{task_uuid}/cancel,已终态会返回 409 task_not_cancellable。
图生视频只要首帧图
传 task_type=image_to_video 与 first_frame(公网可访问的图片 URL)即可;首尾帧用 first_last_frame + last_frame。 图片 URL 上游必须能直连,内网地址或临时签名链接会失败。
08 · 契约
统一信封与 cursor 分页#
{
"code": 0,
"message": "ok",
"data": {},
"timestamp": 1763470000
}code = 0 表示成功;非 0 一律按错误处理, 请用 code 分支判断,不要依赖 message 文案。
列表统一 cursor 分页:请求带 cursor,响应给 data.next_cursor 与 data.has_more。
4xx 是调用方问题,默认不重试;5xx 由系统承担,可退避重试;429 遵守 Retry-After。
GET https://openclub.uumit.com/api/v1/openclub/public/goods?category=compute&tags=relay-node&supply_type=RELAY_NODE&limit=12&cursor=...09 · 认证
Key 与资源范围#
Agent 与脚本调用只用一把 平台 Key(控制台里的统一开发者 Key):在 API Keys 页点「创建 API Key」,把 pat_... 放进 UUMIT_API_KEY,请求头只带 Authorization: Bearer $UUMIT_API_KEY,不需要用户 ID。新建 Key 默认允许 OpenClub 「可调用」;旧的 Key 若显示「未授权」,点一次「允许调用」即可。OpenClub 复用平台 账号与钱包,不引入第二套账号、第二本账。
第三方 Agent 平台替终端用户托管调用、且要按平台身份隔离归属时,才用平台级 Key:X-Api-Key + X-Platform-User-Id,Key 在 m.uumit.com/keys 创建,不受 resource_scope 限制。
「允许调用」等价于 resource_scope = {}(允许、不额外收紧);范围只能收窄不能放宽,关闭后调用返回 403 / 7311。
公开面(/api/v1/openclub/public/*)匿名可读; Agent 面的 401 / 402 / 403 都不会自动重试,需要人工换 Key、充值或调整预算。
10 · 排障
错误码#
| HTTP | code | 含义 | 怎么处理 |
|---|---|---|---|
| 401 | 1002 | Key 缺失 / 无效 / 过期 | 到控制台换 Key,不要重试 |
| 402 | 7305 | 余额不足 | 充值到账前不要重试 |
| 402 | 1011 | 该 Key 金额限额已用完(PAT spend_limit) | 到 API Keys 页调高限额或换一把 Key,不要重试 |
| 403 | 7303 | 超出预算或单次上限 | 调整窗口预算或单次上限后再试 |
| 403 | 7311 | Key 未被授权调用 OpenClub | 到 API Keys 页点这把 Key 的「允许调用」,不要重试 |
| 403 | 1003 | 账号权限不足 | 到控制台确认账号权限 |
| 404 | 7301 | 商品不存在 | 重新 discover,不要猜 slug |
| 404 | 7307 | 调用记录不存在 | 核对 run_id,或重新发起调用 |
| 409 | 7302 | 商品未上架 | 重新 discover,不要重试 |
| 409 | 7308 | 该调用当前不可停止 | 读已有状态,不要重复 stop |
| 422 | 1008 | 请求参数校验失败(如缺 Idempotency-Key) | 按 input_schema 修正,不要重试 |
| 429 | 1009 | 触发限流 | 按 Retry-After 退避,不要并发重试 |
| 503 | 7309 | 目录暂未开放 | 稍后再试,不要重试 |
| 5xx | 9999 | 平台或上游临时故障 | 指数退避 2~3 次;仍失败保留 X-Request-Id |
两段式接口(/v1)的错误码
两段式的错误分两类:请求级错误返回非 2xx + {"error": {"code", "message", "type", "detail"}}(字符串码); 任务级失败返回 200 + status=failed,原因在 error.code(content_rejected / generation_failed / upstream_timeout), 计 0。只有鉴权失败(401)走平台统一信封 {"code", "message", "data", "timestamp"}, 目录侧的 403(预算 / 授权范围)仍返回 error.code。
| HTTP | error.code | 含义 | 怎么处理 |
|---|---|---|---|
| 400 | task_media_mismatch | 路径与任务媒体不符(如图片路径查视频任务) | 改用 /v1/tasks/{id} 或与任务媒体一致的路径,不要重试 |
| 401 | 1002 / 1006 | Key 缺失 / 无效 / 已撤销(平台信封) | 换 Key,不要重试 |
| 402 | OPENCLUB_INSUFFICIENT_BALANCE | 余额不足 | 充值到账后再提交 |
| 403 | OPENCLUB_BUDGET_EXCEEDED | 超出预算或单次上限 | 调整预算后再提交 |
| 403 | OPENCLUB_RESOURCE_SCOPE_DENIED | Key 未被授权调用 OpenClub | 到 API Keys 页点这把 Key 的「允许调用」 |
| 404 | OPENCLUB_GOODS_NOT_FOUND | 该路径没配置在售商品 | 读 /v1/models,或改用 /run + slug |
| 404 | task_not_found | 任务不存在或不属于当前账号 | 核对 task_uuid,不要新建任务 |
| 409 | OPENCLUB_GOODS_NOT_ON_SALE | 商品未上架 | 重新选商品,不要重试 |
| 409 | task_not_cancellable | 任务已是终态 | 读任务详情,不要重复取消 |
| 409 | OPENCLUB_IDEMPOTENCY_CONFLICT | 同一个 Idempotency-Key 换了请求体 | 换 Key 或改回原请求体 |
| 422 | 上游错误码原样返回(如 content_policy_violation) | 上游内容审核 / 参数拒绝 | 改 prompt / 换图,不要原样重试 |
| 429 | rate_limited | 触发限流 | 按 Retry-After 退避 |
| 502 | upstream_unavailable | 上游抖动,任务状态未知 | 用同一个 task_uuid 重新查询,不要改参数重提 |
| 503 | OPENCLUB_DISABLED / upstream_busy | 目录未开放 / 上游繁忙 | 稍后再试,不要连续重试 |
下一步