> ## Documentation Index
> Fetch the complete documentation index at: https://evolink.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Imagine Image 2.0 Image Generation

> - Grok Imagine Image 2.0 (grok-imagine-image-2.0) is xAI's image generation and editing model — text-to-image and image editing share the same model name
- Omit `image_urls` for text-to-image; pass `1~3` reference images and it automatically switches to image editing, no model change needed
- Asynchronous processing mode, use the returned task ID to [query](/en/api-manual/task-management/get-task-detail)
- Generated image links are valid for 24 hours, please save them promptly



## OpenAPI

````yaml en/api-manual/image-series/grok/grok-imagine-image-2.0-image-generate.json POST /v1/images/generations
openapi: 3.1.0
info:
  title: grok-imagine-image-2.0 API
  description: >-
    Create image tasks using AI models with support for multiple models and
    parameter configurations
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.evolink.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Image Generation
    description: AI image generation related APIs
paths:
  /v1/images/generations:
    post:
      tags:
        - Image Generation
      summary: grok-imagine-image-2.0 API
      description: >-
        - Grok Imagine Image 2.0 (grok-imagine-image-2.0) is xAI's image
        generation and editing model — text-to-image and image editing share the
        same model name

        - Omit `image_urls` for text-to-image; pass `1~3` reference images and
        it automatically switches to image editing, no model change needed

        - Asynchronous processing mode, use the returned task ID to
        [query](/en/api-manual/task-management/get-task-detail)

        - Generated image links are valid for 24 hours, please save them
        promptly
      operationId: createImageGenerationGrokImagineImage2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              text_to_image:
                summary: Text to Image (simple)
                value:
                  model: grok-imagine-image-2.0
                  prompt: >-
                    Cyberpunk Tokyo street at night, neon lights reflecting on
                    the wet pavement
              text_to_image_hd:
                summary: Text to Image (2K widescreen)
                value:
                  model: grok-imagine-image-2.0
                  prompt: Cinematic wide shot of a futuristic city skyline at dusk
                  size: '16:9'
                  resolution: 2K
                  quality: medium
              image_edit:
                summary: Image editing (single reference image)
                value:
                  model: grok-imagine-image-2.0
                  prompt: Change the season in the scene to a snowy winter
                  size: '1:1'
                  resolution: 1K
                  quality: medium
                  image_urls:
                    - https://example.com/input.png
                  callback_url: https://your-domain.com/webhook/image-done
              multi_image_edit:
                summary: Multi-image editing (reference syntax)
                value:
                  model: grok-imagine-image-2.0
                  prompt: >-
                    Place the person from <IMAGE_0> into the scene of <IMAGE_1>,
                    keeping the lighting consistent
                  size: '16:9'
                  resolution: 1K
                  quality: medium
                  image_urls:
                    - https://example.com/person.png
                    - https://example.com/scene.png
              batch_generation:
                summary: Batch generation (fast tier)
                value:
                  model: grok-imagine-image-2.0
                  prompt: A cute robot in pixel art style
                  size: '1:1'
                  resolution: 1K
                  quality: low
                  'n': 4
      responses:
        '200':
          description: Image generation task created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_request
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: Unauthenticated, invalid or expired token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: unauthorized
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: Insufficient quota, recharge required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: insufficient_quota
                  message: Insufficient quota. Please top up your account.
                  type: insufficient_quota
        '403':
          description: Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: model_access_denied
                  message: 'Token does not have access to model: grok-imagine-image-2.0'
                  type: invalid_request_error
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: rate_limit_exceeded
                  message: Too many requests, please try again later
                  type: rate_limit_error
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: internal_error
                  message: Internal server error
                  type: api_error
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: >-
            Image generation model name. Text-to-image and image editing share
            this model name; the mode switches automatically depending on
            whether `image_urls` is provided
          enum:
            - grok-imagine-image-2.0
          example: grok-imagine-image-2.0
        prompt:
          type: string
          description: >-
            Prompt describing the image you want to generate, or how to edit the
            reference images you provide


            **Multi-image reference syntax:**

            - When passing multiple reference images, use `<IMAGE_0>`,
            `<IMAGE_1>`, `<IMAGE_2>` in the prompt to refer to the 1st, 2nd and
            3rd reference image respectively

            - Indexes start at `0` and map one-to-one to the order of the
            `image_urls` array

            - Example: `Place the person from <IMAGE_0> into the scene of
            <IMAGE_1>`
          example: >-
            Cyberpunk Tokyo street at night, neon lights reflecting on the wet
            pavement
        image_urls:
          type: array
          description: >-
            Reference image URL list for image-to-image and image editing
            functions


            **Note:**

            - Number of input images per request: `0~3` (omitted =
            text-to-image, `1~3` = image editing)

            - Only publicly accessible `http` / `https` image URLs are
            supported; base64 and data URLs are not supported

            - Supported file formats: `.jpeg`, `.jpg`, `.png`, `.webp`

            - Image URLs must be directly accessible by the server, or the image
            URL should directly download when accessed (typically these URLs end
            with image file extensions, such as `.png`, `.jpg`)

            - In image editing scenarios the reference images incur an
            additional charge, counted once per request and not multiplied by
            `n`
          items:
            type: string
            format: uri
          maxItems: 3
          example:
            - https://example.com/person.png
            - https://example.com/scene.png
        size:
          type: string
          description: >-
            Aspect ratio of the generated image, defaults to `auto`


            **Supported ratios (13):**


            | Ratio | Description |

            |---|---|

            | `1:1` | Square |

            | `4:3` / `3:4` | Classic landscape / portrait |

            | `3:2` / `2:3` | Standard landscape / portrait |

            | `16:9` / `9:16` | Widescreen / mobile portrait |

            | `2:1` / `1:2` | Ultra-wide / ultra-tall |

            | `19.5:9` / `9:19.5` | Full-screen phone landscape / portrait |

            | `20:9` / `9:20` | Ultra-wide landscape / portrait |


            **Note:**

            - `auto`: the model decides the ratio itself; omitting this
            parameter is equivalent to `auto` (output is usually portrait)

            - Values outside the table above are not supported
          enum:
            - '1:1'
            - '4:3'
            - '3:4'
            - '3:2'
            - '2:3'
            - '16:9'
            - '9:16'
            - '2:1'
            - '1:2'
            - 19.5:9
            - '9:19.5'
            - '20:9'
            - '9:20'
            - auto
          default: auto
          example: '16:9'
        resolution:
          type: string
          description: >-
            Pixel tier of the output image, defaults to `1K`; supports the `1K`
            and `2K` tiers


            **Note:**

            - This model does not support `4K`

            - Values are case-insensitive
          enum:
            - 1K
            - 2K
          default: 1K
          example: 1K
        quality:
          type: string
          description: >-
            Generation quality tier, controls how deeply the model thinks,
            defaults to `medium`


            | Value | Description |

            |---|---|

            | `low` | Faster output, lower cost |

            | `medium` | Better image quality and detail |


            **Note:**

            - This model only supports the `low` / `medium` tiers; other values
            such as `high` are not supported

            - `quality` (quality tier) and `resolution` (pixel tier) are
            independent and can be combined freely

            - Values are case-insensitive
          enum:
            - low
            - medium
          default: medium
          example: medium
        'n':
          type: integer
          description: >-
            Number of images to generate, range `1~10`, defaults to `1`


            **Note:**

            - Each image is billed independently, cost grows linearly with `n`

            - The additional charge for reference images is counted once per
            request and is not multiplied by `n`

            - When the task completes, `result_urls` returns `n` independent
            image links
          minimum: 1
          maximum: 10
          default: 1
          example: 1
        callback_url:
          type: string
          description: >-
            HTTPS callback address after task completion


            **Callback Timing:**

            - Triggered when task is completed, failed, or cancelled

            - Sent after billing confirmation is completed


            **Security Restrictions:**

            - Only HTTPS protocol is supported

            - Callback to internal IP addresses is prohibited (127.0.0.1,
            10.x.x.x, 172.16-31.x.x, 192.168.x.x, etc.)

            - URL length must not exceed `2048` characters


            **Callback Mechanism:**

            - Timeout: `10` seconds

            - Maximum `3` retries on failure (retries after `1` second/`2`
            seconds/`4` seconds)

            - Callback response body format is consistent with the task query
            API response format

            - Callback address returning 2xx status code is considered
            successful, other status codes will trigger retry
          format: uri
          example: https://your-domain.com/webhooks/image-task-completed
    ImageGenerationResponse:
      type: object
      properties:
        created:
          type: integer
          description: Task creation timestamp
          example: 1757156493
        id:
          type: string
          description: Task ID
          example: task-unified-1757156493-imcg5zqt
        model:
          type: string
          description: Actual model name used
          example: grok-imagine-image-2.0
        object:
          type: string
          enum:
            - image.generation.task
          description: Specific task type
        progress:
          type: integer
          description: Task progress percentage (0-100)
          minimum: 0
          maximum: 100
          example: 0
        status:
          type: string
          description: Task status
          enum:
            - pending
            - processing
            - completed
            - failed
          example: pending
        task_info:
          $ref: '#/components/schemas/TaskInfo'
          description: Asynchronous task information
        type:
          type: string
          enum:
            - text
            - image
            - audio
            - video
          description: Task output type
          example: image
        usage:
          $ref: '#/components/schemas/Usage'
          description: Usage and billing information
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code identifier
            message:
              type: string
              description: Error description
            type:
              type: string
              description: Error type
    TaskInfo:
      type: object
      properties:
        can_cancel:
          type: boolean
          description: Whether the task can be cancelled
          example: true
        estimated_time:
          type: integer
          description: Estimated completion time (seconds)
          minimum: 0
          example: 100
    Usage:
      type: object
      description: Usage and billing information
      properties:
        billing_rule:
          type: string
          description: Billing rule
          enum:
            - per_call
            - per_token
            - per_second
          example: per_call
        credits_reserved:
          type: number
          description: Estimated credits consumed
          minimum: 0
          example: 3.06
        user_group:
          type: string
          description: User group category
          example: default
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All APIs require Bearer Token authentication##


        **Get API Key:**


        Visit [API Key Management Page](https://evolink.ai/dashboard/keys) to
        get your API Key


        **Add to request header:**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````