# XAI | Grok | Imagine | 2.0 | Image Edit Edit source images with xAI Grok Imagine Image 2.0 using prompt-guided controls for aspect ratio, resolution, quality, and output count. ## API Information - **Model Slug:** xai-grok-imagine-2-0-image-edit - **Branded URL:** https://www.eachlabs.ai/xai/grok-imagine/xai-grok-imagine-2-0-image-edit - **Provider:** xAI - **Category:** Image to Image - **Output Type:** image - **Status:** active - **Base Cost:** Direct xAI cost from usage.cost_in_usd_ticks. For grok-imagine-image-2.0 edits this includes image input cost plus generated output image cost by resolution/quality. - **Estimated Processing Time:** 70 seconds - **Interactive Demo:** https://www.eachlabs.ai/ai-models/xai-grok-imagine-2-0-image-edit ## Pricing - **Charge Type:** dynamic - **Pricing Details:** Direct xAI cost from usage.cost_in_usd_ticks. For grok-imagine-image-2.0 edits this includes image input cost plus generated output image cost by resolution/quality. ### Pricing Rules | Condition | Pricing | | --- | --- | | Rule 1 | Direct xAI cost from usage.cost_in_usd_ticks. For grok-imagine-image-2.0 edits this includes image input cost plus generated output image cost by resolution/quality. | ## Input Schema | Parameter | Type | Required | Default | Constraints | Description | |-----------|------|----------|---------|-------------|-------------| | prompt | string | Yes | - | - | Text prompt describing the desired image edit. For multi-image edits, reference inputs as , , etc. | | image_url | string | No | - | - | URL or base64 data URI of the source image to edit. Mutually exclusive with image_urls. | | image_urls | array | No | [] | - | One to three source image URLs or base64 data URIs for multi-image edits. Mutually exclusive with image_url. | | num_images | integer | No | 1 | 1–10 | Number of edited images to generate. Each successful output image affects provider cost. | | aspect_ratio | string | No | auto | auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20 | Output aspect ratio. For single-image edits, use auto to follow the source image; for multi-image edits, specify a target ratio when needed. | | resolution | string | No | 1k | 1k, 2k | Output resolution. Higher resolution increases provider cost. | | quality | string | No | medium | low, medium | Output quality for grok-imagine-image-2.0. Higher quality increases provider cost. | | output_format | string | No | jpeg | jpeg, png, webp | Output image format. The pipeline converts the provider image before upload. | ## Example Request ```bash curl -X POST https://api.eachlabs.ai/v1/prediction/ \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai-grok-imagine-2-0-image-edit", "input": { "prompt": "Transform this photo into a split \"half real, half illustrated\" artwork: keep the LEFT half of the image completely untouched — the original photograph, the person's real face, hair, skin and clothing exactly as they are. Convert ONLY the RIGHT half into a bold hand-drawn digital illustration of the same person: thick black outlines, flat warm painterly colors with visible brush and crosshatch texture, slightly stylized cartoon features (expressive eyes with bold lashes, simplified lips, rosy hatched cheek blush), the same hairstyle redrawn as flowing illustrated waves, the same clothing redrawn in flat colors with simple shading. The two halves are divided by a single sweeping curved black line running from the top of the head down through the face and body — the split passes through the middle of the face so one eye is real and one eye is illustrated. Both halves align perfectly: same pose, same proportions, same features, reading as one continuous person. Clean white background behind the illustrated side. Preserve the person's identity, likeness and expression on both sides." } }' ``` ## Output Schema Response returned by `GET /v1/prediction/{id}` when the job completes: ```json { "status": "success", "predictionID": "string", "output": "string (URL of generated image)", "metrics": { "predict_time": "number (seconds)" } } ``` ## Polling ```bash curl https://api.eachlabs.ai/v1/prediction/{PREDICTION_ID} \ -H "Authorization: Bearer YOUR_API_KEY" ``` | Status | Meaning | |--------|---------| | `processing` | Still running — poll again | | `success` | Done — read `output` | | `error` | Failed — read `message` / `details` | ## Webhook (alternative to polling) Pass `"webhook_url": "https://your.host/path"` in the create request. Eachlabs POSTs this payload when the job ends: ```json { "exec_id": "prediction-uuid", "status": "succeeded", "output": "https://...", "error": "" } ``` `status` is `"succeeded"` or `"failed"`. `exec_id` equals the `predictionID` from create. Return 2xx within 30 seconds. ## Errors Error body: `{ "status": "error", "message": "...", "details": "..." }` | Code | Meaning | |------|---------| | `400` | Invalid input | | `401` | Missing / invalid `Authorization` bearer token | | `404` | Unknown model or prediction id | | `429` | Rate limit — 100 creates / min, 10 concurrent per key | | `5xx` | Retry with backoff | ## Overview **XAI | Grok | Imagine | 2.0 | Image Edit Overview** **XAI | Grok | Imagine | 2.0 | Image Edit** is xAI’s image-editing model for changing an existing image with prompt-guided control while preserving the rest of the frame. It is built for workflows where creators need region-specific edits, smart resizing, background removal, and multi-reference composition without manual compositing. The main differentiator is its editing-first design: instead of treating image generation as a one-shot output, the model focuses on precise, localized changes and composition-aware transforms. In xAI’s Imagine family, Image 2.0 is positioned as the quality-oriented image mode with tools such as Magic Wand, Segmentation, and Smart Resize. ## Usage Notes - API Base URL: `https://api.eachlabs.ai/v1` - Authentication: send `Authorization: Bearer YOUR_API_KEY`. Generate a key from the Eachlabs dashboard at https://www.eachlabs.ai/dashboard/api-keys. - File-typed parameters (`*_url`, `image_url`, `video_url`, `audio_url`, etc.) accept publicly-reachable HTTPS URLs only. Upload your asset first (GCS / S3 / your CDN) and pass the resulting URL. Data-URIs and localhost URLs are rejected. - For structured parameters (arrays / objects) send real JSON values, not stringified payloads. - Monetary values are reported in USD; per-token / per-megapixel rates may be billed in micro-cents internally. - Prefer `webhook_url` over polling for long-running predictions — see the Webhook Callback section.