Grok Imagine Image to Image API
/v1/tasks All models are called through the Unified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).
Model summary
| Model name | grok-imagine/image-to-image |
|---|---|
| Type | Image generation (image-to-image) |
| Routes | default / quality |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI Pricing |
Grok Imagine image editing: blends up to 3 references at a flat per-image price; the standalone quality-tier model (grok-imagine-quality/image-to-image) adds stronger consistency with tiered pricing.
Production guidance
- For production, pass callback.url at the top level of the request body so HiAPI can notify your service when the task reaches a terminal state.
- GET /v1/tasks/:id is better for local debugging, low-volume jobs, or fallback reconciliation if a callback is missed.
- Use callback.when=final. Both success and fail are terminal states, so your service should deduplicate by taskId.
Best suited for
Up to 3 references cited by order — composites and subject transfer.
image_urlspromptDefaults to the first input image ratio — change content, keep framing.
aspect_ratioOn the standard model, price is independent of reference count.
resolutionFor stronger consistency, switch to grok-imagine-quality/image-to-image — style transformations keep composition, billed in 1k/2k tiers.
promptRequest parameters
model string required Fixed value grok-imagine/image-to-image.
input object required Business parameters. Put Grok Imagine Image to Image-specific configuration here.
prompt string required Editing instruction describing the desired output.
aspect_ratio enum optional Aspect ratio of the generated image. 'auto' follows the first input image.
resolution enum optional Output image resolution.
output_format enum optional Output image format.
image_urls string[] required Input reference images (1-3). Public URLs; jpeg/png/webp (SVG not supported).
callback object optional Optional callback configuration. When set, HiAPI notifies your service when the task reaches a terminal state.
url string required Required when callback is set; HTTPS URL that receives terminal task notifications.
when enum optional Callback trigger timing. Use final.
Example requests
Tested two-reference composite with auto aspect on the standard model.
{
"model": "grok-imagine/image-to-image",
"input": {
"prompt": "Place the crystal aurora fox from image 1 inside the cozy teahouse scene from image 2, sitting beside the red panda tea master",
"image_urls": [
"https://static.hiapi.ai/gallery/2026/07/9aebd45f17988676.jpg",
"https://static.hiapi.ai/gallery/2026/07/08abfb032c3b7640.jpg"
]
}
}Getting the result
- The response returns a taskId immediately without waiting for generation to finish.
- In production, prefer waiting for callback.url to receive the terminal notification. For local debugging, poll GET /v1/tasks/:id.
- When status=success, download the generated image from output[].url.
- When status=fail, fix the request based on the returned error instead of retrying the same invalid payload.
FAQ
How many references?
1-3, cited by order in the prompt.
Need stronger consistency?
Use the standalone quality-tier model grok-imagine-quality/image-to-image (xAI official quality model) — same parameters, priced by 1K/2K resolution tiers.