图片
gpt-image-2 API
通过 Modelflare 使用 gpt-image-2,使用本页显示的精确模型 ID。
使用精确模型 ID gpt-image-2。请求中的模型名必须与本页完全一致。

请求参数:size=1536x1024n=1
提示词:A 24-hour laundromat at three in the morning, a whole wall of front-loaders turning. A young man in a silver metallic bomber jacket has just tipped a jar of coloured glass marbles into the nearest drum. The marbles are pouring upward out of the open door instead of sinking, already arcing across the room in a bright teal and amber bridge that rings against the ceiling lights. Cold cyan tubes overhead, a hard warm amber glow thrown out of the drum itself. Straight-on symmetrical camera, wide, hyper-real detail in the glass, film grain, no text.
{ "model": "gpt-image-2", "prompt": "A 24-hour laundromat at three in the morning, a whole wall of front-loaders turning. A young man in a silver metallic bomber jacket has just tipped a jar of coloured glass marbles into the nearest drum. The marbles are pouring upward out of the open door instead of sinking, already arcing across the room in a bright teal and amber bridge that rings against the ceiling lights. Cold cyan tubes overhead, a hard warm amber glow thrown out of the drum itself. Straight-on symmetrical camera, wide, hyper-real detail in the glass, film grain, no text.", "n": 1, "size": "1536x1024"}使用 Modelflare API Key,通过 https://modelflare.dev/v1 发送请求。网关入口为 POST /v1/images/generations。
Authorization: Bearer YOUR_MODELFLARE_API_KEYcurl https://modelflare.dev/v1/images/generations \ -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2", "prompt": "一只白猫在雨夜霓虹街道上奔跑", "size": "1024x1024", "n": 1 }'OpenAI 兼容图片模型使用 prompt、n、size、quality 等字段;编辑仅在官方页面明确支持时使用。
GPT Image 使用 OpenAI 兼容 Images API。生成使用 JSON,编辑和蒙版编辑使用 multipart;GPT Image 2 的响应在 data[].b64_json 返回 Base64 图片。
| 字段 | 必填 | 说明 |
|---|---|---|
model |
是 | gpt-image-2 |
prompt |
是 | 生图或编辑指令 |
size |
否 | auto 或自定义 WIDTHxHEIGHT,需遵守尺寸规则 |
quality |
否 | low / medium / high / auto;默认 auto |
background |
否 | auto / opaque / transparent;透明背景必须搭配 PNG 或 WebP 输出 |
output_format |
否 | png / jpeg / webp |
output_compression |
否 | JPEG/WebP 取 0–100,默认 100;PNG 忽略此参数 |
moderation |
否 | auto / low;默认 auto |
n |
否 | 1–10 张,默认 1 |
响应与输入限制
Section titled “响应与输入限制”自定义尺寸的宽和高必须是 16 的倍数,宽高比在 1:3 到 3:1 之间,单边不超过 3,840 像素,总像素数在 655,360 到 8,294,400 之间。编辑最多接收 16 张源图,每张和蒙版都应小于 50 MB;不要传入 DALL·E 专用的 response_format。
GPT Image 2 的编辑使用 /v1/images/edits 和 multipart image/image[];最多 16 张输入图,mask 必须与首张图尺寸和格式一致。
curl https://modelflare.dev/v1/images/edits \ -H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \ -F "model=gpt-image-2" \ -F "image[]=@/path/to/product.png" \ -F "mask=@/path/to/mask.png" \ -F "prompt=保持主体不变,将背景替换为暖色摄影棚渐变" \ -F "size=1536x1024" \ -F "quality=high" \ -F "output_format=png" \ -F "n=1"错误与失败任务
Section titled “错误与失败任务”参数不符合模型契约时,接口会返回带 request ID 的 4xx;响应字段和错误消息以当前模型接口为准。
本页只覆盖 Modelflare 的模型生成/编辑调用。搜索或地图增强、声音管理、元素库管理等资源型接口不属于本页的公开调用范围,也不需要作为模型请求字段传入。
本模型按 Token 计费。请查看模型价格页查看当前销售价、参考原价和完整规格。
媒体契约 · v1
官方来源: OpenAI
契约参数
| Intent 字段 | 控件 | 选项 |
|---|---|---|
size | select | auto / 1024x1024 / 1536x1024 / 1024x1536 |
quality | select | auto / low / medium / high |
n | number | — |
支持能力
allowed_values·size· auto, 1024x1024, 1536x1024, 1024x1536allowed_values·quality· auto, low, medium, highmax_assets·reference_asset_ids· 16
结构化请求示例
text
Intent
{
"n": 1,
"prompt": "A red paper kite over a quiet harbour at dusk.",
"quality": "auto",
"size": "auto"
}上游请求
{
"model": "gpt-image-2",
"n": 1,
"prompt": "A red paper kite over a quiet harbour at dusk.",
"quality": "auto",
"size": "auto"
}reference
Intent
{
"n": 1,
"prompt": "A red paper kite over a quiet harbour at dusk.",
"quality": "auto",
"size": "auto"
}上游请求
{
"images": [
"https://example.com/reference.png"
],
"model": "gpt-image-2",
"n": 1,
"prompt": "A red paper kite over a quiet harbour at dusk.",
"quality": "auto",
"size": "auto"
}