Developer Platform

OBPAI 天梯图 API

一次 HTTP 请求,使用官方模板或自定义条目,即刻生成高清天梯图 PNG/WebP。 适合博客、社区 Bot、数据可视化站点与 AI Agent 集成。

给 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/代码。

丢给 Cursor / Codex / Workbuddy

不用自己学接口。把下面地址交给 AI,再说「做一张某某天梯图」,并附上你的 API Key。

https://obpai.com/skill

官方模板

搜索拿 templateId,用 item_0 排位成图

自定义条目

文字磁贴或外链图片,自由分档

同步出图

POST /api/v1/render 直接返回 imageUrl

用官方模板的 3 步

  1. GET /api/v1/templates?q=关键词 → 拿到 templateId
  2. GET /api/v1/templates/{id} → 看 itemIndexMap
  3. POST /api/v1/render · mode=template → 拿 imageUrl

也可从页面 URL 抄 ID:https://obpai.com/tier/1787597633240 → templateId=1787597633240

模板模式示例

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
  }'