Grok Imagine Image 2.0
Model id: x-ai/grok-imagine-image-2.0. Grok Imagine Image 2.0 is the second generation of the xAI image model, for image generation and editing.
Model Overview
Grok Imagine Image 2.0 is the second generation of the xAI image model, for image generation and editing. It follows detailed instructions closely, renders small text and typography sharply, and edits from up to 5 reference images. Choose low or medium quality at 1K, 1.5K or 2K resolution.
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
API Schemas
The text prompt describing the content, style, or composition of the image to be generated.
The number of images to generate.
1The format in which the generated images are returned.
urlPossible values: The aspect ratio of the generated image.
autoPossible values: The resolution of the output image. A higher resolution costs more.
1kPossible values: The quality of the image that will be generated. medium renders more detail and costs more than low at the same resolution.
lowPossible values: Successful response.
curl --request POST \
--url 'https://api.aimlapi.com/v1/images/generations' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
--header 'Content-Type: application/json' \
--data '{"model": "x-ai/grok-imagine-image-2.0", "prompt": "Describe what you want the model to generate."}'Successful response.
{
"data": [
{
"url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
"b64_json": null
}
],
"meta": {
"usage": {
"credits_used": 120000,
"usd_spent": 0.06
}
}
}The text prompt describing the content, style, or composition of the image to be generated.
The image(s) to edit: one PNG, JPEG or WebP file, or an array of up to 5. Refer to several images in the prompt as <IMAGE_0>, <IMAGE_1>, … in upload order.
The number of images to generate.
1The format in which the generated images are returned.
urlPossible values: The aspect ratio of the edited image. When omitted, the output keeps the aspect ratio of the first input image.
The resolution of the output image. A higher resolution costs more.
1kPossible values: The quality of the image that will be generated. medium renders more detail and costs more than low at the same resolution.
lowPossible values: Successful response.
curl --request POST \
--url 'https://api.aimlapi.com/v1/images/edits' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
--header 'Content-Type: application/json' \
--data '{"model": "x-ai/grok-imagine-image-2.0", "prompt": "Describe what you want the model to generate.", "image": "<image>"}'Successful response.
{
"data": [
{
"url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
"b64_json": null
}
],
"meta": {
"usage": {
"credits_used": 120000,
"usd_spent": 0.06
}
}
}Quick Example
Let's generate an image of the specified size using a simple prompt.
We obtained the following 2816x1536 image by running this code example:
Last updated
Was this helpful?