Skip to main content
POST
GPT Image
Parameters and usage are aligned with the official implementation. For detailed parameters, refer directly to the official documentation.

Endpoint

  • https://{api_domain}/openai/v1/images/generations
  • https://{api_domain}/openai/v1/images/edits
BaseURL:
  • https://{api_domain}/openai/v1

Supported Models

  • gpt-image-2
  • gpt-image-2-oai
  • gpt-image-2.5-sunburst-oai
  • gpt-image-2.5-flare-oai

Description

This endpoint is compatible with the OpenAI Image API and currently supports image generation and image editing. For detailed parameters, refer to the official OpenAI documentation:
  • OpenAI Official Image Generation Guide
  • Images generate
  • Images edit
  • Image generation requests use application/json.
  • Image editing supports multipart/form-data file uploads as well as application/json, with image references passed via the images array; a JSON example is provided below.
  • It is recommended to explicitly set size and quality to control image quality and cost. Fees are calculated based on actual Token usage and model pricing; usage can be viewed in the usage field of the response.

Models and Parameters

  • Use gpt-image-2.5-sunburst-oai for fine-grained image editing, or gpt-image-2.5-flare-oai for fast image generation. Use the full names listed above in the model field of your requests.
  • For 2.5, quality accepts low / medium / high / xhigh / max / auto, with a default of auto; GPT Image 2 does not support the newly added xhigh / max.
  • To generate images with a transparent background, set background="transparent" and use output_format="png" or "webp".
  • Set the image size via size, for example 1024x1024, 1536x1024, or 1024x1536. For constraints on custom sizes and the full parameter description, refer to the official documentation.

REST API

1. Image Generation

2. Image Editing

For multi-image reference editing, you can pass image[] multiple times:

3. Image Editing (JSON)

Replace {base64_image} with the Base64 encoding of the input PNG image.

OpenAI SDK

Python

Image editing:

Node.js

Image editing:

Best Practices

moderation Parameter

  • moderation="auto" is the default standard filtering; moderation="low" indicates more lenient filtering.
  • moderation can be used in both image generation and image editing requests.