Generate image with Grok Imagine
xAI Grok Imagine — image generation with strong aesthetics and instruction-based image editing from up to 3 reference images. Flat 35 credits per image at 1K or 2K.
Asynchronous. Returns a job id (the image is not in this response). Poll GET /v1/images/{id} until status is succeeded — the generated image URLs are in that response’s images array (each { url, position }).
Authorizations
API key as a bearer token: Authorization: Bearer bpx_live_xxx
Body
Text description of the image to generate.
Output aspect ratio.
1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, auto, match_input_image Number of images to generate.
1 <= x <= 4Optional reference images (up to 3) for image editing. Each item is a public image URL, a data URI, raw base64, or an uploaded-file URL from POST /v1/uploads. Omit for text-to-image. Use aspect_ratio "match_input_image" (or "auto") to let the model follow the input.
3Output resolution tier. Both tiers bill the same 35 credits per image.
1K, 2K