Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gmicloud.ai/llms.txt

Use this file to discover all available pages before exploring further.

Model ID
gpt-image-2-edit

gpt-image-2-edit API Usage Guide

Overview

gpt-image-2-edit uses OpenAI’s GPT Image 2 model to edit or transform an existing image based on a text prompt. It supports two modes:
  • Image Edit: Modify an image according to a prompt (e.g. change background, style transfer)
  • Inpainting: Edit a specific region of an image using a mask (white pixels are edited, black pixels are preserved)

Authentication

Authorization: Bearer YOUR_API_KEY

Submit Image Edit Request

Endpoint

POST /api/v1/ie/requestqueue/apikey/requests

Image Edit (no mask)

curl -X POST "https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2-edit",
    "payload": {
      "prompt": "Replace the background with a snowy mountain scene",
      "image": "<base64-encoded-image-or-url>",
      "size": "1024x1024",
      "quality": "medium"
    }
  }'

Inpainting (with mask)

curl -X POST "https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2-edit",
    "payload": {
      "prompt": "Paint a rainbow in the sky",
      "image": "<base64-encoded-image-or-url>",
      "mask": "<base64-encoded-mask-same-size-as-image>",
      "size": "1024x1024",
      "quality": "medium"
    }
  }'

Request Parameters

ParameterTypeRequiredDescriptionDefaultConstraints
modelstringYesModel identifier-Must be "gpt-image-2-edit"
payload.promptstringYesText instruction describing the desired edit--
payload.imagestringYesInput image as base64-encoded string or publicly accessible URL-Must be a valid image
payload.maskstringNoMask image for inpainting. White pixels are edited, black pixels are preserved. Must match the dimensions of image.-Same size as input image
payload.sizestring (enum)NoDimensions of the output image"1024x1024""1024x1024", "1024x1536", "1536x1024"
payload.qualitystring (enum)NoImage quality level, affects detail and cost"medium""low", "medium", "high", "auto"
payload.nintegerNoNumber of images to generate1Min: 1, Max: 10

Response

{
  "request_id": "cd5b59d5-1b3f-4fd5-9899-15ecea1f28ba",
  "model": "gpt-image-2-edit",
  "status": "success",
  "outcome": {
    "media_urls": [{"id": "0", "url": "https://storage.googleapis.com/..."}],
    "thumbnail_image_url": "https://storage.googleapis.com/..."
  }
}

Check Request Status

GET /api/v1/ie/requestqueue/apikey/requests/{request_id}