OmwAIOmwAI
API GuideAPI ReferenceProgramming Tools
Grok Image

Image Editing

Grok Image async image editing endpoint

Grok Image image editing is called through the async image task entry: POST /v1/images/async/generations, with reference images passed in the images field (an array of image URLs, 1-5) to enter image-to-image/edit mode.

The interface is async: on success it returns an image.task task object (with task_id); poll the Query Result endpoint with the returned task ID until status becomes completed to fetch the final image.

Supported models

grok-imagine-1.0-edit, grok-imagine-2.0-edit, and the Grok Image family: grok-imagine-image, grok-imagine-image-quality, grok-imagine-image-2.0.

Single-image / multi-image editing

The interface panel below lets you switch between single-image and multi-image request bodies: single-image editing passes one reference image via image (an image URL); multi-image editing passes up to 5 reference image URLs via the images array (publicly reachable http/https URLs; duplicate URLs are de-duplicated automatically). The async entry accepts JSON only, so reference images must be publicly reachable http/https URLs — host local files at a public address before passing them in. Each edit returns exactly one image.

POST
/v1/images/async/generations

Authorization

BearerAuth

AuthorizationBearer <token>

使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx 令牌需开通对应模型的调用权限。

In: header

Request Body

application/json

model*string

模型名称,可选:grok-imagine-1.0-edit、grok-imagine-2.0-edit、grok-imagine-image、grok-imagine-image-quality、grok-imagine-image-2.0

prompt*string

编辑指令,描述对参考图的保留 / 修改要求

image?string

单张参考图 URL(http/https)。多张请使用 images 数组

images?array<string>

参考图 URL 列表(1-5 张,公开可访问的 http/https 地址)。重复 URL 会自动去重

Itemsitems <= 5
size?string

输出比例。可传 OpenAI 风格尺寸(如 1024x1024、1536x1024、1024x1536),网关会映射为最接近的宽高比;也可直接传宽高比(如 1:1、16:9、9:16、3:2、2:3)。不传默认 1:1

quality?string

画质:low / medium。仅 grok-imagine-image-2.0 支持;其余模型忽略该字段

Value in"low" | "medium"

Response Body

application/json

application/json

application/json

curl -X POST "https://www.omwai.xyz/v1/images/async/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "grok-imagine-2.0-edit",    "prompt": "保留主体,将背景改成雪山和清晨的自然光",    "image": "https://example.com/source.png",    "size": "1024x1024"  }'
{
  "id": "task_01J8ABCDEFGHIJKLMNOPQRST",
  "task_id": "task_01J8ABCDEFGHIJKLMNOPQRST",
  "object": "image.task",
  "model": "grok-imagine-2.0-edit",
  "status": "queued",
  "progress": "0%",
  "created_at": 1788256630,
  "completed_at": 1788256720
}
{
  "code": "invalid_request",
  "message": "string"
}
{
  "code": "string",
  "message": "string"
}

Async flow

  1. POST /v1/images/async/generations submits the task and returns task_id (prefixed with task_) and status=queued;
  2. Poll GET /v1/images/async/generations/{task_id} with that task_id;
  3. When status=completed, the data array contains the final image URL (url field); when failed, error explains why.

Images are kept for about 2 hours

The returned image URL is temporary (metadata.assetsExpireAt holds the expiry time in Unix seconds); images are kept for about 2 hours and then deleted automatically. Download them before they expire if you need long-term storage. Querying a task that does not exist or is not accessible returns 400.

How is this guide?

Last updated on