Beta OpenAI Images Edits API
https://hsyunapi.hszl-bd.cn/openai/images/edits
https://hsyunapi.hszl-bd.cn/v1/images/edits
OpenAI image editing API, input images and instructions, output modified images.
Request Headers
acceptstring
Specify the response format, only supporting `application/json`.
Please select
Content-Typestring
Use `multipart/form-data` to upload image files, or use `application/json` to reference images via URL (extended mode; JSON mode does not support direct upload of file bytes).
Please select
authorizationstring
Bearer token
Request Body
imagestring | arrayRequired parameter
Reference image URL. Accepts a single URL string or an array of URL strings (up to 16 for the GPT Image series models, `dall-e-2` supports only 1). The JSON mode **does not** accept uploaded file bytes—if you need to upload files directly, please use `multipart/form-data`.
promptstringRequired parameter
Describe the text of the desired editing effect. `dall-e-2` up to 1000 characters, GPT Image series models up to 32000 characters.
modelstring
Model used for image editing. Supports `dall-e-2`, `dall-e-3`, the GPT Image series (`gpt-image-1`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`), and the Google Nano Banana series (`nano-banana`, `nano-banana-2-lite`, `nano-banana-2`, `nano-banana-2.1`, `nano-banana-pro`). `gpt-image-2` provides `gpt-image-2:official` (official channel, stable and compliant, billed based on the actual Token usage of text input, image input, and image output) and `gpt-image-2:reverse` (equivalent to the default `gpt-image-2`, with better cost-effectiveness); `gpt-image-2.5-flare` and `gpt-image-2.5-sunburst` also respectively provide `:official` variants with the same names, billed based on actual Token usage. GPT Image 2.6 supports `gpt-image-2.6-flare`, `gpt-image-2.6-sunburst`, and their respective `:reverse` and `:official` variants; the standard version and `:reverse` are 0.22 Credits/image, while `:official` is the same as 2.5, billed based on actual Token usage.
Please select
ninteger
Number of images to generate (1-10). `dall-e-3` is fixed at `1`. The `dall-e-2`, `gpt-image-1` / `gpt-image-1.5` / `gpt-image-2` / `gpt-image-2.5-flare` / `gpt-image-2.5-sunburst` series, as well as the `nano-banana` / `nano-banana-2-lite` / `nano-banana-2` / `nano-banana-2.1` / `nano-banana-pro` series all support `n>1`: the default model and `:reverse` are billed based on the number of successfully generated images, while `:official` is charged based on the actual Token usage aggregated across the entire response, without being multiplied repeatedly by `n`. Note that `response_format=b64_json` only supports `n=1`; when `n>1`, please use the default URL return. If some images fail to generate, only the successful ones will be returned and billed.
qualitystring
Image quality. GPT Image models support `auto` (default), `low`, `medium`, `high`; `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`, `gpt-image-2.6-flare`, and `gpt-image-2.6-sunburst` (including `:official` variants) additionally support `xhigh`, `max`. Official channels are billed based on actual Token usage.
Please select
output_formatstring
Output formats: png, jpeg, webp; GPT Image 2.6 Flare/Sunburst (including :reverse, :official) supports native GIF, preserving animation frames and duration. SVG is not yet available.
Please select
sizestring
Image size, in the format `WIDTHxHEIGHT`, or `auto`. **The GPT Image 2 series (`gpt-image-2`, `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`, `gpt-image-2.6-flare`, `gpt-image-2.6-sunburst`)** accepts any `WIDTHxHEIGHT` value that conforms to this format, including 1K presets (`1024x1024`, `1536x1024`, `1024x1536`, `1792x1024`, `1024x1792`), 2K presets (`2048x2048`, `2048x1536`, `1536x2048`, `2048x1152`, `1152x2048`), 4K presets (`2880x2880`, `3264x2448`, `2448x3264`, `3840x2160`, `2160x3840`), and custom sizes; the default model and `:reverse` are billed per image, while only the size and quality of `:official` affect Token usage and are billed based on actual usage. Size limits: custom sizes must be multiples of 16, the long side must be ≤ 3840, the total pixel count must be 655,360–8,294,400, and the aspect ratio must not exceed 3:1. `dall-e-2` supports: `256x256`, `512x512`, `1024x1024`. Omitting the `size` field is completely equivalent to explicitly passing `auto`: the GPT Image 2 series first identifies explicit pixels, aspect ratio, landscape/portrait orientation, resolution tier (such as 4K / high-res), or named canvas from the prompt; when size intent is identified, it uses the planned specific size, and when the prompt has no size requirement or automatic determination is unavailable, it falls back to the size of the first reference image. The final size is normalized to the above limits; if absolute control is required, directly pass `WIDTHxHEIGHT`. Static image generation and editing in GPT Image 2.6 support the above 4K pixel presets; pass specific pixels such as `size: "3840x2160"`, and do not use `4K` as a size value. When GIF omits size or passes auto, it uses the `512x512` preview preset; it is recommended to use `size: "512x512"`, `frame_count: 9`, `frame_duration_ms: 200`. GIF size and frame count have separate limits, and static 4K specifications cannot be applied directly; some models may adjust the actual GIF size.
backgroundstring
Only applicable to the GPT Image series models. Transparency handling methods: `transparent` (transparent), `opaque` (opaque), or `auto` (automatic).
Please select
output_compressioninteger
Compression level (0-100%) when outputting `webp` or `jpeg`.
asyncboolean
Whether to process in asynchronous mode. When set to `true`, the interface immediately returns `task_id`, without the need to provide `callback_url`, and then the result can be obtained by polling the corresponding task query interface; if `callback_url` is also provided, the result will be pushed to that callback address.
Please select
markupstring | object
GPT Image 2.6 static editing annotation layer, transparent PNG, containing transparent pixels, with the same dimensions as the first reference image after orientation correction; each of the two images must not exceed 16,777,216 pixels, and the annotation image must be at most 40MB. JSON accepts an HTTPS URL, a PNG data URL, or an object containing only image_url; multipart accepts a file or HTTPS URL. Cannot be used together with mask, GIF, or prompt_rewriter; file_id is not supported.
complexitystring
GPT Image 2.6 only: composition planning complexity low, medium, high; when omitted, the model default high is used. Independent of rendering quality, with no separate surcharge.
Please select
frame_countinteger
GIF frame count, integer 2–16, default 9. Only used for output_format=gif; invalid values will be rejected before generation.
input_fidelitystring
The matching strength for the style and features of the input image. Supported by `gpt-image-1` and `gpt-image-1.5`; `gpt-image-1-mini` and the GPT Image 2 series will ignore this parameter.
Please select
response_formatstring
Response format: `url` (default) or `b64_json`.
Please select
callback_urlstring
Optional callback URL. When provided, the interface immediately returns `task_id` and pushes the results to that URL via POST after the image editing is completed.
frame_duration_msinteger
GIF frame duration in milliseconds, integer 20–655350, default 200. GIF encoding rounds to the nearest 10ms; only used for output_format=gif.
Response
Integration guide
Kind reminder: For streaming requests, the above code may not be fully applicable. Please refer to the integration documentation for changes.
OpenAI generation
Allow Use General Balance
When 'Allow General Balance' is enabled, the general balance is used automatically if an app's balance is insufficient.