APIMart
Back to models
Grok Imagine 2.0 model icon
ImageImage GenerationText to ImageAsynchronous API

Grok Imagine 2.0 API

The Grok Imagine 2.0 API on APIMart gives you two ways to use xAI's Grok Imagine 2.0 image model: the low-cost grok-imagine-2.0-ext for text to image, ratio redraw, layers and region editing, and the official grok-imagine-image-2.0 for 1K or 2K text to image and editing with up to three reference images.

Generated image 1

Grok Imagine 2.0 API Pricing

Transparent pricing with no hidden fees. Pay only for what you use.

Pricing by specification

VariantTierGoldCurrent pricePlatinumDiamondOfficialYour savings
grok-imagine-2.0-extImage uploadFreeFreeFree——
Standard Generation0.15Credits/pic~$0.015/pic0.1425Credits/pic~$0.0143/pic0.135Credits/pic~$0.0135/pic0.8Credits/pic~$0.08/pic81.2%
Region edit0.15Credits/gen~$0.015/gen0.1425Credits/gen~$0.0143/gen0.135Credits/gen~$0.0135/gen0.1875Credits/gen~$0.0188/gen20%
grok-imagine-image-2.01K low0.32Credits/pic~$0.032/pic0.304Credits/pic~$0.0304/pic0.288Credits/pic~$0.0288/pic0.4Credits/pic~$0.04/pic20%
1K medium0.48Credits/pic~$0.048/pic0.456Credits/pic~$0.0456/pic0.432Credits/pic~$0.0432/pic0.6Credits/pic~$0.06/pic20%
2K low0.48Credits/pic~$0.048/pic0.456Credits/pic~$0.0456/pic0.432Credits/pic~$0.0432/pic0.6Credits/pic~$0.06/pic20%
2K medium0.64Credits/pic~$0.064/pic0.608Credits/pic~$0.0608/pic0.576Credits/pic~$0.0576/pic0.8Credits/pic~$0.08/pic20%
Reference image (each)0.08Credits/pic~$0.008/pic0.076Credits/pic~$0.0076/pic0.072Credits/pic~$0.0072/pic0.1Credits/pic~$0.01/pic20%

* Actual costs are subject to final output.

Grok Imagine 2.0 API Example: Text to Image and Image Editing

Call grok-imagine-image-2.0 on APIMart with one POST request. Generation is asynchronous: submit a task, then poll the task endpoint for the image URLs. The example uses the official grok-imagine-image-2.0; grok-imagine-2.0-ext accepts optional image_urls: an array of up to 5 public HTTP(S) reference image URLs, in selection order. Use an array even for one image. Omit image_urls for text-to-image (n=1–12). With references, use n=1 and omit resolution. This code sends no X-APIMart-Response-Version header, so the submit response is HTTP 200 with data[0].task_id; the docs example sends that header and gets HTTP 202 with data.id.

  1. 1

    Authenticate Grok Imagine 2.0 API requests

    Save the key you created above in the APIMART_API_KEY environment variable and send it as Authorization: Bearer <key> on every request.

  2. 2

    Submit a grok-imagine-image-2.0 task

    POST /v1/images/generations with model grok-imagine-image-2.0, your prompt, aspect_ratio, resolution, quality and n. To edit, add image_urls and drop quality. The task ID is in data[0].task_id.

  3. 3

    Get the Grok Imagine 2.0 result

    Poll GET /v1/tasks/{task_id} until status is completed, then read the image URL from data.result.images[0].url[0]. Results are kept for 72 hours. Failed tasks are not charged.

    See the Grok Imagine 2.0 API reference for every parameter and response field.

POST /v1/images/generations
curl -X POST https://api.apimart.ai/v1/images/generations \
  -H "Authorization: Bearer $APIMART_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-image-2.0",
    "prompt": "Minimal product photography of a white ceramic cup on a stone surface, soft window light, clean background",
    "n": 1,
    "aspect_ratio": "16:9",
    "resolution": "2k",
    "quality": "medium"
  }'

Grok Imagine 2.0 API Parameters

ParameterTypeRequiredDefaultDescription
modelstringRequiredDefault: grok-imagine-image-2.0grok-imagine-image-2.0. The same model handles text to image and editing.
promptstringRequiredDefault: —Image description, or the edit instruction when image_urls is set. Up to 8,000 characters.
aspect_ratiostringOptionalDefault: autoAspect ratio: auto, 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1.
resolutionstringOptionalDefault: 1kOutput resolution: 1k or 2k. The price depends on resolution and quality.
qualitystringOptionalDefault: mediumText to image only: low or medium. Do not send it when image_urls is present.
nintegerOptionalDefault: 1Number of images, 1–10.
image_urlsarrayOptionalDefault: —Reference images for editing, 1–3 public HTTP(S) URLs. Omit the field for text to image.
nsfw_checkbooleanOptionalDefault: falseSet true to moderate the prompt and input images before the task is submitted.