APIMart
Grok Imagine 2.0 model icon
Image

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.

Image GenerationText to ImageAsynchronous API

Service Highlights

  • Official Discounts
  • Pay-as-you-go
  • Fast & Low Latency
Input
115
Output
Generated 1

Image link valid for 72 hours

Grok Imagine 2.0 API Pricing

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

VariantTierGoldCurrent pricePlatinumDiamondOfficialYour savings
grok-imagine-2.0-extImage uploadFreeFreeFree——
Standard Generation0.15Credits(~$0.015)/pic0.1425Credits(~$0.0143)/pic0.135Credits(~$0.0135)/pic0.6Credits(~$0.06)/pic75%
Region edit0.15Credits(~$0.015)/gen0.1425Credits(~$0.0143)/gen0.135Credits(~$0.0135)/gen0.1875Credits(~$0.0188)/gen20%
grok-imagine-image-2.01K low0.32Credits(~$0.032)/pic0.304Credits(~$0.0304)/pic0.288Credits(~$0.0288)/pic0.4Credits(~$0.04)/pic20%
1K medium0.48Credits(~$0.048)/pic0.456Credits(~$0.0456)/pic0.432Credits(~$0.0432)/pic0.6Credits(~$0.06)/pic20%
2K low0.48Credits(~$0.048)/pic0.456Credits(~$0.0456)/pic0.432Credits(~$0.0432)/pic0.6Credits(~$0.06)/pic20%
2K medium0.64Credits(~$0.064)/pic0.608Credits(~$0.0608)/pic0.576Credits(~$0.0576)/pic0.8Credits(~$0.08)/pic20%
Reference image (each)0.08Credits(~$0.008)/pic0.076Credits(~$0.0076)/pic0.072Credits(~$0.0072)/pic0.1Credits(~$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; for Ext, set model to grok-imagine-2.0-ext with n up to 12 and no reference images. 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.