Skip to content

GPT Image: edit image

POST/v1/images/edits

Create or edit an image from one or more reference images with the GPT Image series; results return in the same request.

Models and limits

ModelRule groupEndpointsnReference imagesprompt limit (chars)
gpt-image-2GPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.5GPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.5-flareGPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.5-sunburstGPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.6GPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.6-flareGPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000
gpt-image-2.6-sunburstGPT Image series/v1/images/generations/v1/images/edits/v1/images/tasks1–41–16images on edits only32,000

Headers

  • AuthorizationstringRequired

    Bearer <API_KEY>.

  • Content-TypestringRequired

    application/json. Only JSON bodies are supported.

Request bodyJSON

  • modelstringRequired

    A GPT Image model ID, case-sensitive. Available models are listed below.

    GPT Image series
    gpt-image-2gpt-image-2.5gpt-image-2.5-flaregpt-image-2.5-sunburstgpt-image-2.6gpt-image-2.6-flaregpt-image-2.6-sunburst
  • promptstringRequired

    Describe what to change and which subject, composition or details to keep.

    Must not be empty; up to 32,000 characters.

  • imagesobject[]Required

    Reference images, 1–16.

    Limits

    • A publicly reachable https:// image URL, or asset://<asset ID> from your asset library (owned by the API key’s user).
    • PNG, JPEG or WebP. The URL must not depend on cookies, auth headers, hotlink protection or short-lived signatures.
    Show child fields (1)
    • image_urlstringRequired

      Reference image URL.

  • nintegerOptionalDefault 1

    Supports 1–4.

    Billed as per-image price × count, reserved from n at submission.

  • sizestringOptional

    Omit to let the model choose. Common dimensions are listed below. Other sizes are handled according to model capability; check the returned image for its actual dimensions.

    Use a lowercase x between width and height, not ×.

    Supported values

    • 1024x10241:1
    • 1536x10243:2
    • 1024x15362:3
  • response_formatstringOptional

    Omit or send url, then read the image from the returned data.

Returns

HTTP 200 with the list of images.

mask, input_fidelity and multipart file uploads are not supported; do not send them.

  • createdintegerOptional

    Creation time in Unix seconds.

  • dataobject[]Optional

    Generated images, one per item.

    Show child fields (4)
    • urlstringOptional

      Download URL. Use it as returned and save the image promptly; do not send your API key when downloading.

    • b64_jsonstringOptional

      Base64 image data, which may be returned instead of url. Decode it to save.

    • revised_promptstringOptional

      The prompt the model used, when present.

    • width / height / sizeinteger / stringOptional

      Image dimensions, as width and height or WxH, when present.

  • output_formatstringOptional

    File format, when present.

  • usageobjectOptional

    Token usage, for reference only. Usage logs show the actual charge.

Errors

Errors return {"error": {"message": "...", "type": "...", "code": "..."}}.

HTTPcodeCause and action
400—Invalid parameters such as missing model, n above 128 or × in size; see error.message.
400asset_reference_not_foundThe asset:// asset does not exist or is not yours.
401—The API key is invalid, expired or disabled.
403insufficient_user_quotaInsufficient balance or key quota.
403—The key does not allow this model, or the IP is restricted.
429—Rate limited; retry later.
503model_not_foundNo channel is available for the model, or editing is not enabled for it.
524—Gateway timeout while waiting (an HTML page). The image may still be generated and billed; check usage logs before retrying, or use asynchronous image tasks.
Repaint a reference as watercolor
curl -X POST https://ling-light.com/v1/images/edits \
  -H "Authorization: Bearer $LINGLIGHT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2.6",
  "prompt": "Keep the subject and composition, repaint as a watercolor",
  "images": [
    {
      "image_url": "https://media.example.com/images/reference.png"
    }
  ],
  "n": 1,
  "size": "1024x1024"
}'
const response = await fetch('https://ling-light.com/v1/images/edits', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "gpt-image-2.6",
    "prompt": "Keep the subject and composition, repaint as a watercolor",
    "images": [
      {
        "image_url": "https://media.example.com/images/reference.png"
      }
    ],
    "n": 1,
    "size": "1024x1024"
  }),
})
console.log(response.status, await response.json())
import os

import requests

response = requests.post(
    "https://ling-light.com/v1/images/edits",
    headers={
        "Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
    },
    json={
        "model": "gpt-image-2.6",
        "prompt": "Keep the subject and composition, repaint as a watercolor",
        "images": [
            {
                "image_url": "https://media.example.com/images/reference.png",
            },
        ],
        "n": 1,
        "size": "1024x1024",
    },
    timeout=60,
)
print(response.status_code, response.json())
Response
{
  "created": 1795660800,
  "data": [
    {
      "url": "https://media.example.com/images/example.png",
      "width": 1024,
      "height": 1024
    }
  ],
  "output_format": "png",
  "usage": {
    "input_tokens": 20,
    "output_tokens": 1056,
    "total_tokens": 1076
  }
}
API reference overview
Authentication, media URLs, idempotency and errors.
Integration guide
The full flow from API key to downloaded result.
Last updated