NewAPI 接口文档

统一兼容 OpenAI 格式中转接口文档|BaseURL: https://your‑domain.com/v1
鉴权说明:请求 Header 带上 Authorization: Bearer 你的key
所有接口尽量兼容 OpenAI 请求体格式,可直接接入 OpenAI 客户端、各类AI画布、Agent工具。

基础信息

项目 内容
Base URL https://your‑domain.com/v1
鉴权方式 Header Authorization: Bearer {api‑key}
Content‑Type application/json

1. 获取模型列表 GET /v1/models

curl 请求示例

curl https://your‑domain.com/v1/models \
  -H "Authorization: Bearer sk‑xxxxxx"

2. 对话接口 POST /v1/chat/completions

支持流式 stream:true 与非流式返回,兼容 gpt‑style 请求体,支持文本、图片多模态。

请求体示例

{
  "model": "model‑id‑here",
  "messages": [
    {"role":"user","content":"你好"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "stream": false
}

curl完整示例

curl https://your‑domain.com/v1/chat/completions \
  -H "Authorization: Bearer sk‑xxxxxx" \
  -H "Content‑Type: application/json" \
  -d '{
    "model":"model‑id‑here",
    "messages":[{"role":"user","content":"hello"}],
    "stream":false
  }'

请求参数说明

参数 类型 必填 说明
model string 调用模型标识
messages array 对话消息数组 role:system/user/assistant
temperature float 随机性 0‑1
max_tokens int 最大输出token
stream boolean true开启sse流式

3. 错误码说明

HTTP状态码 含义
401 API Key错误、未携带鉴权头
429 限流、额度耗尽
400 请求参数格式错误
500 上游模型服务异常

4. 视频/图像生成扩展(可选)

如果你做视频中转,可以在这里补充对应端点 /v1/images/generations /v1/video/generations
POST /v1/images/generations
{
  "model":"xxx",
  "prompt":"prompt描述",
  "n":1
}

使用提示