GPT-5.5 与 GPT Image 2 图片生成 API
Posted April 25, 2026 by XAI 技术团队 ‐ 18 min read

GPT-5.5 不只适合处理文字、代码和复杂工具调用,也可以作为多模态工作流里的“调度模型”:由 gpt-5.5 理解用户意图,再通过 image_generation 工具调用图像模型生成图片。
在 XAI Router 上,这个调用有两条 OpenAI 风格的入口:
- Responses API:让
gpt-5.5作为主模型,通过image_generation工具调用gpt-image-2。 - Images API:直接使用 OpenAI 官方兼容的
/v1/images/generations和/v1/images/edits请求gpt-image-2。
核心组合是:
- 主模型:
gpt-5.5 - 工具:
image_generation - 图像模型:
gpt-image-2 - Images API:
/v1/images/generations、/v1/images/edits - Base URL:
https://api.xairouter.com - Key 环境变量:
XAI_API_KEY
注意模型 ID 是 gpt-image-2,不是 gpt-img-2。
本文参考 OpenAI 官方图片生成工具和 Images API 示例,再把请求地址、鉴权环境变量和模型选择改成 XAI Router 版本。你可以把它理解成三层关系:
| 层级 | OpenAI 官方写法 | XAI Router 写法 |
|---|---|---|
| API Base URL | https://api.openai.com/v1 | https://api.xairouter.com/v1 |
| API Key | OPENAI_API_KEY | XAI_API_KEY |
| 主模型 | gpt-5.5 | gpt-5.5 |
| 图像工具 | image_generation | image_generation |
| 图像模型 | GPT Image 模型,例如 gpt-image-2 | gpt-image-2 |
OpenAI 官方文档里的关键点是:image_generation 是 Responses API 的内置工具;工具调用结果会包含 base64 图片;gpt-5.5 支持这个工具;真正执行图像生成的是 GPT Image 模型,例如 gpt-image-2。如果你已经使用 OpenAI 官方 Images API,也可以直接把 baseURL 切到 XAI Router,继续调用 /v1/images/generations 或 /v1/images/edits。
XAI Router 实测通过能力
以下结果基于 2026 年 4 月 25 日至 2026 年 5 月 1 日对 https://api.xairouter.com 的实测。接口能力会继续演进,生产系统仍建议保留超时、重试和失败记录。
| 能力 | 实测结果 | 建议 |
|---|---|---|
/v1/models 查询 gpt-5.5、gpt-image-2 | 成功,均在模型列表中 | 可用于启动前探测 |
/v1/responses 文本调用 gpt-5.5 | 成功,status=completed | 可作为基础连通性检查 |
/v1/responses + image_generation + gpt-image-2 + stream:true | 成功,返回 response.completed 和图片 base64 | 推荐路径 |
tool_choice: { type: "image_generation" } | 成功,能强制走图像工具 | 适合固定“生成图片”按钮 |
partial_images | 成功,但请求 2 张 partial 时实际可能只返回 1 张 | UI 不要假设 partial 数量固定 |
quality:"high" + output_format:"png" | 成功 | 可用于成稿质量控制 |
/v1/responses 非流式图片生成 | 本次成功返回完整图片 | 可用,但仍建议优先用 stream |
/v1/images/generations + gpt-image-2 | 成功,返回 OpenAI Images API 风格 JSON,包含 data[0].b64_json | OpenAI SDK 兼容接入首选 |
/v1/images/edits + gpt-image-2 | 成功,支持图片输入后编辑或参考图生成 | 用于改图、角色延续和参考图工作流 |
3840x2160 / 2160x3840 4K 输出 | 成功,解码后的 JPEG 文件尺寸分别确认为 3840x2160 和 2160x3840 | 可用,但延迟和成本高于 1024 尺寸 |
4096x4096 | 返回 HTTP 400,最长边不能超过 3840 | 不要把 4K 理解成 4096x4096 |
因此,在 XAI Router 当前行为下有两个推荐路径:
- 需要
gpt-5.5理解用户需求、改写提示词或参与多步骤工作流:使用 Responses API +stream:true+image_generation工具 +gpt-image-2。 - 已经接入 OpenAI 官方 Images API 或只需要生成/编辑单张图片:使用
/v1/images/generations或/v1/images/edits+model:"gpt-image-2"。
两条调用路径怎么选
| 路径 | Endpoint | model 字段怎么写 | 适合场景 |
|---|---|---|---|
| Responses API 工具调用 | /v1/responses | 主模型写 gpt-5.5,工具里写 model:"gpt-image-2" | 聊天式生成、多轮编辑、让主模型先理解或扩写提示词 |
| Images API 生成 | /v1/images/generations | 直接写 model:"gpt-image-2" | OpenAI 官方 Images API 兼容、文本生成单张或多张图片 |
| Images API 编辑 | /v1/images/edits | 直接写 model:"gpt-image-2" | 上传图片后编辑、用参考图生成新图、局部修改 |
如果你的客户端已经是 OpenAI SDK 的 client.images.generate() 或 client.images.edit(),通常只需要修改 baseURL 和 API Key。请求里的模型建议明确写 gpt-image-2。XAI Router 当前这组 Images API 以 gpt-image-2 为目标模型,不建议依赖 DALL·E 的旧参数语义。
/v1/images/variations 属于旧图像模型常见接口,不是 gpt-image-2 的推荐路径;对 gpt-image-2,重点使用 generations 和 edits。
所有示例都使用:
export XAI_API_KEY="你的 XAI API Key"Images API:生成图片
这是最接近 OpenAI 官方 Images API 的写法。请求地址是 https://api.xairouter.com/v1/images/generations,返回值包含 data[0].b64_json。
cURL
curl -sS "https://api.xairouter.com/v1/images/generations" \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "Generate a polished square portrait of a professional XAI female AI assistant in a bright futuristic control room. No text, no logos, no watermark.",
"size": "1024x1024",
"quality": "high",
"output_format": "png",
"response_format": "b64_json"
}' | jq -r '.data[0].b64_json' | base64 -d > xai-assistant.png
file xai-assistant.png典型返回结构如下:
{
"created": 1777573692,
"data": [
{
"b64_json": "...",
"revised_prompt": "..."
}
],
"output_format": "png",
"quality": "high",
"size": "1024x1024",
"usage": {
"input_tokens": 123,
"output_tokens": 456,
"total_tokens": 579
}
}对 gpt-image-2,建议把 response_format 固定为 b64_json。如果需要 URL,推荐在你的后端解码 base64 后上传到对象存储或 CDN,再把自有 URL 返回给前端。
Node.js
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.xairouter.com/v1",
});
const result = await client.images.generate({
model: "gpt-image-2",
prompt:
"Generate a polished square portrait of a professional XAI female AI assistant in a bright futuristic control room. No text, no logos, no watermark.",
size: "1024x1024",
quality: "high",
output_format: "png",
response_format: "b64_json",
});
const imageBase64 = result.data[0].b64_json;
fs.writeFileSync("xai-assistant.png", Buffer.from(imageBase64, "base64"));Python
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["XAI_API_KEY"],
base_url="https://api.xairouter.com/v1",
)
result = client.images.generate(
model="gpt-image-2",
prompt="Generate a polished square portrait of a professional XAI female AI assistant in a bright futuristic control room. No text, no logos, no watermark.",
size="1024x1024",
quality="high",
output_format="png",
response_format="b64_json",
)
with open("xai-assistant.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))Images API:4K 图片
gpt-image-2 支持灵活尺寸,但 4K 要按官方约束理解:
- 4K 横图:
3840x2160 - 4K 竖图:
2160x3840 - 最大边不超过
3840 - 两条边都必须是
16px的倍数 - 长边和短边比例不超过
3:1 - 总像素不超过
8,294,400
实测 3840x2160 和 2160x3840 都能生成,4096x4096 会被拒绝:
{
"error": {
"message": "Invalid size '4096x4096'. The longest edge must be less than or equal to 3840.",
"type": "image_generation_user_error",
"param": "tools",
"code": "invalid_value"
}
}4K 生成耗时更长,建议先用 quality:"low" 或 quality:"medium" 做草稿,确认画面方向后再提高质量。
curl -sS "https://api.xairouter.com/v1/images/generations" \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "Generate a clean 4K landscape image of a professional XAI female AI assistant in a bright futuristic command center. No text, no logos, no watermark.",
"size": "3840x2160",
"quality": "low",
"output_format": "jpeg",
"response_format": "b64_json"
}' | jq -r '.data[0].b64_json' | base64 -d > xai-4k-landscape.jpg
file xai-4k-landscape.jpg竖图只需要把 size 改为 2160x3840。
Images API:编辑图片
编辑接口使用 /v1/images/edits。OpenAI 官方 SDK 和 cURL 通常会发送 multipart/form-data,适合上传本地文件;XAI Router 会把输入图片传给 gpt-image-2 做编辑或作为参考图生成新图。
cURL 单图编辑
curl -sS "https://api.xairouter.com/v1/images/edits" \
-H "Authorization: Bearer $XAI_API_KEY" \
-F "model=gpt-image-2" \
-F "[email protected]" \
-F "prompt=Keep the same assistant identity and pose, but make the lighting brighter and add subtle floating interface panels. No text, no logos, no watermark." \
-F "size=1024x1024" \
-F "quality=high" \
-F "output_format=png" \
-F "response_format=b64_json" \
| jq -r '.data[0].b64_json' | base64 -d > xai-assistant-edited.pngcURL 多参考图
curl -sS "https://api.xairouter.com/v1/images/edits" \
-H "Authorization: Bearer $XAI_API_KEY" \
-F "model=gpt-image-2" \
-F "image[][email protected]" \
-F "image[][email protected]" \
-F "prompt=Create a new XAI assistant portrait using the first image as identity reference and the second image as lighting and color reference. No text, no logos, no watermark." \
-F "size=1024x1024" \
-F "quality=high" \
-F "output_format=png" \
-F "response_format=b64_json" \
| jq -r '.data[0].b64_json' | base64 -d > xai-assistant-reference-edit.pngNode.js 编辑
import fs from "node:fs";
import OpenAI, { toFile } from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.xairouter.com/v1",
});
const source = await toFile(fs.createReadStream("source.png"), "source.png", {
type: "image/png",
});
const result = await client.images.edit({
model: "gpt-image-2",
image: source,
prompt:
"Keep the same assistant identity and pose, but make the lighting brighter and add subtle floating interface panels. No text, no logos, no watermark.",
size: "1024x1024",
quality: "high",
output_format: "png",
response_format: "b64_json",
});
fs.writeFileSync(
"xai-assistant-edited.png",
Buffer.from(result.data[0].b64_json, "base64"),
);Python 编辑
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["XAI_API_KEY"],
base_url="https://api.xairouter.com/v1",
)
with open("source.png", "rb") as image:
result = client.images.edit(
model="gpt-image-2",
image=image,
prompt="Keep the same assistant identity and pose, but make the lighting brighter and add subtle floating interface panels. No text, no logos, no watermark.",
size="1024x1024",
quality="high",
output_format="png",
response_format="b64_json",
)
with open("xai-assistant-edited.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))如果需要局部编辑,可以传 mask。使用 mask 时,mask 应与第一张输入图尺寸一致,并包含 alpha 通道;实际效果仍建议通过提示词明确说明要替换或保留的区域。
Images API:流式生成和 partial images
直接调用 Images API 也可以使用 stream:true 和 partial_images。这条路径返回的是 Images API 风格事件:
image_generation.partial_image:中间图,data.b64_json是 partial 图片。image_generation.completed:最终图,data.b64_json是最终图片。
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.xairouter.com/v1",
});
const stream = await client.images.generate({
model: "gpt-image-2",
prompt:
"Draw a polished XAI assistant in a bright futuristic control room. No text, no logos, no watermark.",
size: "1024x1024",
quality: "medium",
output_format: "png",
response_format: "b64_json",
stream: true,
partial_images: 2,
});
for await (const event of stream) {
if (event.type === "image_generation.partial_image") {
const index = event.partial_image_index ?? 0;
fs.writeFileSync(`partial-${index}.png`, Buffer.from(event.b64_json, "base64"));
}
if (event.type === "image_generation.completed") {
fs.writeFileSync("final.png", Buffer.from(event.b64_json, "base64"));
}
}partial_images 可以请求 0 到 3 张中间图,但实际返回数量不保证固定。如果最终图生成很快,可能少于请求数量。
Responses API:最小请求体
如果你只想先确认接口能跑,最小请求体可以这样写:
{
"model": "gpt-5.5",
"input": "Generate an elegant image of a glass AI studio with soft light.",
"tools": [
{
"type": "image_generation",
"model": "gpt-image-2",
"size": "1024x1024"
}
],
"stream": true
}这里的 model: "gpt-5.5" 是 Responses API 的主模型。tools 里的 image_generation 负责生成图像,并把图像模型指定为 gpt-image-2。
在实际使用中,建议保留 stream: true。流式响应会把生成进度和最终图片结果直接推回来,便于在脚本里拿到 base64 并落盘。
Responses API:官方示例改成 XAI Router
OpenAI 官方 JavaScript 示例大致是:
import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.responses.create({
model: "gpt-5.5",
input: "Generate an image of a premium AI workspace",
tools: [{ type: "image_generation" }],
});改成 XAI Router 时,主要改两处:
apiKey从process.env.XAI_API_KEY读取。baseURL改成https://api.xairouter.com/v1。
同时,如果你希望明确使用 gpt-image-2,可以在 image_generation 工具里指定 model:
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.xairouter.com/v1",
});
const response = await client.responses.create({
model: "gpt-5.5",
input: "Generate an elegant image of a glass AI studio with soft light.",
tools: [
{
type: "image_generation",
model: "gpt-image-2",
size: "1024x1024",
},
],
});
const imageData = response.output
.filter((output) => output.type === "image_generation_call")
.map((output) => output.result);
if (imageData.length > 0) {
fs.writeFileSync("xai-image.png", Buffer.from(imageData[0], "base64"));
}这就是最接近官方文档的改法。它适合普通同步调用;如果图片生成耗时较长,建议改用下面的流式版本。
cURL:生成并保存为 PNG
先设置 API Key:
export XAI_API_KEY="你的 XAI API Key"下面这个脚本会调用 gpt-5.5,让它通过 image_generation 工具使用 gpt-image-2 生成图片,并把最终 base64 解码为 xai-generated-image.png。
out="xai-generated-image.png"
prompt='Create an elegant technical cover image: a refined glass AI studio, a luminous prompt console, and a generated image appearing as a softly glowing framed visual. No words, no logos, no watermark.'
body=$(jq -nc --arg prompt "$prompt" '{
model: "gpt-5.5",
input: $prompt,
tools: [
{
type: "image_generation",
model: "gpt-image-2",
size: "1024x1024"
}
],
stream: true
}')
sse=$(mktemp)
b64=$(mktemp)
trap 'rm -f "$sse" "$b64"' EXIT
curl -sS -N --max-time 300 "https://api.xairouter.com/v1/responses" \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
--data-binary "$body" > "$sse"
awk '/^data: /{
data=$0
sub(/^data: /, "", data)
if (data != "[DONE]") print data
}' "$sse" |
while IFS= read -r json; do
jq -r '(.item.result? // .result? // empty)' 2>/dev/null <<< "$json"
done |
awk 'length($0) > max {max=length($0); best=$0} END {if (max > 0) print best}' > "$b64"
if [ ! -s "$b64" ]; then
echo "No image result found."
exit 1
fi
base64 -d "$b64" > "$out"
file "$out"成功时,你会看到类似输出:
xai-generated-image.png: PNG image data, 1024 x 1024, 8-bit/color RGB, non-interlaced这段脚本做了三件事:
- 用
jq组装 JSON 请求体,避免 shell 引号把长提示词弄坏。 - 用
curl -N接收 Server-Sent Events 流式响应。 - 从事件里的
image_generation_call.result提取最长的 base64 字符串并解码成 PNG。
如果你希望看到中间进度,可以在解析 SSE 时打印 event: 行。常见事件包括:
response.created
response.in_progress
response.output_item.added
response.image_generation_call.generating
response.output_item.done
response.completedResponses API:Node.js 示例
如果你在 Node.js 项目里使用 OpenAI SDK,可以把 baseURL 指向 XAI Router:
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.xairouter.com/v1",
});
const stream = await client.responses.create({
model: "gpt-5.5",
input:
"Create an elegant technical cover image: a refined glass AI studio, a luminous prompt console, and a generated image appearing as a softly glowing framed visual. No words.",
tools: [
{
type: "image_generation",
model: "gpt-image-2",
size: "1024x1024",
},
],
stream: true,
});
let imageBase64 = "";
for await (const event of stream) {
if (event.type === "response.output_item.done") {
const item = event.item;
if (item?.type === "image_generation_call" && item.result) {
imageBase64 = item.result;
}
}
}
if (!imageBase64) {
throw new Error("No image result returned");
}
fs.writeFileSync("xai-generated-image.png", Buffer.from(imageBase64, "base64"));这个版本的重点是监听 response.output_item.done。当 item.type 是 image_generation_call 时,item.result 通常就是最终图片的 base64 内容。
Responses API:Python 示例
Python 版本同样只需要把客户端指向 XAI Router:
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["XAI_API_KEY"],
base_url="https://api.xairouter.com/v1",
)
response = client.responses.create(
model="gpt-5.5",
input="Generate an elegant image of a glass AI studio with soft light.",
tools=[
{
"type": "image_generation",
"model": "gpt-image-2",
"size": "1024x1024",
}
],
)
image_data = [
output.result
for output in response.output
if output.type == "image_generation_call"
]
if image_data:
with open("xai-generated-image.png", "wb") as f:
f.write(base64.b64decode(image_data[0]))如果你要做 Web 服务,建议把保存逻辑换成对象存储上传,例如 S3、R2、OSS 或你自己的 CDN。数据库里只保存图片 URL、提示词、模型、尺寸和生成状态,不要把大段 base64 直接塞进业务表。
Responses API:强制调用图像工具
默认情况下,主模型会根据用户输入决定是否调用工具。大多数“请生成一张图片”的请求都会触发 image_generation,但如果你的产品按钮就是“生成图片”,可以用 tool_choice 强制调用:
{
"model": "gpt-5.5",
"input": "Draw an elegant AI product cover image.",
"tools": [
{
"type": "image_generation",
"model": "gpt-image-2",
"size": "1024x1024"
}
],
"tool_choice": {
"type": "image_generation"
}
}这个写法适合后台任务、批量生成和固定按钮触发的工作流。聊天场景可以不加,让模型自己判断什么时候需要生成图片。
Responses API:常用工具选项
image_generation 工具除了 model 之外,还可以设置一些输出参数。实际支持情况以 XAI Router 当前模型能力为准,但接口形态可以按 OpenAI 官方风格组织:
{
"type": "image_generation",
"model": "gpt-image-2",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}常见选项可以这样理解:
| 参数 | 用途 | 建议 |
|---|---|---|
size | 输出尺寸 | 头像和封面先用 1024x1024;4K 横图用 3840x2160,竖图用 2160x3840 |
quality | 渲染质量 | 预览用 low 或 medium,成稿用 high |
output_format | 输出格式 | 需要无损后处理用 png,网页大图可考虑 webp |
output_compression | 压缩级别 | JPEG/WebP 场景再设置 |
background | 背景 | gpt-image-2 当前不适合请求透明背景 |
action | 生成或编辑 | 新图用 generate,多轮上下文可保留 auto |
如果你需要透明图,建议先生成干净的纯色背景,再用后处理去底;或者确认当前图像模型和路由是否支持原生透明背景后再开启。
Responses API:流式 partial images
OpenAI 官方示例里,图片生成可以返回 partial images,用于更快给用户展示中间结果。XAI Router 兼容时,可以在工具里加 partial_images:
const stream = await client.responses.create({
model: "gpt-5.5",
input: "Draw an elegant AI studio with a generated image panel.",
stream: true,
tools: [
{
type: "image_generation",
model: "gpt-image-2",
size: "1024x1024",
partial_images: 2,
},
],
});
for await (const event of stream) {
if (event.type === "response.image_generation_call.partial_image") {
const imageBuffer = Buffer.from(event.partial_image_b64, "base64");
fs.writeFileSync(`partial-${event.partial_image_index}.png`, imageBuffer);
}
if (event.type === "response.output_item.done") {
const item = event.item;
if (item?.type === "image_generation_call" && item.result) {
fs.writeFileSync("final.png", Buffer.from(item.result, "base64"));
}
}
}产品上可以先展示 partial image,再用最终图替换它。这样用户感知延迟会低很多,尤其适合图片生成页、创意工具和聊天式设计助手。
Responses API:为什么建议使用 stream
图片生成比普通文本响应耗时更长。虽然当前实测中非流式 Responses 图片生成可以直接返回完整结果,但对脚本和服务端任务来说,stream: true 更直接:
- 可以看到
response.image_generation_call.generating等进度事件。 - 可以在同一条连接里拿到最终
image_generation_call。 - 不需要额外管理轮询、任务状态和超时恢复。
如果你只是做一次性验证,可以先把提示词写短,生成一张 1024x1024 的图。等链路稳定后,再增加更详细的画面描述、品牌约束和风格要求。
提示词建议
图像生成提示词不需要很长,但最好明确四件事:
- 主体:要生成什么,例如技术封面、产品图、角色头像。
- 构图:居中、半身、俯视、留白、横幅或方图。
- 风格:写实、半写实、插画、产品渲染、编辑感。
- 避免项:不要水印、不要文字、不要变形手、不要低质量伪影。
例如:
Create an elegant technical cover image for an article about GPT-5.5 calling GPT Image 2 through an API router.
Show a refined glass AI studio, a luminous prompt console, and a generated image appearing as a softly glowing framed visual.
Square 1024x1024 composition, premium editorial look, graphite, ivory, soft teal and silver accents.
No words, no logos, no watermark, no clutter.如果你需要图片里出现准确文字,建议谨慎使用。图像模型可以生成文字,但稳定性通常不如在前端、设计软件或后处理流程里单独排版。
适合落地的产品形态
这个组合适合很多常见产品功能:
| 场景 | 典型输入 | 输出 |
|---|---|---|
| 博客封面生成 | 文章标题、摘要、风格 | 封面图 |
| 电商素材 | 商品名、卖点、背景偏好 | 商品场景图 |
| 角色头像 | 人设、职业、服装、表情 | 头像或角色卡 |
| 广告创意 | 活动主题、品牌色、禁用元素 | 多个方向的视觉草案 |
| 设计助手 | 用户自然语言需求 | 可保存和复用的图片资产 |
一个稳妥的后端流程通常是:
- 接收用户输入和画面约束。
- 用
gpt-5.5整理或补全图像提示词。 - 调用
image_generation,图像模型指定gpt-image-2。 - 把 base64 解码成图片文件。
- 上传到对象存储或 CDN。
- 返回图片 URL、模型、尺寸、提示词和生成时间。
这样做比把生成逻辑直接塞在前端更稳:Key 不暴露,超时可控,也方便记录失败原因和重试。
常见问题
gpt-image-2 能不能放在 Responses API 的 model 字段?
不要这样写。Responses API 的 model 字段应该放文本/主线模型,例如 gpt-5.5。gpt-image-2 是图像模型,应该放在 image_generation 工具配置里。
但如果你调用的是 /v1/images/generations 或 /v1/images/edits,那里的 model 字段就应该直接写 gpt-image-2。
需要让图片里出现中文标题怎么办?
建议把文字和图片分开处理:图像模型负责生成无字背景或主视觉,前端、Canvas、设计软件或后处理脚本负责排版中文。这样可控性更高,也更容易保持品牌字体和响应式布局。
小结
通过 XAI Router 调用 gpt-image-2,现在有两种稳定写法:
gpt-5.5 -> image_generation tool -> gpt-image-2 -> base64 image result
/v1/images/generations or /v1/images/edits -> gpt-image-2 -> b64_json image resultResponses API 适合把“理解需求、扩写提示词、选择工具、生成图像”放在同一个多模态工作流里。Images API 适合兼容 OpenAI 官方 SDK 和 /v1/images/* 调用,尤其是已有 images.generate() 或 images.edit() 代码的应用。对应用开发来说,前端只需要提交自然语言需求或图片文件,后端调用 XAI Router,再把 gpt-image-2 返回的图片保存到对象存储、CDN 或本地文件即可。
参考资料: