OpenAI Images Generations API
https://api2.yujuntc.fun/openai/images/generations
https://api2.yujuntc.fun/v1/images/generations
Unified image generation endpoint compatible with the OpenAI Images API. A single endpoint supports DALL·E 2/3, the full GPT Image family (gpt-image-1, gpt-image-1.5, gpt-image-2), and Google's Nano Banana family (nano-banana, nano-banana-2, nano-banana-pro). Fine-grained control via size, quality, style, background, output_format, moderation, etc., with transparent background, PNG/JPEG/WebP outputs, and optional callback_url for async delivery.
Request Headers
acceptstring
Specify the response format returned by the server.
Please select
authorizationstring
Bearer token
Request Body
modelstringRequired parameter
Models for image generation. Supports OpenAI's `dall-e-2`, `dall-e-3`, `gpt-image-1` / `gpt-image-1.5` / `gpt-image-2` / `gpt-image-2.5-flare` / `gpt-image-2.5-sunburst` series, as well as Google's `nano-banana` / `nano-banana-2-lite` / `nano-banana-2` / `nano-banana-2.1` / `nano-banana-pro`. Different models vary in their support for the `size`, `quality`, `style`, `background`, `output_format`, `moderation`, and `response_format` parameters; see the description of each field for details. `gpt-image-2` provides `gpt-image-2:official` (official channel, stable and compliant, billed based on the actual Token usage of text 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 each provide same-named `:official` variants, billed based on actual Token usage.
promptstringRequired parameter
Text description of the required image. The GPT image model supports up to 32,000 characters, `dall-e-2` supports up to 1,000 characters, and `dall-e-3` supports up to 4,000 characters. A selection of example prompts is provided in the dropdown list (source: [EvoLinkAI/awesome-gpt-image-2-prompts](https://github.com/EvoLinkAI/awesome-gpt-image-2-prompts), Apache-2.0 license); you can also enter your own.
ninteger
The number of images to generate, ranging from 1 to 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 by the number of successfully generated images, while `:official` is charged based on the actual Token usage aggregated across the entire response, and will not be 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 successfully generated ones will be returned and billed.
sizestring
Image size, in the format `widthxheight`, or enter `auto` to select the aspect ratio based on the prompt semantics. **The GPT Image 2 series (`gpt-image-2`, `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`)** accepts any properly formatted `WIDTHxHEIGHT` value, including 1K presets (`1024x1024`, `1536x1024`, `1024x1536`, `1792x1024`, `1024x1792`), 2K presets (`2048x2048`, `2048x1536`, `1536x2048`, `2048x1152`, `1152x2048`), 4K presets (`2880x2880`, `3264x2448`, `2448x3264`, `3840x2160`, `2160x3840`), as well as any custom size; the default model and `:reverse` are billed per image, while the size and quality of `:official` affect Token usage and are billed based on actual usage. Size limits: custom dimensions must be multiples of 16, the longer side must not exceed 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`. `dall-e-3` supports: `1024x1024`, `1792x1024`, `1024x1792`. When `auto` is explicitly passed, the platform determines the result in a continuous aspect-ratio space in the following order: explicit pixels or ratios, named standards (paper / print materials / platform placements / advertisements / devices / photography / film), medium conventions, and composition. In addition to common ratios, non-preset ratios such as `1.91:1`, `1.85:1`, `2.39:1`, and ISO paper `1:√2` can also be retained; the result will be normalized to multiples of 16 and the pixel budget supported by the service. When automatic determination is unavailable, it falls back to the model's default aspect ratio. Omitting the `size` field directly uses the model's default aspect ratio. If you have strict pixel requirements, please directly pass `WIDTHxHEIGHT`.
callback_urlstring
Optional callback URL. Once provided, the API will immediately return `task_id` and will push the results to that URL via a POST request after the image generation is complete. The callback payload contains `task_id`, `trace_id`, `success` (boolean), and the complete response data or error information.
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
stylestring
The style of `dall-e-3`: `vivid` (hyper-realistic/dramatic) or `natural` (more naturally neutral).
qualitystring
Image quality. GPT image model options: `auto` (default), `high`, `medium`, `low`. `dall-e-3` options: `hd` or `standard`. `dall-e-2` supports only: `standard`.
backgroundstring
Set the background opacity for the GPT image model. The optional values are `transparent`, `opaque`, or `auto` (default). When selecting `transparent`, please use an output format that supports the Alpha channel (png/webp).
Please select
moderationstring
The content review levels of the GPT image model. `low` will relax the filtering strength; `auto` uses the default policy.
Please select
output_formatstring
The return format of the GPT image model. Optional values are `png`, `jpeg`, or `webp`.
Please select
partial_imagesinteger
The number of intermediate images sent during the streaming process (0-3). `0` indicates that the final image is returned directly in one event.
response_formatstring
Return format: `url` (default) or `b64_json`. When using `url`, the platform will convert results that only return base64 into accessible CDN URLs; when explicitly using `b64_json`, the base64 content is retained. `b64_json` only supports `n=1`.
output_compressioninteger
The compression level (0-100%) of the GPT image model when using `webp` or `jpeg` output formats.
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.