Grok Imagine Text 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/text-to-image |
|---|---|
| Type | Image generation (text-to-image) |
| Routes | default / quality |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI Pricing |
Grok Imagine text-to-image: fast and low-cost with 13 aspect ratios and flat 1k/2k pricing; the standalone quality-tier model (grok-imagine-quality/text-to-image) delivers hero-grade output with resolution-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
The standard model optimizes speed and cost — ideal for batches and ideation.
promptFrom 2:1/20:9 ultra-wide to 9:20 extra-tall, covering every social format.
aspect_ratioOn the standard model, resolution does not change the price — just use 2k.
resolutionFor hero-grade detail, switch to grok-imagine-quality/text-to-image (xAI official quality model), billed in 1k/2k tiers.
promptRequest parameters
model string required Fixed value grok-imagine/text-to-image.
input object required Business parameters. Put Grok Imagine Text to Image-specific configuration here.
prompt string required Text description of the image to generate.
aspect_ratio enum optional Aspect ratio of the generated image.
resolution enum optional Output image resolution.
output_format enum optional Output image format.
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 on the standard model with full parameters at 16:9.
{
"model": "grok-imagine/text-to-image",
"input": {
"prompt": "A red panda tea master in a tiny mountain teahouse pouring glowing amber tea, steam curling into soft light",
"aspect_ratio": "16:9",
"resolution": "2k",
"output_format": "jpeg"
}
}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
Standard vs quality tier?
Standard (grok-imagine/text-to-image) is fast and cheap for volume; the quality-tier model (grok-imagine-quality/text-to-image) has richer detail with 1k/2k tiered pricing.
How do I get higher quality?
Use the standalone quality-tier model grok-imagine-quality/text-to-image (xAI official quality model) — same parameters, priced by 1K/2K resolution tiers.
Does it take reference images?
Use grok-imagine/image-to-image for reference-based edits.