外观
生成图像
POST
https://vip.zen-ai.top/v1/images/generationsOpenAI Images 兼容接口,根据文字描述生成图片。支持 GPT Image 系列、DALL·E 3、FLUX 等模型,不同模型支持的参数略有差异(见下表备注)。在线调试时生成的图片会直接预览。
当前可用的图像模型(点击复制):
计费方式
GPT Image 系列按 token 计费(文本输入 + 图片输出),DALL·E 3、FLUX 等按次计费,价格见 模型列表。Gemini 图片模型请使用 Gemini 原生图片生成。
请求体
modelstring必填模型名称,如 gpt-image-1.5、gpt-image-2、dall-e-3、FLUX-1.1-pro。
promptstring必填图片描述,越具体效果越好。
ninteger默认 1生成数量。DALL·E 3 只支持 1。
sizestring图片尺寸:
- GPT Image:
1024x1024、1536x1024(横)、1024x1536(竖)或auto - DALL·E 3:
1024x1024、1792x1024、1024x1792
qualitystring画质。GPT Image:low / medium / high / auto;DALL·E 3:standard / hd。画质越高越慢、费用越高。
response_formatstring返回图片链接还是 base64。GPT Image 系列始终返回 b64_json。
可选值
urlb64_jsonbackgroundstring背景,transparent 需搭配 png 或 webp 格式(GPT Image)。
可选值
autotransparentopaqueoutput_formatstring输出格式(GPT Image)。
可选值
pngjpegwebpoutput_compressionintegerjpeg / webp 的压缩质量 0–100(GPT Image)。
moderationstring内容审核严格程度(GPT Image)。
可选值
autolowstylestring风格,仅 DALL·E 3 支持。
可选值
vividnaturaluserstring终端用户标识。
响应
createdinteger创建时间戳。
dataarray生成的图片列表。
子字段 3
b64_jsonstringbase64 编码的图片数据。
urlstring图片链接(response_format 为 url 时),通常有有效期,请及时保存。
revised_promptstring模型改写后的提示词(DALL·E 3)。
usageobjecttoken 用量(GPT Image 系列)。
请求示例
bash
curl https://vip.zen-ai.top/v1/images/generations \
-H "Authorization: Bearer $VIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1.5",
"prompt": "一只戴着宇航员头盔的柴犬漂浮在太空中,插画风格",
"size": "1024x1024",
"quality": "medium"
}' | jq -r '.data[0].b64_json' | base64 --decode > dog.pngpython
import base64
from openai import OpenAI
client = OpenAI(base_url="https://vip.zen-ai.top/v1", api_key="sk-xxxxxxxx")
resp = client.images.generate(
model="gpt-image-1.5",
prompt="一只戴着宇航员头盔的柴犬漂浮在太空中,插画风格",
size="1024x1024",
quality="medium",
)
with open("dog.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))js
import OpenAI from "openai";
import { writeFile } from "node:fs/promises";
const client = new OpenAI({ baseURL: "https://vip.zen-ai.top/v1", apiKey: process.env.VIP_API_KEY });
const resp = await client.images.generate({
model: "gpt-image-1.5",
prompt: "一只戴着宇航员头盔的柴犬漂浮在太空中,插画风格",
size: "1024x1024",
quality: "medium",
});
await writeFile("dog.png", Buffer.from(resp.data[0].b64_json, "base64"));响应示例
json
{
"created": 1790684800,
"data": [
{ "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zU..." }
],
"usage": {
"input_tokens": 36,
"input_tokens_details": { "text_tokens": 36, "image_tokens": 0 },
"output_tokens": 1056,
"total_tokens": 1092
}
}