Skip to main content
POST
生成图片
Create an image task. Returns { "taskId": "..." }. Poll Get Task Result until status is completed.
quality is only sent upstream when model is grok-imagine-image-2.0. Other models ignore it.

Models

Request

Aspect ratios

2:3 3:2 1:1 9:16 16:9 4:3 3:4 2:1 1:2 19.5:9 9:19.5 20:9 9:20 21:9 5:2 auto

Examples

Image-to-image (size follows the first reference if aspectRatio is omitted):

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

图片描述提示词(最大 5000 字符)

Maximum string length: 5000
Example:

"a cute cat sitting on a windowsill"

model
enum<string>
required

图片模型

Available options:
grok-imagine-image,
grok-imagine-image-quality,
grok-imagine-image-2.0
Example:

"grok-imagine-image"

n
number
default:1

生成张数,1–10。不传则生成 1 张(与现网一致)

Required range: 1 <= x <= 10
aspectRatio
enum<string>

图片宽高比。不传则由模型自行决定(官方 auto)

Available options:
2:3,
3:2,
1:1,
9:16,
16:9,
4:3,
3:4,
2:1,
1:2,
19.5:9,
9:19.5,
20:9,
9:20,
21:9,
5:2,
auto
resolution
enum<string>

图片分辨率,1k / 2k。不传则走官方默认 1k

Available options:
1k,
2k
quality
enum<string>

生成质量,仅 grok-imagine-image-2.0 支持。不传则不向官方传该字段

Available options:
low,
medium,
auto
images
string[]

参考图片 URL(图生图 / 编辑图片,最多 5 张)。不传 aspectRatio 时输出尺寸跟随第一张参考图;传入则覆盖

Maximum array length: 5

Response

200 - application/json
taskId
string
required

任务 ID,用于后续查询结果