«

newapi openai对接标准文档

时间:2026-11-25 15:33     作者:wanzi     分类: newapi


接口列表

接口名称 方法 路径 说明
模型列表 GET /v1/models 返回 OpenAI 兼容模型列表
聊天补全 POST /v1/chat/completions OpenAI 兼容聊天补全接口,支持图片解析
Responses POST /v1/responses 兼容 Responses 输入结构,支持文本与工具调用
Messages POST /v1/messages Anthropic Messages 兼容入口
联网搜索 POST /v1/search 本地搜索兼容入口,返回 answer 与 sources
图片生成 POST /v1/images/generations 图片生成接口
图片编辑 POST /v1/images/edits 图片编辑接口,支持 multipart 上传参考图
创建可编辑文件任务 POST /v1/editable-file-tasks 统一创建 PPT/PSD 文件任务
查询可编辑文件任务 GET /v1/editable-file-tasks 按任务 ID 查询 PPT/PSD 文件生成状态
PPT 生成任务 POST /v1/ppt/generations 直接创建 PPT 生成任务
PSD 生成任务 POST /v1/psd/generations 直接创建 PSD 生成任务
文件下载 GET /files/{file_path} 公开下载生成的文件或压缩包,无需鉴权

详细接口说明

1. 模型列表

请求

curl https://wanzij.cc.cd/v1/models \
  -H "Authorization: Bearer YANGboom@201233"

说明: 返回 OpenAI 兼容模型列表。


2. 聊天补全

请求

curl https://wanzij.cc.cd/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"model":"gpt-5-mini","messages":[{"role":"user","content":"你好"}]}'

说明: OpenAI 兼容聊天补全接口,图片兼容场景也会解析 n 等参数。


3. Responses

请求

curl https://wanzij.cc.cd/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"model":"gpt-5-mini","input":"生成一张未来城市图片"}'

说明: 兼容 Responses 输入结构,支持文本与工具调用场景。


4. Messages

请求

curl https://wanzij.cc.cd/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"model":"gpt-5-mini","max_tokens":1024,"messages":[{"role":"user","content":"你好"}]}'

说明: Anthropic Messages 兼容入口,支持 Authorization Bearer 或 x-api-key 鉴权。


5. 联网搜索

请求

curl https://wanzij.cc.cd/v1/search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"prompt":"今天的 OpenAI 新闻"}'

说明: 本地搜索兼容入口,返回 answer 与 sources。


6. 图片生成

请求

curl https://wanzij.cc.cd/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"model":"gpt-image-2","prompt":"一张极简产品海报","n":1}'

说明: 图片生成接口,支持 prompt、model、n、size、quality 等参数。


GPT Image 2.5 可以直接通过 size 参数指定 2K、4K 分辨率,不需要额外传入 2k 或 4k 这样的枚举值。

1. 分辨率参数

分辨率 size 参数 像素
2K 正方形 2048x2048 4.19MP
2K 横屏 2048x1152 2.36MP
2K 竖屏 1152x2048 2.36MP
4K 横屏 3840x2160 8.29MP
4K 竖屏 2160x3840 8.29MP

2. API 请求示例

{
  "model": "gpt-image-2.5-sunburst",
  "prompt": "A beautiful futuristic city",
  "size": "2048x2048",
  "quality": "high"
}

改成 4K:

{
  "model": "gpt-image-2.5-sunburst",
  "prompt": "A beautiful futuristic city",
  "size": "3840x2160",
  "quality": "high"
}

3. 自定义尺寸限制

官方文档目前给出的约束:

特别注意:4K 可以请求,但不代表所有 4K 尺寸都属于稳定支持范围。

4. quality 和 size 的区别

参数 作用
size 决定输出图片分辨率
quality 决定渲染质量
auto 让模型自动选择

GPT Image 2.5 还支持 xhigh、max 质量档位。

{
  "model": "gpt-image-2.5-sunburst",
  "prompt": "A beautiful futuristic city",
  "size": "2048x2048",
  "quality": "high"
}

7. 图片编辑

请求

curl https://wanzij.cc.cd/v1/images/edits \
  -H "Authorization: Bearer YANGboom@201233" \
  -F "model=gpt-image-2" \
  -F "prompt=改成赛博朋克夜景" \
  -F "image=@./input.png"

说明: 图片编辑接口,支持 multipart 上传参考图。


8. 创建可编辑文件任务

请求

curl https://wanzij.cc.cd/v1/editable-file-tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"kind":"ppt","prompt":"做一份产品发布会 PPT"}'

说明: 统一创建 PPT/PSD 文件任务,kind 可填 ppt 或 psd。


9. 查询可编辑文件任务

请求

curl "https://wanzij.cc.cd/v1/editable-file-tasks?ids=task_1,task_2" \
  -H "Authorization: Bearer YANGboom@201233"

说明: 按任务 ID 查询 PPT/PSD 文件生成状态。


10. PPT 生成任务

请求

curl https://wanzij.cc.cd/v1/ppt/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"prompt":"生成一份市场分析 PPT"}'

说明: 直接创建 PPT 生成任务,返回任务 ID 后再查询状态。


11. PSD 生成任务

请求

curl https://wanzij.cc.cd/v1/psd/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YANGboom@201233" \
  -d '{"prompt":"生成一张电商海报 PSD"}'

说明: 直接创建 PSD 生成任务,返回任务 ID 后再查询状态。


12. 文件下载

请求

curl https://wanzij.cc.cd/files/{file_path}

说明: 公开下载 PPT/PSD 任务生成的文件或压缩包,无需鉴权。