curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"prompt": "Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "gpt-image-2-vip",
"prompt": "Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2-vip',
prompt: 'Cinematic landscape, old lighthouse by the sea at dusk, photorealistic'
})
};
fetch('https://api.apiyi.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-image-2-vip',
'prompt' => 'Cinematic landscape, old lighthouse by the sea at dusk, photorealistic'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"created": 1778037127,
"usage": {
"input_tokens": 98,
"output_tokens": 1185,
"total_tokens": 1283
}
}텍스트-이미지 API 레퍼런스
gpt-image-2-vip 텍스트-이미지 API 레퍼런스 및 인터랙티브 플레이그라운드 — 텍스트와 크기를 지정해 이미지를 생성합니다 + 모든 크기에서 이미지당 $0.03의 정액 요금
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-vip",
"prompt": "Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "gpt-image-2-vip",
"prompt": "Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2-vip',
prompt: 'Cinematic landscape, old lighthouse by the sea at dusk, photorealistic'
})
};
fetch('https://api.apiyi.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-image-2-vip',
'prompt' => 'Cinematic landscape, old lighthouse by the sea at dusk, photorealistic'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2-vip\",\n \"prompt\": \"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"created": 1778037127,
"usage": {
"input_tokens": 98,
"output_tokens": 1185,
"total_tokens": 1283
}
}Bearer sk-xxx), prompt과 size를 설정한 뒤 전송하십시오.size — 이미지 업로드는 필요하지 않습니다. 기존 이미지를 편집하거나 합성하려면 이미지 편집 endpoint를 사용하십시오.gpt-image-2-all와의 차이: 호출 구조는 동일하고, size 필드 하나만 추가됩니다. 차원을 고정할 필요가 없고 가장 빠른 출력을 원하시면 대신 gpt-image-2-all을 사용하십시오.b64_json)을 반환하므로 크기가 몇 MB에 이를 수 있어 브라우저 Playground에 请求时发生错误: unable to complete request가 표시될 수 있습니다 — 요청은 실제로 성공한 것입니다; 브라우저가 그처럼 긴 base64 문자열을 렌더링하지 못할 뿐입니다.권장 작업 흐름: 아래 코드 샘플을 복사해 로컬에서 실행하십시오 — 이미지를 디코딩하여 파일로 자동 저장합니다.size: 모델이 선택하게 하려면auto를 전달하십시오(vip는 주어진 prompt에 대해 상대적으로 고정적/안정적인 크기로 수렴하는 경향이 있습니다). 또는 엄격하게 고정하려면 지원되는 30개 크기 중 하나(10개 비율 × 1K 빠름 / 2K 권장 / 4K 상세 — 개요 페이지의 전체 크기 표 참조)를 선택하십시오. 소문자 ASCIIx를 사용하십시오. 예:2048x1360,3840x2160— 절대×나 대문자X는 사용하지 마십시오.quality: ❌ 거부됨 — 전달하지 마십시오.n: ❌ 거부됨 — 호출당 이미지 1장만 지원합니다.n=3를 보내면 3배가 과금되지만 여전히 이미지 1장만 반환합니다. 필드를 제거하십시오.aspect_ratio: ❌ 거부됨 — 비율은size에 의해 결정됩니다.response_format: 생략하면 base64(원시, prefix 없음, 2026-07 검증)를 반환합니다. 이미지 URL을 받으려면"url"를 전달하십시오. URL 출력에 의존하는 비즈니스는 base64 대체 없이 결정적인 URL 출력을 위해 token을image2_OSS그룹으로 전환해야 합니다.
코드 예제
Python
import requests
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "gpt-image-2-vip",
"prompt": "Cinematic landscape, old lighthouse by the sea at dusk, photorealistic",
"size": "2048x1152", # 16:9 2K Recommended
"response_format": "url" # defaults to base64; explicit response_format needed to read the url field
},
timeout=300 # conservative; absorbs long-tail and image download
).json()
image_url = response["data"][0]["url"]
print(image_url)
import requests
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={"Authorization": "Bearer sk-your-api-key"},
json={
"model": "gpt-image-2-vip",
"prompt": "Desktop wallpaper, cyberpunk city night, neon signs, wet pavement reflections",
"size": "3840x2160" # 16:9 4K Detail
},
timeout=300
).json()
# Verified 2026-07: b64_json is raw base64 (no data: prefix); earlier versions included the prefix — a check is safest
import base64
b64 = response["data"][0]["b64_json"]
if b64.startswith("data:"):
b64 = b64.split(",", 1)[1]
with open("wallpaper.png", "wb") as f:
f.write(base64.b64decode(b64))
cURL
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-vip",
"prompt": "Product shot of a white ceramic mug on a gray desk, soft natural light",
"size": "2048x1360"
}'
Node.js
const API_KEY = "sk-your-api-key";
const response = await fetch(
"https://api.apiyi.com/v1/images/generations",
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gpt-image-2-vip",
prompt: "1:1 square logo, minimalist cat line art",
size: "2048x2048" // 1:1 2K Recommended
})
}
);
const data = await response.json();
// Verified raw base64 (no data: prefix) — prepend before rendering; earlier versions included the prefix, so check first
let b64 = data.data[0].b64_json;
if (!b64.startsWith("data:")) b64 = `data:image/png;base64,${b64}`;
document.getElementById("result").src = b64;
OpenAI SDK (Python, 권장)
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="gpt-image-2-vip",
prompt="Ink wash landscape painting, traditional Chinese style, vertical composition",
size="1536x2048", # 3:4 2K Portrait
)
print(resp.data[0].url)
매개변수
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | gpt-image-2-vip로 고정됩니다 |
prompt | string | Yes | Prompt — 콘텐츠, 스타일, 조명 등을 설명합니다. |
size | string | 강력히 권장 | 출력 크기: auto(모델이 결정합니다 — vip는 주어진 prompt에 대해 비교적 고정됩니다) 또는 30개 크기 중 하나입니다; 형식 WIDTHxHEIGHT(소문자 x); 필드를 생략하면 auto와 같습니다 |
- 이커머스 히어로 샷:
2048x1360(3:2 2K) /2048x2048(1:1 2K) - 세로 포스터:
1536x2048(3:4 2K) /2480x3312(3:4 4K) - 동영상 썸네일:
2048x1152(16:9 2K) /3840x2160(16:9 4K) - 스토리 / 휴대폰 배경화면:
1152x2048(9:16 2K) /2160x3840(9:16 4K)
응답 형식
기본값으로 base64를 반환합니다 (data[0].b64_json, 접두사 없는 raw base64, 2026-07 검증됨). 대신 이미지 URL을 받으려면 response_format: "url"을 명시적으로 전달하십시오. URL 출력에 의존하는 비즈니스는 안정적인 URL 출력을 위해 base64 대체 없이 token의 그룹을 **image2_OSS**로 변경해야 합니다. data[0]는 url 또는 b64_json 중 하나만 반환합니다 — 둘 다는 아닙니다.
b64_json 모드 (기본값):
{
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"created": 1778037127,
"usage": {
"input_tokens": 98,
"output_tokens": 1185,
"total_tokens": 1283
}
}
url 모드 (response_format: "url"을 명시적으로 전달하십시오; URL에 의존한다면 image2_OSS 그룹을 사용하십시오 — R2 CDN이 전역으로 가속됩니다):
{
"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 필드는 data: 접두사가 없는 raw base64입니다. 파일에 쓰려면 디코딩하고, 렌더링하기 전에 직접 접두사를 붙이십시오. 이전 버전에는 접두사가 포함되어 있었습니다, 따라서 두 형태를 모두 처리하려면 항상 먼저 startsWith('data:') 검사를 실행하십시오.관련 리소스
모델 개요 (전체 크기 표)
이미지 편집 API
/v1/images/edits 다중 이미지 융합 및 편집자매 모델 gpt-image-2-all
인증
API Key from the API易 Console
본문
Model name, fixed to gpt-image-2-vip
gpt-image-2-vip Prompt — describe content, style, lighting, etc.
"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"
Output size. Pass auto to let the model decide (vip tends to converge on a relatively fixed size for a given prompt), or pick one of the 30 supported sizes (10 ratios × 1K Fast / 2K Recommended / 4K Detail) to lock it strictly.
Format: WIDTHxHEIGHT with lowercase ASCII x, e.g., 2048x1360, 3840x2160. Flat $0.03/image across all tiers.
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"
응답
Image successfully generated. Defaults to base64 in data[0].b64_json — url is not returned in the same response.
Image generation response. Returns base64 by default (data[0].b64_json); to get a url, switch to the image2_OSS group with response_format=url. data[0] returns either url or b64_json, never both.
이 페이지가 도움이 되었나요?