🎨 ChatGPT 最新生图 gpt-image-2-all 已上线 | Now Live:$0.03/张图,对话式端点提示词遵循最佳!详情 Details
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"
}
]
}
'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1702855400,
"model": "gpt-image-2-vip",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": ""
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}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"
}
]
}
'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1702855400,
"model": "gpt-image-2-vip",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": ""
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}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).messages → text-to-imageimage_url (URL or base64 data URL) → reference-image editassistant messages and continue → multi-turn iterationgpt-image-2-all: identical call format. Just swap model to gpt-image-2-vip and describe your target dimensions in the prompt.⚠️ The chat endpoint has no separate size field — dimensions are conveyed via the prompt (same as -all). For strict size locking, use the text-to-image endpoint with the size field.), which the Playground renders fine. If the model returns a base64 data URL embedded in message.content, or if you pass a large base64 input image via image_url, 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 extract the image link or base64 data from content cleanly.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",
"messages": [
{"role": "user", "content": "Cinematic landscape 16:9, old lighthouse by the sea at dusk, photorealistic"}
]
},
timeout=300
).json()
print(response["choices"][0]["message"]["content"])
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",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Convert this image into watercolor style"},
{"type": "image_url", "image_url": {"url": data_url}}
]
}
]
},
timeout=300
).json()
print(response["choices"][0]["message"]["content"])
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": "Cyberpunk rainy night street, 16:9, neon sign reading Hello World"}
]
}'
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" } }
]
}
]
}'
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();
console.log(data.choices[0].message.content);
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.chat.completions.create(
model="gpt-image-2-vip",
messages=[{
"role": "user",
"content": "Generate a 16:9 ink wash landscape painting in traditional Chinese style"
}]
)
print(resp.choices[0].message.content)
| 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) |
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,... |
chat.completion shape. The generated image appears as a URL or data URL inside choices[0].message.content:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1702855400,
"model": "gpt-image-2-vip",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": ""
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}
content using a regex like https?://[^\s)]+\.(png|jpg|jpeg|webp) or data:image/[^\s)]+.image_url accepts CDN URLs or base64 data URLs directly — no multipart upload needed.assistant messages to continue refining — same logic as ChatGPT.size field. To get pixel-exact outputs from the 30-size set, use the text-to-image endpoint (/v1/images/generations).size to lock dimensionsAPI Key from the API易 Console
Model name, fixed to gpt-image-2-vip
gpt-image-2-vip Conversation messages. Supports multi-turn and multimodal content.
Show child attributes
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 <= 2Image generated (image URL or data URL appears in choices[0].message.content)