curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"山间木屋,清晨薄雾,水彩风格","n":1,"size":"1536x1024","response_format":"b64_json"}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1, "size": "1024x1024", "response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2",
prompt: "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
n: 1, size: "1024x1024", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/result.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
{"error":{"type":"invalid_request_error","message":"n must be greater than 0"}}
Image 图片
GPT Image 图片生成
GPT Image 模型、尺寸、数量、质量和返回格式,以及 cURL、Python、JavaScript 示例。
POST
https://sub.vcnovb.cn
/
v1
/
images
/
generations
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"山间木屋,清晨薄雾,水彩风格","n":1,"size":"1536x1024","response_format":"b64_json"}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1, "size": "1024x1024", "response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2",
prompt: "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
n: 1, size: "1024x1024", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/result.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
{"error":{"type":"invalid_request_error","message":"n must be greater than 0"}}
根据提示词生成图片,支持 URL 和 Base64 返回方式。API Key 需绑定具有图片权限的分组;异步调用见图片任务。
其他尺寸和清晰度档位见对应模型说明。模型名称带清晰度后缀时,使用匹配的尺寸。
结果 URL 请及时下载保存。需要参考图时使用图片编辑接口。
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"山间木屋,清晨薄雾,水彩风格","n":1,"size":"1536x1024","response_format":"b64_json"}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "gpt-image-2",
"prompt": "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
"n": 1, "size": "1024x1024", "response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2",
prompt: "白色背景上的橙色玻璃水杯,柔和侧光,产品摄影",
n: 1, size: "1024x1024", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/result.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
{"error":{"type":"invalid_request_error","message":"n must be greater than 0"}}
模型选择
| 模型 | 说明 |
|---|---|
gpt-image-2 | 本页示例使用的模型 |
gpt-image-1、gpt-image-1.5 | 选择包含对应型号的分组,参数按模型说明填写 |
gpt-image-2.5、gpt-image-2.6 及其可用型号 | 通过模型列表获取完整模型 ID |
请求参数
尺寸与参考图
| 场景 | 示例尺寸 |
|---|---|
| 方图 | 1024x1024 |
| 横图 | 1536x1024 |
| 竖图 | 1024x1536 |
返回结果
| 字段 | 说明 |
|---|---|
created | 生成时间,Unix 时间戳 |
data[].url | 图片下载地址 |
data[].b64_json | Base64 图片数据,解码后保存为文件 |