API 文档 v1
Base URL: https://obpai.com · 同步天梯图渲染
给 AI 的口令
把下面口令贴给 Cursor / ChatGPT / Claude,即可按规范集成天梯图 API(含官方模板定位流程)。
给 AI 的一句话口令
复制后贴给 Cursor / Codex / Workbuddy;也可让 AI 直接读 Skill 地址
你正在帮用户集成【OBPAI 天梯图 Render API】。请严格按下列规范实现,不要臆造端点。
## 文档与入口
- Skill(优先让 AI 读这份): https://obpai.com/skill/SKILL.md
- 开发者平台: https://obpai.com/developers
- API 文档: https://obpai.com/developers/docs
- OpenAPI: https://obpai.com/openapi/v1.yaml
- 创建 API Key(需登录): https://obpai.com/developers/dashboard
- Base URL: https://obpai.com
## 鉴权
所有 /api/v1/* 写/读模板接口需要 API Key:
- Header: Authorization: Bearer sk_live_xxx
- 或: X-API-Key: sk_live_xxx
API Key 只负责鉴权与配额,不绑定某一张模板。
## 两种成图方式
### A. 官方模板(推荐,用站点 900+ 预设)
1) 搜索模板拿 templateId:
GET /api/v1/templates?q=关键词&locale=zh&limit=10
2) 拉详情拿条目索引:
GET /api/v1/templates/{templateId}?locale=zh
响应含 tracks(档位名)与 itemIndexMap(item_0, item_1…)
也可从页面 URL 抄 ID:https://obpai.com/tier/{templateId}
3) 成图:
POST /api/v1/render
{
"mode": "template",
"templateId": 1787597633240,
"title": "标题",
"tiers": [
{ "title": "夯", "items": ["item_0", "item_2"] },
{ "title": "顶级", "items": ["item_1"] },
{ "title": "人上人", "items": ["item_3"] },
{ "title": "NPC", "items": [] },
{ "title": "拉完了", "items": ["item_4"] }
],
"aspectRatio": "3:4",
"theme": "night",
"watermark": false
}
4) 成功响应取 imageUrl(WebP/PNG 绝对地址)展示或下载。
### B. 自定义条目(不用官方模板)
POST /api/v1/render
{
"mode": "custom",
"title": "我的技术栈",
"items": [
{ "type": "text", "label": "React" },
{ "type": "text", "label": "Vue" },
{ "type": "url", "url": "https://example.com/logo.png" }
],
"tracks": [
{ "title": "S", "color": "#ff7f7f" },
{ "title": "A", "color": "#ffbf7f" },
{ "title": "B", "color": "#ffdf7f" }
],
"tiers": [
{ "title": "S", "items": [0] },
{ "title": "A", "items": [1, 2] }
],
"theme": "night",
"watermark": false
}
## 关键约束
- theme 只管样子:night 夜黑 / paper 白纸 / arcade 街机,默认 night。不要拿它当榜单内容。
- 单次最多 80 条目;外链图 ≤2MB
- 默认配额约 500 次/天、30 次/分钟
- 超时建议 60s;相同请求可能命中缓存(cached:true)
- 错误格式: { "success": false, "message": "..." }
- Key 只放服务端,勿写进前端公开代码
## 你的任务
根据用户需求:先确认用 template 还是 custom;若用模板,先搜索/确认 templateId 与 itemIndexMap,再调用 render;最后返回 imageUrl 与可运行的 curl/代码。定位某个模板(最重要)
API Key 只负责鉴权,不绑定模板。选哪张模板靠 templateId。
GET /api/v1/templates?q=关键词&locale=zh→ 列表里的idGET /api/v1/templates/{id}→itemIndexMap(item_0, item_1…)与档位名 tracksPOST /api/v1/render·mode: "template"+ templateId + tiers
或从官网 URL 抄:https://obpai.com/tier/1787597633240 → templateId = 1787597633240
# 1) 搜索
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://obpai.com/api/v1/templates?q=手机处理器&locale=zh&limit=5"
# 2) 详情(看 itemIndexMap)
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://obpai.com/api/v1/templates/1787597633240?locale=zh"
# 3) 成图
curl -X POST https://obpai.com/api/v1/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "template",
"templateId": 1787597633240,
"title": "我的手机处理器榜",
"tiers": [
{ "title": "夯", "items": ["item_0", "item_2"] },
{ "title": "顶级", "items": ["item_1"] },
{ "title": "人上人", "items": ["item_3"] },
{ "title": "NPC", "items": [] },
{ "title": "拉完了", "items": ["item_4"] }
],
"watermark": false
}'快速开始(自定义模式)
- 获取 API Key:登录 控制台 创建
- 发送
POST /api/v1/render - 响应中的 imageUrl 即为成图地址
curl -X POST https://obpai.com/api/v1/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "custom",
"title": "Demo",
"items": [
{ "type": "text", "label": "React" },
{ "type": "text", "label": "Vue" }
],
"tiers": [
{ "title": "S", "items": [0] },
{ "title": "A", "items": [1] }
],
"watermark": false
}'鉴权
| Header | 值 |
|---|---|
| Authorization | Bearer sk_live_xxx |
| X-API-Key | sk_live_xxx |
POST /api/v1/render
核心接口:提交排位 JSON,同步返回 imageUrl。
请求字段
| 字段 | 说明 |
|---|---|
| mode | template / custom / inline,可自动推断 |
| templateId | template 模式:官方模板 ID |
| title | 天梯图标题 |
| aspectRatio | 3:4 | 9:16 | 1:1 | 16:9 |
| theme | night 夜黑 / paper 白纸 / arcade 街机;只管样子,不管名单 |
| watermark | 默认 true;false 无水印 |
| items | custom 模式:候选条目池 |
| tracks | 档位定义 { title, color? } |
| tiers | 各档 { title, items: [索引或 item_N] } |
成功响应
{
"success": true,
"renderId": "rnd_a1b2c3",
"imageUrl": "https://obpai.com/uploads/exports/rnd_a1b2c3.webp",
"width": 960,
"height": 1280,
"aspectRatio": "3:4",
"cached": false,
"expiresAt": "2026-09-27T00:00:00.000Z"
}更多示例
官方模板 mode
{
"mode": "template",
"templateId": 1787597633240,
"title": "2026 旗舰 SoC 榜",
"tiers": [
{ "title": "夯", "items": ["item_0", "item_2"] },
{ "title": "顶级", "items": ["item_1"] },
{ "title": "人上人", "items": ["item_3"] },
{ "title": "NPC", "items": [] },
{ "title": "拉完了", "items": ["item_4"] }
],
"watermark": false
}自定义 mode
{
"mode": "custom",
"title": "编程语言",
"items": [
{ "type": "text", "label": "Rust" },
{ "type": "text", "label": "Go" },
{ "type": "url", "url": "https://example.com/logo.png" }
],
"tracks": [
{ "title": "S", "color": "#ff7f7f" },
{ "title": "A", "color": "#ffbf7f" }
],
"tiers": [
{ "title": "S", "items": [0] },
{ "title": "A", "items": [1, 2] }
]
}Node.js
const res = await fetch('https://obpai.com/api/v1/render', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OBPAI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode: 'custom',
title: 'Demo',
items: [{ type: 'text', label: 'Hello' }],
tiers: [{ title: 'S', items: [0] }],
watermark: false,
}),
});
const { imageUrl } = await res.json();模板 API
GET /api/v1/templates— 列表(q / categoryId / locale / page)GET /api/v1/templates/{id}— 详情,额外返回 itemIndexMap
限制与错误码
- 单次最多 80 个条目
- 外链图片最大 2MB
- 默认 500 次/天、30 次/分钟
- 相同 spec 24h 内返回缓存
| HTTP | 含义 |
|---|---|
| 400 | 参数错误 |
| 401 | 无效 API Key |
| 404 | 模板不存在 |
| 429 | 超出配额 |