Grok Image 2.0 Image to Image API
https://api.hiapi.ai /v1/tasks Image, video, and audio models are called through theUnified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).
Model summary
| Model name | grok-imagine-image-2.0/image-to-image |
|---|---|
| Type | Image generation (image-to-image) |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI live pricing |
xAI Grok Imagine Image 2.0 edits one public reference image with natural-language instructions for recoloring, restyling, scene changes, and refinements.
Production guidance
- Pass one publicly reachable JPG, JPEG, PNG, or WebP URL in input.image; do not send an image_urls array.
- Keep the API key on your server and use callback.url when your service should receive terminal task notifications.
- aspect_ratio is accepted by the request validator but ignored during editing; the reference image determines the output framing.
Best suited for
Preserve the subject while changing color, material, background, or lighting.
input.imageinput.promptTurn a reference photo into an illustration, cinematic frame, or another specified visual style.
input.imageinput.promptDrive a complete edit from one reference image and a natural-language instruction.
input.imageinput.qualityinput.resolutionRequest parameters
model string required Use grok-imagine-image-2.0/image-to-image.
input object required Model input parameters.
prompt string required Natural-language editing instruction for the reference image.
image string required One public JPG, JPEG, PNG, or WebP reference image; the public contract accepts one image.
quality enum optional Generation quality; medium has more detail and low has lower latency.
resolution enum optional Output resolution tier.
aspect_ratio enum optional The request accepts this field, but edited output always follows the reference image framing; the field has no effect.
callback object optional Optional callback configuration for terminal task notifications.
url string required HTTPS endpoint required when callback is provided.
when enum optional Callback timing; use final.
Example requests
Keep the sneaker shape, recolor it electric blue, and render a 2k studio shot.
{
"model": "grok-imagine-image-2.0/image-to-image",
"input": {
"prompt": "Recolor the sneaker to vivid electric blue, keep the original shape and place it in a clean studio product shot",
"image": "https://static.hiapi.ai/example/inputs/sneaker.jpg",
"quality": "medium",
"resolution": "2k",
"aspect_ratio": "1:1"
}
}使用中文指令编辑一张公开参考图。
{
"model": "grok-imagine-image-2.0/image-to-image",
"input": {
"prompt": "把鞋子改成鲜艳的电光蓝,保持原有形状,并放在干净的棚拍产品画面中",
"image": "https://static.hiapi.ai/example/inputs/sneaker.jpg",
"quality": "medium",
"resolution": "2k",
"aspect_ratio": "1:1"
}
}Getting the result
- The response returns a taskId immediately.
- Poll GET /v1/tasks/:id or wait for the callback terminal event.
- When status=success, download the edited image from output[].url.
- When status=fail, fix the request using the returned error before retrying.
FAQ
Which image field should I send?
Send one publicly reachable JPG, JPEG, PNG, or WebP URL in input.image. Do not use an image_urls array.
Can I send multiple reference images?
No. The public Grok Image 2.0 image-to-image contract accepts one reference image.
Does aspect_ratio affect editing?
It is accepted but has no effect — edited output always follows the reference image framing.
How do I retrieve the edited image?
Read the returned taskId, poll GET /v1/tasks/:id or wait for callback.url, then download output[].url when status is success.