Generate and Edit Images

Create and edit images with OpenAI-compatible image endpoints, supporting multipart and JSON URL inputs.

Overview

Create new images or edit existing images using standard OpenAI image routes, supporting both standard multipart file uploads and nonstreaming JSON image URL inputs for gpt-image-2.

Image Generation

POST/v1/images/generations
  • Canonical endpoint: POST /v1/images/generations (operationId: openai.images.generations) creates images from a text prompt.
  • Generation parameters: Accepts prompt, optional model, n, quality, and size.
  • Compatibility alias: Accepts POST /openai/v1/images/generations (operationId: openai.images.generations.alias).

Image Editing

POST/openai/v1/images/edits
json
{
  "model": "gpt-image-2",
  "prompt": "Combine these reference images into a coherent surreal portrait.",
  "images": [
    { "image_url": "https://cdn.example.com/reference-1.png" },
    { "image_url": "https://cdn.example.com/reference-2.png" }
  ],
  "mask": {
    "image_url": "https://cdn.example.com/mask.png"
  },
  "n": 1,
  "quality": "medium",
  "size": "1024x1024"
}
  • Canonical endpoint: POST /openai/v1/images/edits (operationId: openai.images.edits) with compatibility alias POST /v1/images/edits (operationId: openai.images.edits.alias).
  • Multipart file uploads: Send multipart/form-data with original image file and optional mask file.
  • JSON URL input: For gpt-image-2 and supported native upstreams, send nonstreaming JSON with model, prompt, an images array containing 1 to 16 objects with image_url, and an optional mask object (image_url).
  • Public HTTPS requirements: Image URLs must use public HTTPS without embedded credentials, read directly by the upstream provider.
  • Quality and size parameters: gpt-image-2 defaults quality to medium (low and high are also supported); additional native parameters pass through intact.