用户工具

站点工具


public:api

AI 服务公开接口

网站 AI 服务可调用的接口一览(供开发者接入与 AI 检索)。所有接口经 nginx 反代,同域调用自动携带登录 Cookie。


AI 对话

  • `GET /ai/chat/models` — 模型列表 `{models:[{id,name}], default}`
  • `GET /ai/chat/health` — 上游健康 `{ok, default, upstreams[]}`
  • `GET /ai/chat/members` — 社员公开列表 `{members:[{user,display,group,title,avatar,homepage}]}`
  • `POST /ai/chat/` — AI 对话(SSE 流式)。请求 `{model?, messages:[{role,content}], max_tokens?}`;服务端自动校验身份(Cookie)、注入检索;返回 OpenAI 格式 SSE(含 `tool_status` 事件、`X-Used-Model` 头)。限制:单条 ≤6000 字、总 ≤20000 字、24 条、每 IP 8 次/分钟

多模态转文字

  • `POST /ai/media2text/` — multipart `file=<文件>`,自动识别类型:
    • 图片 jpg/png/gif/webp/bmp(≤10MB)→ OCR
    • 音频(≤10MB)/ 视频(抽音轨)→ STT
    • 文档 txt/doc/docx/pdf/ppt/pptx(≤7MB)→ 文本提取
  • 返回 `{ok, kind: image|audio|video|doc, text, ms}`;识别文本截断 4000 字

万念造物(需登录·本人)

  • `POST /ai/create/api/create` — `{title, html}` 创建 → `{ok, slug, url, url_private}`
  • `GET /ai/create/api/list` — 我的页面列表 `{pages:[{slug,title,status,published,url,url_private,created,size}]}`
  • `POST /ai/create/api/read` — `{slug}` 读取代码 `{ok, html, title, status}`
  • `POST /ai/create/api/update` — `{slug, html}` 更新(重新消毒,保留发布状态)
  • `POST /ai/create/api/publish` — `{slug, publish:bool}` 发布/转私有
  • `POST /ai/create/api/delete` — `{slug}` 删除
  • `GET /ai/create/view?user=&slug=` — 私有页浏览(本人鉴权,返回带 CSP 的 HTML)

语音与识别

  • `POST /ai/tts/` — TTS 合成(edge-tts,词级时间戳)
  • `POST /ai/ocr/` — 图片 OCR(multipart file)
  • `POST /ai/stt/` — 语音转文字(原始音频字节,≤90 秒)
  • `GET /ai/segment/?text=` — jieba 分词

博客互动

  • `GET /blog/api/likes?post=` / `GET /blog/api/comments?post=` — 公开读取
  • `POST /blog/api/like` / `POST /blog/api/comments` — 需登录(限流;评论 ≤500 字;敏感词过滤)

统一认证

  • `POST /zhangben/auth/api.php?action=me` — 校验登录 `{logged_in, user, display, avatar}`(详见 SSO 指南
⚠️ 以上接口均不含密钥/敏感参数;权限判断在服务端完成。

返回知识库首页

public/api.txt · 最后更改: 2026/08/12 08:34 由 127.0.0.1