> ## 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.

# GPT Image 2 画像生成

> - GPT Image 2（gpt-image-2）モデルはテキストから画像、画像から画像、画像編集などの生成モードに対応
- 非同期処理モード、返却されたタスクIDで[照会](/ja/api-manual/task-management/get-task-detail)
- 生成された画像リンクは24時間有効です、お早めに保存してください



## OpenAPI

````yaml ja/api-manual/image-series/gpt-image-2/gpt-image-2-image-generation.json POST /v1/images/generations
openapi: 3.1.0
info:
  title: gpt-image-2 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: gpt-image-2 API
      description: >-
        - GPT Image 2（gpt-image-2）モデルはテキストから画像、画像から画像、画像編集などの生成モードに対応

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

        - 生成された画像リンクは24時間有効です、お早めに保存してください
      operationId: createImageGenerationGptImage2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              text_to_image:
                summary: テキストから画像（シンプル）
                value:
                  model: gpt-image-2
                  prompt: 海面に広がる色鮮やかな美しい夕焼け
              text_to_image_hd:
                summary: テキストから画像（高精細 16:9）
                value:
                  model: gpt-image-2
                  prompt: 夕暮れ時の未来都市スカイラインのシネマティックなワイドショット
                  size: '16:9'
                  resolution: 4K
                  quality: high
                  'n': 1
              text_to_image_pixel:
                summary: テキストから画像（明示的なピクセル指定）
                value:
                  model: gpt-image-2
                  prompt: ミニマルなロゴデザイン
                  size: 1024x1024
                  quality: medium
              image_edit:
                summary: 画像から画像 / 画像編集
                value:
                  model: gpt-image-2
                  prompt: 彼女の隣に可愛い猫を追加
                  size: '1:1'
                  resolution: 1K
                  quality: medium
                  image_urls:
                    - https://example.com/input.png
                  callback_url: https://your-domain.com/webhook/image-done
              image_inpaint:
                summary: インペインティング（マスク付き）
                value:
                  model: gpt-image-2
                  prompt: 空を星空に置き換えてください
                  size: '1:1'
                  resolution: 1K
                  quality: medium
                  image_urls:
                    - https://example.com/input.png
                  mask_url: https://example.com/mask.png
              batch_generation:
                summary: バッチ生成
                value:
                  model: gpt-image-2
                  prompt: ピクセルアート風の可愛いロボット
                  size: '1:1'
                  resolution: 2K
                  quality: high
                  '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: gpt-image-2'
                  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: 画像生成モデル名、公式チャネル、より優れた安定性と制御性、商用シナリオに適しています
          enum:
            - gpt-image-2
          default: gpt-image-2
          example: gpt-image-2
        prompt:
          type: string
          description: >-
            生成する画像を説明するプロンプト、または入力画像の編集方法を説明するプロンプト


            **制限:**

            - 最大 `32000` 文字（Unicode コードポイント単位、日本語・中国語・韓国語・英語などに対応）

            - プロンプトが `8000` tokens
            を超えると、生成画像が想定と一致しない場合があります。プロンプトを簡潔にすることを推奨します
          example: 海面に広がる色鮮やかな美しい夕焼け
          maxLength: 32000
        image_urls:
          type: array
          description: >-
            画像から画像への変換および画像編集機能のための参照画像URLリスト


            **注意:**

            - リクエストあたりの入力画像数: `1~16` 枚

            - 1 枚あたりのサイズ: `50MB` 以内

            - 1 枚あたりのピクセル数: 幅 × 高さが `178,956,970` px 以内

            - 1 枚あたりの辺の長さ: 幅 / 高さともに `23170` px 以内（超えると異常が発生する可能性があります）

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

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

            - 画像から画像 / 画像編集のシナリオでは、渡された参照画像自体にも追加の画像入力トークン消費が発生します
          items:
            type: string
            format: uri
          example:
            - https://example.com/image1.png
            - https://example.com/image2.png
        mask_url:
          type: string
          format: uri
          description: >-
            インペインティング マスク URL —
            参照画像の再生成したい領域を指定します。**画像編集モードでのみ有効**（`image_urls`
            と併用必須）です。純粋なテキストから画像への生成では、マスクは黙って無視されます。


            **形式要件：**

            - **アルファチャンネル付き PNG である必要があります**：透明ピクセル（`alpha < 255`）=
            再生成領域、不透明ピクセル = 元画像保持

            - **マスクの寸法は参照画像と完全に一致**する必要があります（幅 × 高さ、ピクセル単位）

            - リクエストごとに 1 枚のマスクのみ


            **注意：**

            - `image_urls` に少なくとも 1 枚の参照画像が必要です。マスク単独では効果がありません

            - よくあるエラー：
                - `Invalid mask image format - mask image missing alpha channel`：アップロードされた画像にアルファチャンネルがありません（JPEG、不透明 PNG など）。透明領域のある PNG として再エクスポートしてください。
                - `Invalid mask image format - mask size does not match image size`：マスクのサイズが参照画像と一致しません。参照画像と同じピクセル寸法にリサイズしてください。
          example: https://example.com/mask.png
        size:
          type: string
          description: >-
            生成画像のサイズ。**比率形式**と**明示的ピクセル形式**の両方に対応、デフォルトは `auto`


            **① 比率形式（推奨、15 種類）**


            - `1:1`: 正方形

            - `1:2` / `2:1`: 超縦長 / 横長

            - `1:3` / `3:1`: 極端な縦長 / 横長（3:1 の境界）

            - `2:3` / `3:2`: 標準の縦 / 横

            - `3:4` / `4:3`: クラシックな縦 / 横

            - `4:5` / `5:4`: SNS でよく使われる

            - `9:16` / `16:9`: スマホ / デスクトップのワイド画面

            - `9:21` / `21:9`: ウルトラワイド


            **② 明示的ピクセル形式**: `WxH`（または `W×H`）、例:
            `1024x1024`、`1536x1024`、`3840×2160`


            - 幅・高さはいずれも `16` の整数倍

            - 各辺の範囲: `[16, 3840]`

            - ピクセル予算: `655,360 ≤ width × height ≤ 8,294,400`（約 0.65 MP ~ 8.29
            MP）

            - アスペクト比: `≤ 3:1`


            **③ `auto`**: モデルが自動的にサイズを決定（このとき `resolution` は無効）


            **オーバー時の処理:**

            - 比率 + `resolution` の組み合わせがピクセル予算を超える場合、比率を保ったまま自動的に最大まで縮小されます（例: 4K
            2:1 → 3840×1920）
          default: auto
          example: auto
        resolution:
          type: string
          description: >-
            解像度階層のショートカットパラメータ。`size` が比率形式の場合のみ有効、明示的ピクセル形式ではこのフィールドは無視されます


            **ピクセルバジェット規則**（目標総ピクセル数と `size` の比率から幅と高さを算出、結果は 16 の倍数に揃えられます）:


            - `1K`: ~1 MP（1024² = 1,048,576 ピクセル）

            - `2K`: ~4 MP（2048² = 4,194,304 ピクセル）

            - `4K`: ~8.29 MP（3840×2160 = 8,294,400 ピクセル、上限値）


            **横向き / 正方形の実際の出力サイズ**（縦向きは対応する横向きの幅と高さを入れ替えたもの、例: `2:3` = `3:2`
            の反転）:


            | 比率 | 1K | 2K | 4K |

            |---|---|---|---|

            | `1:1` | 1024×1024 | 2048×2048 | 2880×2880 |

            | `2:1` | 1456×720 | 2896×1456 | 3840×1920 \* |

            | `3:1` | 1776×592 | 3552×1184 | 3840×1280 \* |

            | `3:2` | 1248×832 | 2512×1680 | 3520×2352 |

            | `4:3` | 1184×880 | 2368×1776 | 3312×2480 \* |

            | `5:4` | 1152×912 | 2288×1824 | 3216×2576 |

            | `16:9` | 1360×768 | 2736×1536 | 3840×2160（UHD）|

            | `21:9` | 1568×672 | 3136×1344 | 3840×1632 \* |


            \* はピクセル予算を超えたため比率を保って自動縮小された組み合わせを表します。値は大文字小文字を区別しません。
          enum:
            - 1K
            - 2K
            - 4K
          default: 1K
          example: 1K
        quality:
          type: string
          description: |-
            レンダリング品質。モデルの「思考の深さ」を制御し、出力トークン数と費用に直接影響します。デフォルトは `medium`

            | 値 | タイル基数 | 相対コスト（1024²）|
            |---|---|---|
            | `low` | 16 | ~0.11× |
            | `medium` | 48 | 1.0× |
            | `high` | 96 | ~4.0× |
          enum:
            - low
            - medium
            - high
          default: medium
          example: medium
        'n':
          type: integer
          description: |-
            生成する画像の枚数。各画像は個別に課金されます

            **注意:**
            - テキスト入力トークンは `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: gpt-image-2
        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: 2.5
        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
        ```

````