mai-image
- 文生图与多图参考
- 参考图最多 5 张
- 支持联网检索实时信息
认证
All endpoints authenticate with a Bearer token.
Get an API key: open the console and create one.
Add it to the request header:
Authorization: Bearer YOUR_OAIRoute_KEY请求结构
请求体是平铺的 JSON,创作字段与输出字段都在顶层,没有 content 数组包装。
The body is flat JSON: creative fields and output fields sit at the top level, with no content array wrapper.
支持的场景
| 场景 | 字段组合 |
|---|---|
| 文生图 | prompt |
| 单图编辑 | prompt + image(1 张) |
| 多图合成 | prompt + image(2 到 5 张) |
| 实时信息配图 | prompt + web_grounding: true |
带参考图后,输出尺寸完全由模型依据参考图决定,约 100 万像素,比例贴近参考图,size、resolution、width、height 都无法指定。
| Scenario | Field combination |
|---|---|
| Text to image | prompt |
| Single-image edit | prompt + image (1 image) |
| Multi-image compose | prompt + image (2 to 5 images) |
| Live-information illustration | prompt + web_grounding: true |
With reference images, the output size is decided entirely by the model based on them — about one megapixel, close to the reference ratio — and size, resolution, width, and height can't be specified.
请求参数
提交成功只返回任务 ID,不含图片本身。拿结果用 task_id 轮询获取任务状态,图片地址在 result.images[0].url,该地址会过期,请及时转存。
取值 mai-image-2.6 或 mai-image-2.6-flash。
描述或编辑指令,中英文均可,上限约 32000 token。
默认 1:1。
可写宽高比(整比范围 1:4 到 4:1)、精确像素(如 1536x1024,也支持 * 与 × 分隔),或 auto。
只在文生图生效,传入参考图后输出尺寸由模型决定。
取值 1K(默认)、2K,兼容小写。4K 等其他档位返回 400。
必须与 height 成对,优先级高于 size 与 resolution。
最小 768,宽高乘积上限 2359296,建议取 32 的倍数,否则向下取整。
约束与 width 相同。
参考图,最多 5 张。
公网直链或 Base64 Data URL。JPEG、PNG 直接使用,WEBP 与 GIF 自动转 PNG。
为 true 时由模型按提示词选比例,等同 size: "auto",默认 false。
生成前检索实时信息,适合真实人物、地点与事件,默认 false。
只能为 1,大于 1 返回 400。
A successful submission returns only the task ID, not the image itself. Poll Get task status with the task_id; the image URL is at result.images[0].url and expires, so copy it promptly.
mai-image-2.6 or mai-image-2.6-flash.
A description or edit instruction, in Chinese or English, up to about 32000 tokens.
Defaults to 1:1.
Accepts aspect ratios (whole ratios from 1:4 to 4:1), exact pixels (such as 1536x1024, also with * or × separators), or auto.
Applies to text to image only; with reference images the output size is decided by the model.
1K (default) or 2K; lowercase accepted. Other tiers such as 4K return a 400.
Must be paired with height; takes precedence over size and resolution.
Minimum 768, with width times height capped at 2359296; multiples of 32 are recommended, otherwise it's rounded down.
Same constraints as width.
Reference images, up to 5.
Public direct links or Base64 Data URLs. JPEG and PNG are used as-is; WEBP and GIF are converted to PNG automatically.
When true, the model picks the ratio from the prompt; equivalent to size: "auto". Defaults to false.
Retrieves live information before generating; suitable for real people, places, and events. Defaults to false.
Must be 1; values above 1 return a 400.
不生效的字段
quality、style、background、output_format、response_format、mask_url 传入会被忽略。输出固定为 PNG,不支持蒙版编辑。
quality, style, background, output_format, response_format, and mask_url are ignored. Output is always PNG, and mask-based editing isn't supported.
尺寸约束
width 与 height 最小 768,宽高乘积上限 2359296。上限针对总像素而非单边,因此长边可以超过 1536,例如 3072x768 合法,而 2048x2048 超限。
width and height must be at least 768, with width times height capped at 2359296. The cap applies to total pixels rather than either side, so the long side can exceed 1536: 3072x768 is valid, while 2048x2048 exceeds the limit.
响应
提交成功返回受理结构:
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
}
]
}状态码,200 表示任务已受理。
本次提交的任务列表。
受理状态,提交成功时为 submitted。
任务 ID,用它轮询结果。
完成态返回:
{
"code": 200,
"data": {
"id": "task_01K8SGYNNNVBQTXNR4MM964S7K",
"status": "completed",
"progress": 100,
"result": {
"images": [
{ "url": ["https://cdn.oairoute.com/f/image/task_01K8_0.png"], "expires_at": 1763174708 }
]
},
"created": 1763088289,
"completed": 1763088302
}
}A successful submission returns an accepted structure:
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
}
]
}The status code; 200 means the task was accepted.
The list of tasks submitted this time.
The acceptance status; submitted on success.
The task ID; use it to poll for the result.
The completed state returns:
{
"code": 200,
"data": {
"id": "task_01K8SGYNNNVBQTXNR4MM964S7K",
"status": "completed",
"progress": 100,
"result": {
"images": [
{ "url": ["https://cdn.oairoute.com/f/image/task_01K8_0.png"], "expires_at": 1763174708 }
]
},
"created": 1763088289,
"completed": 1763088302
}
}错误码
| HTTP | 含义 |
|---|---|
| 400 | 参数错误,type 为 invalid_request_error |
| 401 | Token 缺失或无效,type 为 authentication_error |
| 402 | 余额不足,type 为 payment_required |
| 429 | 触发限流 |
| HTTP | Meaning |
|---|---|
| 400 | Invalid parameters, with type invalid_request_error |
| 401 | Token missing or invalid, with type authentication_error |
| 402 | Insufficient balance, with type payment_required |
| 429 | Rate limit hit |
For more status codes and retry guidance see Error codes and rate limits; for troubleshooting steps on common errors see the FAQ.
支持的模型列表
| 模型 ID | 定位 |
|---|---|
mai-image-2.6 | 高画质版,画质优先 |
mai-image-2.6-flash | 快速版,速度更快、成本更低,画质略低 |
两个模型参数与能力一致,每次调用只出 1 张图。
GET https://api.oairoute.com/api/pricing。| Model ID | Positioning |
|---|---|
mai-image-2.6 | High-quality version, quality first |
mai-image-2.6-flash | Fast version: quicker and cheaper, slightly lower quality |
Both models share the same parameters and capabilities, and each call produces one image.
GET https://api.oairoute.com/api/pricing.