This calling style is no longer recommended: use /v1/images/generations and /v1/images/edits instead — more stable, and the same code works with the official-relay gpt-image-2. The chat endpoint on this page still works, and remains useful for multi-turn iterative editing or passing online image URLs directly.
Chat endpoint highlights: one endpoint handles both text-to-image and reference-image editing, accepts online image URLs (CDN links or base64 data URLs) directly, and supports natural multi-turn iteration. Enter your API Key in the Playground on the right and pick an example from the dropdown (text-to-image / reference editing / multi-turn).If you want one codebase that hits both the official and reverse channels, prefer /v1/images/generations and /v1/images/edits (OpenAI Images API standard format).
Mode selection:
Text-only messages → text-to-image
Add image_url (URL or base64 data URL) → reference-image edit
Keep prior assistant messages and continue → multi-turn iteration
Difference vs gpt-image-2-all: identical call format — just swap model to gpt-image-2-vip. This endpoint additionally accepts a top-level size field to lock dimensions (30-bucket set, same as /v1/images/generations).✨ size is optional: pass it to lock the output dimensions; omit it to let the prompt drive sizing (same as -all).
🖥️ Browser Playground limitation (when response contains base64)This endpoint defaults to an R2 CDN URL (data[0].url) and the Playground displays it fine. In rare cases the response carries base64 (data[0].b64_json), or you pass a large base64 input image via image_url, in which case the response string can be multi-MB and the browser Playground may show 请求时发生错误: unable to complete request — the request actually succeeded; the browser just can’t display such a long string.Recommended workflow: when you see this prompt, copy the code samples below to your local machine — your code can read the result from data[0].url or data[0].b64_json (only one of the two appears, never both).
const API_KEY = "sk-your-api-key";const response = await fetch("https://api.apiyi.com/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ model: "gpt-image-2.5-vip", messages: [ { role: "user", content: "1024x1024 square logo, minimalist cat line art" } ] })});const data = await response.json();// Defaults to url; if you switch to b64_json mode, read data.data[0].b64_jsonconsole.log(data.data[0].url);
About the OpenAI SDK: The request format is OpenAI Chat Completions compatible, but the response format is {data: [{url|b64_json}], created, usage} — there is no choices field. Calling client.chat.completions.create(...) will fail to parse the response. Use the requests / fetch snippets above to read the raw JSON instead.
Conversation array; supports system / user / assistant roles
messages[].content
string | array
Yes
Plain string (text-to-image) or multimodal array (with reference image)
size
string
No
Output dimensions (30-bucket set), e.g. 2048x1152, 3840x2160. Omit to let the prompt drive sizing. See model overview for the full list
stream
boolean
No
Streaming. This model is one-shot; keep false.
Multimodal content fragments (when content is an array):
Field
Type
Required
Description
type
enum
Yes
text or image_url
text
string
Conditional
Required when type=text
image_url.url
string
Conditional
Required when type=image_url. Accepts https://... or data:image/png;base64,...
See the right-side Playground for full field details. The “Example” dropdown switches between text-to-image / reference editing / multi-turn iteration.
The chat endpoint responds with {data: [{url|b64_json}], created, usage}. data[0] returns either url or b64_json, never both. This endpoint defaults to url.Default url output:
Parsing tip: read data[0].url first; if it’s empty, fall back to data[0].b64_json. The b64_json value already includes the data:image/png;base64, prefix and can be used directly as <img src>.
No need to switch between generations / edits — all flows hit the same endpoint.
Online URL inputs
image_url accepts CDN URLs or base64 data URLs directly — no multipart upload needed.
Native multi-turn
Keep prior assistant messages to continue refining — same logic as ChatGPT.
Best SDK coverage
Works with the official OpenAI SDK, LangChain, and most Chat frontends out of the box.
Strict size locking: pass the top-level size field (e.g. 2048x1152, 3840x2160) to lock the output to one of the 30 buckets. If you prefer the OpenAI Images API standard format, you can also use the text-to-image endpoint (/v1/images/generations).
Output dimensions. Optional. Pass auto to let the model decide (vip tends to converge on a relatively fixed size for a given prompt; with reference images, the output follows the aspect ratio of whichever reference image the prompt names as the edit target — not necessarily the first one in multi-image scenarios), or pick one of the 30 supported sizes (10 ratios × 1K Fast / 2K Recommended / 4K Detail) to lock it strictly. Omit to let the prompt drive the output size.
Format: width x height with a lowercase ASCII x, e.g. 2048x1360, 3840x2160. Flat $0.03/image across all buckets.