> ## 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 画像生成

> - Grok Imagine Image 2.0（grok-imagine-image-2.0）は xAI の画像生成・画像編集モデルで、テキストから画像への生成と画像編集が同じモデル名を共有します
- `image_urls` を指定しない場合はテキストから画像への生成、`1~3` 枚の参照画像を渡すと自動的に画像編集モードに切り替わります（モデルの切り替えは不要）
- 非同期処理モード、返却されたタスクIDで[照会](/ja/api-manual/task-management/get-task-detail)
- 生成された画像リンクは24時間有効です、お早めに保存してください



## OpenAPI

````yaml ja/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: AIモデルを使用して画像タスクを作成、複数のモデルとパラメータ設定に対応
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.evolink.ai
    description: 本番環境
security:
  - bearerAuth: []
tags:
  - name: 画像生成
    description: AI画像生成関連のAPI
paths:
  /v1/images/generations:
    post:
      tags:
        - 画像生成
      summary: grok-imagine-image-2.0 API
      description: >-
        - Grok Imagine Image 2.0（grok-imagine-image-2.0）は xAI
        の画像生成・画像編集モデルで、テキストから画像への生成と画像編集が同じモデル名を共有します

        - `image_urls` を指定しない場合はテキストから画像への生成、`1~3`
        枚の参照画像を渡すと自動的に画像編集モードに切り替わります（モデルの切り替えは不要）

        -
        非同期処理モード、返却されたタスクIDで[照会](/ja/api-manual/task-management/get-task-detail)

        - 生成された画像リンクは24時間有効です、お早めに保存してください
      operationId: createImageGenerationGrokImagineImage2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              text_to_image:
                summary: テキストから画像（シンプル）
                value:
                  model: grok-imagine-image-2.0
                  prompt: サイバーパンク風の夜の東京の街並み、濡れた路面に映るネオンの光
              text_to_image_hd:
                summary: テキストから画像（2K ワイド）
                value:
                  model: grok-imagine-image-2.0
                  prompt: 夕暮れ時の未来都市スカイラインのシネマティックなワイドショット
                  size: '16:9'
                  resolution: 2K
                  quality: medium
              image_edit:
                summary: 画像編集（参照画像 1 枚）
                value:
                  model: grok-imagine-image-2.0
                  prompt: シーンの季節を雪の降る冬に変更してください
                  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: 複数画像編集（参照構文）
                value:
                  model: grok-imagine-image-2.0
                  prompt: <IMAGE_0> の人物を <IMAGE_1> のシーンに配置し、光の雰囲気を揃えてください
                  size: '16:9'
                  resolution: 1K
                  quality: medium
                  image_urls:
                    - https://example.com/person.png
                    - https://example.com/scene.png
              batch_generation:
                summary: バッチ生成（高速レベル）
                value:
                  model: grok-imagine-image-2.0
                  prompt: ピクセルアート風の可愛いロボット
                  size: '1:1'
                  resolution: 1K
                  quality: low
                  'n': 4
      responses:
        '200':
          description: 画像タスクが正常に作成されました
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
        '400':
          description: リクエストパラメータが無効です
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_request
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: 未認証、トークンが無効または期限切れ
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: unauthorized
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: 残高不足、チャージが必要です
          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: アクセスが拒否されました
          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: リクエスト頻度制限を超えました
          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: サーバー内部エラー
          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_urls`
            の有無によってモードが自動的に切り替わります
          enum:
            - grok-imagine-image-2.0
          example: grok-imagine-image-2.0
        prompt:
          type: string
          description: >-
            生成したい画像、または渡した参照画像の編集方法を記述するプロンプト


            **複数画像の参照構文:**

            - 複数の参照画像を渡す場合、プロンプト内で `<IMAGE_0>`、`<IMAGE_1>`、`<IMAGE_2>` を使って 1
            枚目・2 枚目・3 枚目の参照画像をそれぞれ指定できます

            - インデックスは `0` から始まり、`image_urls` 配列の順序と 1 対 1 で対応します

            - 例: `<IMAGE_0> の人物を <IMAGE_1> のシーンに配置してください`
          example: サイバーパンク風の夜の東京の街並み、濡れた路面に映るネオンの光
        image_urls:
          type: array
          description: >-
            画像から画像への変換および画像編集機能のための参照画像URLリスト


            **注意:**

            - リクエストあたりの入力画像数: `0~3` 枚（指定なし = テキストから画像への生成、`1~3` 枚 = 画像編集）

            - 公開ネットワークから直接アクセスできる `http` / `https` の画像URLのみ対応。base64 および data
            URL は非対応です

            - サポートされるファイル形式: `.jpeg`、`.jpg`、`.png`、`.webp`

            -
            画像URLはサーバーから直接アクセス可能であるか、アクセス時に直接ダウンロードする必要があります（通常、これらのURLは`.png`、`.jpg`などの画像ファイル拡張子で終わります）

            - 画像編集の場合、渡した参照画像には追加費用が発生します。費用はリクエストごとに 1 回のみ計上され、`n` 倍にはなりません
          items:
            type: string
            format: uri
          maxItems: 3
          example:
            - https://example.com/person.png
            - https://example.com/scene.png
        size:
          type: string
          description: |-
            生成画像のアスペクト比。デフォルトは `auto`

            **対応する比率（13 種類）:**

            | 比率 | 説明 |
            |---|---|
            | `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`: モデルが比率を自動的に決定します。パラメータを指定しない場合は `auto` と同等です（出力は通常縦長になります）
            - 上表以外の値には非対応です
          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: |-
            出力画像のピクセルレベル。デフォルトは `1K` で、`1K` と `2K` の 2 段階に対応

            **注意:**
            - 本モデルは `4K` に非対応です
            - 値は大文字小文字を区別しません
          enum:
            - 1K
            - 2K
          default: 1K
          example: 1K
        quality:
          type: string
          description: |-
            生成品質のレベル。モデルの思考の深さを制御します。デフォルトは `medium`

            | 値 | 説明 |
            |---|---|
            | `low` | 生成が速く、コストが低い |
            | `medium` | 画質とディテールがより優れる |

            **注意:**
            - 本モデルは `low` / `medium` の 2 段階のみ対応。`high` などの値には非対応です
            - `quality`（品質レベル）と `resolution`（ピクセルレベル）は互いに独立しており、自由に組み合わせられます
            - 値は大文字小文字を区別しません
          enum:
            - low
            - medium
          default: medium
          example: medium
        'n':
          type: integer
          description: |-
            生成する画像の枚数。範囲は `1~10`、デフォルトは `1`

            **注意:**
            - 画像ごとに個別に課金され、費用は `n` に比例して増加します
            - 参照画像による追加費用はリクエストごとに 1 回のみ計上され、`n` 倍にはなりません
            - タスク完了後、`result_urls` には互いに独立した `n` 個の画像リンクが返されます
          minimum: 1
          maximum: 10
          default: 1
          example: 1
        callback_url:
          type: string
          description: >-
            タスク完了後の HTTPS コールバックアドレス


            **コールバックタイミング：**

            - タスクが完了、失敗、またはキャンセルされた時にトリガーされます

            - 課金確認完了後に送信されます


            **セキュリティ制限：**

            - HTTPS プロトコルのみサポート

            - 内部 IP アドレスへのコールバックは禁止（127.0.0.1、10.x.x.x、172.16-31.x.x、192.168.x.x
            など）

            - URL の長さは `2048` 文字以内


            **コールバックメカニズム：**

            - タイムアウト：`10` 秒

            - 失敗時最大 `3` 回リトライ（`1` 秒/`2` 秒/`4` 秒後にリトライ）

            - コールバックレスポンスボディの形式はタスククエリ API のレスポンス形式と一致

            - コールバックアドレスが 2xx ステータスコードを返した場合は成功とみなされ、その他のステータスコードはリトライをトリガーします
          format: uri
          example: https://your-domain.com/webhooks/image-task-completed
    ImageGenerationResponse:
      type: object
      properties:
        created:
          type: integer
          description: タスク作成タイムスタンプ
          example: 1757156493
        id:
          type: string
          description: タスクID
          example: task-unified-1757156493-imcg5zqt
        model:
          type: string
          description: 実際に使用されたモデル名
          example: grok-imagine-image-2.0
        object:
          type: string
          enum:
            - image.generation.task
          description: 具体的なタスクタイプ
        progress:
          type: integer
          description: タスク進行状況のパーセンテージ (0-100)
          minimum: 0
          maximum: 100
          example: 0
        status:
          type: string
          description: タスクステータス
          enum:
            - pending
            - processing
            - completed
            - failed
          example: pending
        task_info:
          $ref: '#/components/schemas/TaskInfo'
          description: 非同期タスク情報
        type:
          type: string
          enum:
            - text
            - image
            - audio
            - video
          description: タスクの出力タイプ
          example: image
        usage:
          $ref: '#/components/schemas/Usage'
          description: 使用量と課金情報
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: エラーコード識別子
            message:
              type: string
              description: エラー説明
            type:
              type: string
              description: エラータイプ
    TaskInfo:
      type: object
      properties:
        can_cancel:
          type: boolean
          description: タスクがキャンセル可能かどうか
          example: true
        estimated_time:
          type: integer
          description: 予想完了時間（秒）
          minimum: 0
          example: 100
    Usage:
      type: object
      description: 使用量と課金情報
      properties:
        billing_rule:
          type: string
          description: 課金ルール
          enum:
            - per_call
            - per_token
            - per_second
          example: per_call
        credits_reserved:
          type: number
          description: 予想消費クレジット数
          minimum: 0
          example: 3.06
        user_group:
          type: string
          description: ユーザーグループカテゴリ
          example: default
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##すべてのAPIにBearer Token認証が必要です##

        **APIキーの取得：**

        [APIキー管理ページ](https://evolink.ai/dashboard/keys)にアクセスしてAPIキーを取得してください

        **リクエストヘッダーに追加：**
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

````