curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"messages": [
{
"role": "user",
"content": "Landscape 16:9 cinematic, old lighthouse at sunset, photorealistic"
}
]
}
'{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/0e82148a-bec0-4b42-bbca-117c6b42581b.png"
}
],
"created": 1778037331,
"usage": {
"input_tokens": 30,
"output_tokens": 2074,
"total_tokens": 2104
}
}Chat API Reference
gpt-image-2-vip chat endpoint — one endpoint handles both text-to-image and reference-image editing, accepts online image URLs directly, supports multi-turn iteration.
curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"messages": [
{
"role": "user",
"content": "Landscape 16:9 cinematic, old lighthouse at sunset, photorealistic"
}
]
}
'{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/0e82148a-bec0-4b42-bbca-117c6b42581b.png"
}
],
"created": 1778037331,
"usage": {
"input_tokens": 30,
"output_tokens": 2074,
"total_tokens": 2104
}
}Documentation Index
Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
Use this file to discover all available pages before exploring further.
/v1/images/generations and /v1/images/edits (OpenAI Images API standard format).- Text-only
messages→ text-to-image - Add
image_url(URL or base64 data URL) → reference-image edit - Keep prior
assistantmessages and continue → multi-turn iteration
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).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).Code Examples
Python (text-to-image)
import requests
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json={
"model": "gpt-image-2-vip",
"size": "2048x1152", # Optional; omit to let the prompt drive sizing
"messages": [
{"role": "user", "content": "Cinematic landscape 16:9, old lighthouse by the sea at dusk, photorealistic"}
]
},
timeout=300
).json()
# Defaults to url; if you switch to b64_json mode, read response["data"][0]["b64_json"]
print(response["data"][0]["url"])
Python (reference-image edit)
import requests
import base64
API_KEY = "sk-your-api-key"
# HTTPS URL or base64 data URL — both work
with open("photo.png", "rb") as f:
data_url = "data:image/png;base64," + base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.apiyi.com/v1/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json={
"model": "gpt-image-2-vip",
"size": "2048x2048", # Optional; omit to let the prompt drive sizing
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Convert this image into watercolor style"},
{"type": "image_url", "image_url": {"url": data_url}}
]
}
]
},
timeout=300
).json()
# Defaults to url; if you switch to b64_json mode, read response["data"][0]["b64_json"]
print(response["data"][0]["url"])
cURL (text-to-image)
curl -X POST "https://api.apiyi.com/v1/chat/completions" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-vip",
"size": "2048x1152",
"messages": [
{"role": "user", "content": "Cyberpunk rainy night street, 16:9, neon sign reading Hello World"}
]
}'
cURL (reference-image edit)
curl -X POST "https://api.apiyi.com/v1/chat/completions" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-vip",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Convert this image into watercolor style" },
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.png" } }
]
}
]
}'
Node.js (text-to-image)
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-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_json
console.log(data.data[0].url);
{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.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Fixed at gpt-image-2-vip |
messages | array | Yes | 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. |
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,... |
Response Format
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:
{
"data": [
{
"url": "https://r2cdn.copilotbase.com/r2cdn2/0e82148a-bec0-4b42-bbca-117c6b42581b.png"
}
],
"created": 1778037331,
"usage": {
"input_tokens": 30,
"output_tokens": 2074,
"total_tokens": 2104
}
}
b64_json output (rare):
{
"data": [
{
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"created": 1778037127,
"usage": {
"input_tokens": 98,
"output_tokens": 1185,
"total_tokens": 1283
}
}
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>.Why the Chat Endpoint
One endpoint, two abilities
Online URL inputs
image_url accepts CDN URLs or base64 data URLs directly — no multipart upload needed.Native multi-turn
assistant messages to continue refining — same logic as ChatGPT.Best SDK coverage
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).Related Resources
Model Overview (full size table)
Text-to-Image API (/v1/images/generations)
size to lock dimensionsImage Editing API (/v1/images/edits)
Sister model gpt-image-2-all
Authorizations
API Key from the API易 Console
Body
Model name, fixed to gpt-image-2-vip
gpt-image-2-vip Conversation messages. Supports multi-turn and multimodal content.
Show child attributes
Show child attributes
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.
auto, 1280x1280, 848x1280, 1280x848, 960x1280, 1280x960, 1024x1280, 1280x1024, 720x1280, 1280x720, 1280x544, 2048x2048, 1360x2048, 2048x1360, 1536x2048, 2048x1536, 1632x2048, 2048x1632, 1152x2048, 2048x1152, 2048x864, 2880x2880, 2336x3520, 3520x2336, 2480x3312, 3312x2480, 2560x3216, 3216x2560, 2160x3840, 3840x2160, 3840x1632 "2048x1152"
Whether to stream the response. This model returns one-shot — keep false. Playground does not support streaming preview.
Sampling temperature (minor effect on image generation — default is fine)
0 <= x <= 2Response
Image generated. Defaults to an R2 CDN URL in data[0].url — b64_json is not returned in the same response.
Response shape for the chat endpoint. data[0] returns either url or b64_json, never both. This endpoint defaults to url.
Was this page helpful?