Imagen
- 纯文生图,不支持参考图
- 五种固定画幅,其余比例自动回落 16:9
- 每次固定输出 1 张
认证
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 |
只有文生图一种模式。传 image 会返回 400,提示该模型不支持图生图。
mask、quality 等其他字段会被忽略。
| Scenario | Field combination |
|---|---|
| Text to image | prompt |
Text to image is the only mode. Passing image returns a 400 saying the model doesn't support image-to-image.
Other fields such as mask and quality are ignored.
请求参数
提交成功只返回任务 ID,不含图片本身。拿结果用 task_id 轮询获取任务状态,图片地址在 result.images[0].url,该地址会过期,请及时转存。
取值为 imagen-4.0-apimart。
画面描述,中英文均可。
画幅,取值 1:1、4:3、3:4、16:9、9:16,默认 16:9。
表外比例(如 21:9)会静默回落为 16:9,不报错。
只能为 1。
为 true 时先做内容审查,默认 false。
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.
Always imagen-4.0-apimart.
The scene description, in Chinese or English.
Aspect ratio: 1:1, 4:3, 3:4, 16:9, or 9:16; defaults to 16:9.
Ratios outside the table (such as 21:9) silently fall back to 16:9, with no error.
Must be 1.
When true, runs a content check first. Defaults to false.
使用限制
size 只认五种比例,其余值静默回落到 16:9,不会报错也不会提示。这一点和其他系列不同,客户端需要自己校验。
输出链接 24 小时后过期。
size accepts only the five ratios; any other value silently falls back to 16:9, with no error and no warning. That differs from other series, so the client has to validate itself.
Output links expire after 24 hours.
响应
提交成功返回受理结构:
{
"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 | 定位 |
|---|---|
imagen-4.0-apimart | 纯文生图,Google Imagen 4 底座 |
只支持文生图,参考图、局部重绘都无法使用。
GET https://api.oairoute.com/api/pricing。| Model ID | Positioning |
|---|---|
imagen-4.0-apimart | Text to image only, on Google's Imagen 4 base |
Text to image only; reference images and inpainting aren't available.
GET https://api.oairoute.com/api/pricing.