外观
OpenAI 兼容 API
DeepFlow API 的模型调用接口使用 API 密钥进行 Bearer 鉴权。
http
Authorization: Bearer sk-your-deepflow-key统一 Base URL:
text
https://deepflow.online/v1后台管理接口使用的系统访问令牌与模型调用 API 密钥不是同一种凭据。普通用户集成模型时只需要在 API 密钥 页面创建的
sk-...密钥。
接口目录
| 方法 | 路径 | 用途 | 初稿状态 |
|---|---|---|---|
GET | /v1/models | 获取当前密钥可用模型 | 当前可用 |
POST | /v1/chat/completions | OpenAI Chat Completions | 当前可用 |
POST | /v1/responses | OpenAI Responses | 当前可用,能力依模型而定 |
POST | /v1/images/generations | 图像生成 | 当前可用 |
POST | /v1/images/edits | 图像编辑 | 待按模型逐项验证 |
完整的可导入定义见 openapi.yaml。
获取模型列表
bash
curl 'https://deepflow.online/v1/models' \
-H 'Authorization: Bearer sk-your-deepflow-key'响应示例:
json
{
"object": "list",
"data": [
{
"id": "gpt-5.6-luna",
"object": "model",
"owned_by": "openai"
}
]
}Chat Completions
非流式请求
bash
curl 'https://deepflow.online/v1/chat/completions' \
-H 'Authorization: Bearer sk-your-deepflow-key' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.6-luna",
"messages": [
{"role": "system", "content": "回答简洁、准确。"},
{"role": "user", "content": "解释什么是 API 网关。"}
],
"stream": false
}'常用参数:
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 必填,模型 ID |
messages | array | 必填,对话消息列表 |
stream | boolean | 是否使用 SSE 流式响应 |
temperature | number | 采样温度;部分推理模型可能忽略 |
max_completion_tokens | integer | 最大输出 Token;是否生效取决于模型 |
tools | array | 函数/工具定义;是否支持取决于模型 |
reasoning_effort | string | 推理强度;是否支持取决于模型 |
流式请求
bash
curl -N 'https://deepflow.online/v1/chat/completions' \
-H 'Authorization: Bearer sk-your-deepflow-key' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.6-luna",
"messages": [{"role": "user", "content": "列出三个 API 安全建议。"}],
"stream": true,
"stream_options": {"include_usage": true}
}'流式响应使用 text/event-stream,以多条 data: 事件返回,并通常以 data: [DONE] 结束。
Responses API
bash
curl 'https://deepflow.online/v1/responses' \
-H 'Authorization: Bearer sk-your-deepflow-key' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.6-sol",
"input": "用三点总结稳定 API 集成的关键。"
}'不同模型对 Responses 工具、推理参数、结构化输出和多模态输入的支持可能不同。上线前请用目标模型单独测试。
图像生成
bash
curl 'https://deepflow.online/v1/images/generations' \
-H 'Authorization: Bearer sk-your-deepflow-key' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-1.5",
"prompt": "A clean isometric illustration of an AI API gateway, white background",
"n": 1,
"size": "1024x1024"
}'常用参数:
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 图像模型 ID |
prompt | string | 必填,图像描述 |
n | integer | 生成数量;模型可能限制为 1 |
size | string | 尺寸;支持范围以目标模型为准 |
quality | string | 质量档位;仅部分模型支持 |
background | string | 背景模式;仅部分模型支持透明背景 |
moderation | string | 内容审核档位;仅部分模型支持 |
style | string | 风格参数;仅部分模型支持 |
response_format | string | url 或 b64_json,以模型能力为准 |
user | string | 业务侧最终用户标识,可选 |
返回结果可能使用临时 URL 或 b64_json。调用方应及时下载结果,不要假设临时 URL 永久有效。
图像编辑
New API 支持 OpenAI 兼容的 multipart/form-data 编辑接口,但 DeepFlow 当前需要按每个上游模型验证。
bash
curl 'https://deepflow.online/v1/images/edits' \
-H 'Authorization: Bearer sk-your-deepflow-key' \
-F 'model=gpt-image-1' \
-F 'image=@input.png' \
-F 'prompt=Replace the background with a clean studio backdrop'此示例先作为接口占位。正式发布前必须确认具体模型、文件大小、图片格式、遮罩规则和计费方式。
Python
python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DEEPFLOW_API_KEY"],
base_url="https://deepflow.online/v1",
)
response = client.chat.completions.create(
model="gpt-5.6-luna",
messages=[{"role": "user", "content": "你好,请做一句自我介绍。"}],
)
print(response.choices[0].message.content)Node.js
javascript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DEEPFLOW_API_KEY,
baseURL: "https://deepflow.online/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5.6-luna",
messages: [{ role: "user", content: "你好,请做一句自我介绍。" }],
});
console.log(response.choices[0].message.content);超时与重试
- 连接超时与总请求超时应分别配置。
- 只对网络错误、
408、429和部分5xx使用有限次数的指数退避重试。 - 不要自动重试已经明确返回参数错误的
400。 - 非幂等的图像、音频或视频生成请求重试前,应先确认是否已经产生任务或费用。
- 流式请求应设置足够的读取超时,并正确处理客户端主动中断。
