Grok Image 2.0 Text to Image API
https://api.hiapi.ai /v1/tasks Image, video, and audio 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-2.0/text-to-image |
|---|---|
| Type | Image generation (text-to-image) |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI live pricing |
xAI Grok Imagine Image 2.0 for natural-language image generation with 1k/2k output and flexible square-to-ultrawide framing.
Production guidance
- Keep the API key on your server. The unified task endpoint returns a taskId instead of holding the request open.
- Pass callback.url at the top level when you want HiAPI to notify your service on success or failure.
- The public contract supports only low/medium quality and 1k/2k resolution; unsupported values are rejected.
Best suited for
Generate concept art, social assets, and product directions from natural-language prompts.
input.promptinput.qualityUse 16:9, 2:1, 19.5:9, or 20:9 for wide creative assets.
input.aspect_ratioChoose 1k for lower latency or 2k for more detail.
input.resolutionRequest parameters
model string required Use grok-imagine-image-2.0/text-to-image.
input object required Model input parameters.
prompt string required Description of the image to generate.
quality enum optional Generation quality; medium has more detail and low has lower latency.
resolution enum optional Output resolution tier.
aspect_ratio enum optional Output aspect ratio.
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
Generate a wide product concept at 2k.
{
"model": "grok-imagine-image-2.0/text-to-image",
"input": {
"prompt": "A premium editorial product photograph of a translucent glass camera aperture glowing over a dark studio surface",
"quality": "medium",
"resolution": "2k",
"aspect_ratio": "16:9"
}
}Use a Chinese prompt for a landscape concept image.
{
"model": "grok-imagine-image-2.0/text-to-image",
"input": {
"prompt": "深色摄影棚中的半透明玻璃光圈,内部发出洋红色光芒,高级商业产品摄影质感",
"quality": "medium",
"resolution": "2k",
"aspect_ratio": "16:9"
}
}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 image from output[].url.
- When status=fail, fix the request using the returned error before retrying.
FAQ
What is the model ID?
Set model to grok-imagine-image-2.0/text-to-image.
Which quality and resolution values are supported?
quality supports low and medium; resolution supports 1k and 2k. The defaults are medium and 1k.
Which aspect ratios are supported?
The model accepts 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, and auto.
How do I retrieve the result?
Read the returned taskId, poll GET /v1/tasks/:id or wait for callback.url, then download output[].url when status is success.