🎨 ChatGPT 最新生图 gpt-image-2-all 已上线 | Now Live:$0.03/张图,对话式端点提示词遵循最佳!详情 Details
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"prompt": "黄昏时的海边老灯塔,电影画幅,写实风格"
}
'{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/00aaa9fb-756c-4119-a4a0-4a44fc75152b.png",
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}gpt-image-2-vip 文生图 API 参考与在线调试 — 输入文本描述 + size 锁定输出尺寸生成图片,$0.03/张统一价
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"prompt": "黄昏时的海边老灯塔,电影画幅,写实风格"
}
'{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/00aaa9fb-756c-4119-a4a0-4a44fc75152b.png",
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}Documentation Index
Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
Use this file to discover all available pages before exploring further.
Bearer sk-xxx),输入 prompt 与 size 后一键发送即可。size 即可,无需上传任何图片。如需根据现有图片做编辑或融合,请使用 图片编辑接口。与 gpt-image-2-all 的区别:调用结构完全一致,只多一个 size 字段;不需要锁尺寸、追求出图速度时改用 gpt-image-2-all 即可。response_format: "url" 模式下 Playground 工作正常(响应只是一个 R2 链接)。如果你切换成 response_format: "b64_json",响应会包含数 MB 的 base64 字符串,浏览器 Playground 可能弹出 请求时发生错误: unable to complete request ——实际请求已经成功,只是浏览器无法显示这么长的 base64。推荐做法:url 模式,Playground 会直接返回链接。size:必须从 30 档常见尺寸里选(10 比例 × 1K Fast / 2K Recommended / 4K Detail,详见 概览页 size 完整表)。写法用半角小写 x,例如 2048x1360、3840x2160,不要用 × 或大写 X。quality:❌ 不接受,不要传。n:❌ 不接受,单次仅返回 1 张图。传 n=3 会按 0.09 $ 扣费但只返回 1 张,请把 n 字段从请求里去掉。aspect_ratio:❌ 不接受。比例直接由 size 决定。import requests
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "gpt-image-2-vip",
"prompt": "黄昏时的海边老灯塔,电影画幅,写实风格",
"size": "2048x1152", # 16:9 2K Recommended
"response_format": "url"
},
timeout=300 # 保守值,吸收长尾 + 图片下载耗时
).json()
image_url = response["data"][0]["url"]
print(image_url)
import requests
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={"Authorization": "Bearer sk-your-api-key"},
json={
"model": "gpt-image-2-vip",
"prompt": "桌面壁纸,赛博朋克城市夜景,霓虹招牌,雨后倒影",
"size": "3840x2160", # 16:9 4K Detail
"response_format": "b64_json"
},
timeout=300
).json()
# b64_json 已含 "data:image/png;base64," 前缀,可直接用于 <img src> 或写文件
data_url = response["data"][0]["b64_json"]
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-vip",
"prompt": "白色陶瓷马克杯放在灰色桌面上的产品图,柔和自然光",
"size": "2048x1360",
"response_format": "url"
}'
const API_KEY = "sk-your-api-key";
const response = await fetch(
"https://api.apiyi.com/v1/images/generations",
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gpt-image-2-vip",
prompt: "1:1 方形 LOGO,极简猫咪线条",
size: "2048x2048", // 1:1 2K Recommended
response_format: "b64_json"
})
}
);
const data = await response.json();
// b64_json 已含前缀,可直接用作 <img src>
document.getElementById("result").src = data.data[0].b64_json;
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="gpt-image-2-vip",
prompt="水墨山水,国画风格,纵向构图",
size="1536x2048", # 3:4 2K Portrait
)
print(resp.data[0].url)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定填 gpt-image-2-vip |
prompt | string | 是 | 提示词,描述画面内容、风格、光线等 |
size | string | 强烈建议 | 输出尺寸,从 30 档里选;写法 宽x高(半角小写 x);省略时由模型回退到默认档 |
response_format | string | 否 | url(默认,返回 R2 CDN 链接)或 b64_json |
2048x1360 (3:2 2K) / 2048x2048 (1:1 2K)1536x2048 (3:4 2K) / 2480x3312 (3:4 4K)2048x1152 (16:9 2K) / 3840x2160 (16:9 4K)1152x2048 (9:16 2K) / 2160x3840 (9:16 4K)url 模式(默认,R2 CDN 全球加速):
{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/00aaa9fb-756c-4119-a4a0-4a44fc75152b.png"
}
]
}
b64_json 模式(需显式 "response_format": "b64_json"):
{
"data": [
{
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
b64_json 字段本身已经包含 data:image/png;base64, 前缀,可直接赋给 HTML <img src> 或写入文件;无需再手动拼接 data:image/...;base64,。与部分旧版 OpenAI 兼容模型不同,请留意。/v1/images/edits 多图融合与改图在 API易控制台获取的 API Key
模型名称,固定为 gpt-image-2-vip
gpt-image-2-vip 提示词,描述画面内容、风格、光线等
"黄昏时的海边老灯塔,电影画幅,写实风格"
输出尺寸,从 30 档常见尺寸里选(10 比例 × 1K Fast / 2K Recommended / 4K Detail)。
写法:宽x高(半角小写 x),如 2048x1360、3840x2160。所有档位统一价 $0.03/张。
1280x1280, 848x1280, 1280x848, 960x1280, 1280x960, 1024x1280, 1280x1024, 720x1280, 1280x720, 1280x544, 2048x2048, 1360x2048, 2048x1360, 1536x2048, 2048x1536, 1632x2048, 2048x1632, 1152x2048, 2048x1152, 2048x864, 2880x2880, 2336x3520, 3520x2336, 2480x3312, 3312x2480, 2560x3216, 3216x2560, 2160x3840, 3840x2160, 3840x1632 "2048x1152"
响应格式。url 返回 R2 CDN 链接(默认);b64_json 返回已含 data URL 前缀的 base64 字符串
url, b64_json 成功生成图片
生成结果数组(本模型单次返回 1 张)
Show child attributes