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.5-flare",
"prompt": "Cyberpunk city at night, neon sign closeup, cinematic frame"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "gpt-image-2.5-flare",
"prompt": "Cyberpunk city at night, neon sign closeup, cinematic frame"
}
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.5-flare',
prompt: 'Cyberpunk city at night, neon sign closeup, cinematic frame'
})
};
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.5-flare',
'prompt' => 'Cyberpunk city at night, neon sign closeup, cinematic frame'
]),
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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1776832476,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 42,
"output_tokens": 6240,
"total_tokens": 6282
}
}텍스트-이미지 API 레퍼런스
gpt-image-2.5-flare / gpt-image-2.5-sunburst / gpt-image-2 텍스트-이미지 API 레퍼런스 및 실시간 테스트 — 유효한 모든 해상도 지원(4K 포함), token 기반 과금, 세 가지 모두 동일한 가격 및 매개변수
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.5-flare",
"prompt": "Cyberpunk city at night, neon sign closeup, cinematic frame"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "gpt-image-2.5-flare",
"prompt": "Cyberpunk city at night, neon sign closeup, cinematic frame"
}
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.5-flare',
prompt: 'Cyberpunk city at night, neon sign closeup, cinematic frame'
})
};
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.5-flare',
'prompt' => 'Cyberpunk city at night, neon sign closeup, cinematic frame'
]),
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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\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.5-flare\",\n \"prompt\": \"Cyberpunk city at night, neon sign closeup, cinematic frame\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1776832476,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 42,
"output_tokens": 6240,
"total_tokens": 6282
}
}Bearer sk-xxx)를 입력하고, prompt를 작성한 후 크기 / 품질을 선택하여 전송합니다.请求时发生错误: unable to complete request이 표시될 수 있습니다. 요청은 실제로 성공한 것이며, 브라우저에서 이렇게 긴 base64 문자열을 렌더링할 수 없을 뿐입니다.권장 워크플로(초보자용):- 아래의 Python / Node.js / cURL 샘플을 복사하여 로컬에서 실행합니다. 코드는 응답을 자동으로
base64.b64decodes 처리하고 이미지를 파일에 기록합니다. - 브라우저 내 플레이그라운드를 반드시 사용해야 한다면
size을 가장 작은 등급(예:1024x1024)으로 설정하고, 응답 크기를 줄이도록quality를low으로 설정합니다.
input_fidelity— 세 모델 모두 고충실도를 강제하므로, 이를 전달하면 400을 반환합니다(2026-09-09에 2.5에서 확인됨:does not support the 'input_fidelity' parameter). 1.5에서 마이그레이션하는 경우 해당 줄을 제거하기만 하면 됩니다.
2560×1440 이상의 출력은 여전히 실험 단계입니다. 프로덕션 환경에서는 사전 설정인 2048x1152 / 2048x2048 / 3840x2160를 우선 사용하십시오.코드 예제
Python (OpenAI SDK)
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="gpt-image-2.5-flare",
prompt="Cyberpunk city at night, neon sign closeup, cinematic frame",
size="2048x1152",
quality="high",
output_format="jpeg",
output_compression=85
)
# b64_json is raw base64 (no prefix) — decode and write to file
with open("out.jpg", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Python (원시 요청)
import requests
import base64
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"model": "gpt-image-2.5-flare",
"prompt": "Landscape 2K seaside lighthouse at sunset, cinematic frame",
"size": "2048x1152",
"quality": "high"
},
timeout=360 # high + 2K/4K can run 3-5 min; ~120s defaults will frequently false-timeout
).json()
with open("out.png", "wb") as f:
f.write(base64.b64decode(response["data"][0]["b64_json"]))
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.5-flare",
"prompt": "Orange tabby cat with sunglasses at a seaside bar, cinematic",
"size": "2048x1152",
"quality": "high",
"output_format": "jpeg",
"output_compression": 85
}'
Node.js (네이티브 fetch)
import fs from 'node:fs';
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'gpt-image-2.5-flare',
prompt: 'Minimalist line-art cat logo',
size: '1024x1024',
quality: 'medium'
})
});
const { data } = await resp.json();
// b64_json is raw base64 — decode manually
fs.writeFileSync('logo.png', Buffer.from(data[0].b64_json, 'base64'));
브라우저 JavaScript (직접 렌더링)
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'gpt-image-2.5-flare',
prompt: 'Watercolor-style Nordic aurora',
size: '1536x1024',
quality: 'high'
})
});
const { data } = await resp.json();
// Browser rendering needs the data URL prefix prepended manually
document.getElementById('img').src = `data:image/png;base64,${data[0].b64_json}`;
매개변수 참조
| 매개변수 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|
model | string | 예 | — | gpt-image-2.5-flare (속도 우선, 일상적인 기본값) / gpt-image-2.5-sunburst (품질 및 편집 우선) / gpt-image-2 (이전 세대, 계속 사용 가능); 프로덕션에서는 날짜가 지정된 스냅샷 gpt-image-2.5-flare-2026-09-08 / gpt-image-2.5-sunburst-2026-09-08를 고정하십시오. 세 가지 모두 가격과 매개변수가 동일합니다 |
prompt | string | 예 | — | 프롬프트이며 중국어와 영어를 모두 지원합니다 |
size | string | 아니요 | auto | 출력 크기 — 사전 설정값 또는 제약 조건을 충족하는 사용자 지정값 |
quality | string | 아니요 | auto | low / medium / high / xhigh / max / auto; xhigh / max는 2.5에서 새로 추가되었으며, gpt-image-2는 high에서 중지됩니다 |
output_format | string | 아니요 | png | png / jpeg / webp |
output_compression | int | 아니요 | — | 0–100이며, jpeg / webp에만 사용됩니다 |
background | string | 아니요 | auto | transparent / opaque / auto. transparent을 사용하는 경우 output_format는 png 또는 webp이어야 합니다 — jpeg와 함께 사용하면 400이 반환됩니다. 투명 배경 FAQ를 참조하십시오 |
moderation | string | 아니요 | auto | auto / low (낮은 강도의 조정) |
n | int | 아니요 | 1 | 1만 지원됩니다 |
quality에 기존 DALL·E 값 standard / hd를 전달하지 마십시오. 공식 열거형 값 6개인 low / medium / high / xhigh / max / auto만 허용됩니다 (xhigh / max는 두 2.5 모델에서만 허용됩니다). 기존 값은 백엔드 채널에 따라 일관되지 않게 동작합니다. 일부 경우에는 400(invalid_value)과 함께 즉시 실패하고, 일부 경우에는 무시되어 요청이 auto에서 실행됩니다(비용을 예측할 수 없음). 항상 공식 값 중 하나를 명시적으로 전달하십시오.응답 형식
{
"created": 1776832476,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 17,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 17
},
"output_tokens": 196,
"output_tokens_details": {
"image_tokens": 196,
"text_tokens": 0
},
"total_tokens": 213
}
}
data:image/...;base64, 접두사 없이입니다. 클라이언트는 다음을 수행해야 합니다:- 파일 쓰기:
base64.b64decode(b64_str)→ 디스크에 기록 - 브라우저 렌더링:
data:image/png;base64,을 수동으로 앞에 붙입니다
gpt-image-2-all / gpt-image-2-vip도 원시 base64를 반환하지만, 이전 버전에는 접두사가 포함되어 있었습니다 — 모델 간에 코드를 공유할 때는 항상 먼저 startsWith('data:')를 확인하십시오.usage 필드는 이 호출에 대해 실제로 과금된 token 수를 나타냅니다. input_tokens_details / output_tokens_details은 텍스트 token과 이미지 token을 별도로 분리합니다(image_tokens은 일반 text-to-image의 경우 항상 0입니다). 전체 필드 참고와 셀프서비스 비용 계산 공식은 개요 페이지의 각 호출의 실제 token 수를 확인하는 방법을 참조하십시오.인증
API Key obtained from APIYI Console
본문
Model name. gpt-image-2.5-flare (speed-first) / gpt-image-2.5-sunburst (quality- and editing-first) / gpt-image-2 (previous generation) share the same price and parameters; pin a dated snapshot in production
gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2, gpt-image-2.5-flare-2026-09-08, gpt-image-2.5-sunburst-2026-09-08 Prompt text. Supports both Chinese and English. Place scene description at the front for better adherence.
"Cyberpunk city at night, neon sign closeup, cinematic frame"
Output size. Presets: 1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 2048x1152 / 3840x2160 / 2160x3840. Also accepts any valid custom size (max edge ≤ 3840, both multiples of 16, ratio ≤ 3:1, total pixels 0.65–8.3MP).
"2048x1152"
Quality tier. low (sketches/batch), medium (daily), high (final/fine text), xhigh / max (new in 2.5: higher quality and cost, rejected by gpt-image-2), auto (default)
auto, low, medium, high, xhigh, max Output format
png, jpeg, webp Output compression (0–100), only effective for jpeg/webp
0 <= x <= 10085
Background mode. auto (default) or opaque. Not supported: transparent
auto, opaque Moderation strength. auto (default) or low
auto, low Number of images. This model only supports 1
1 이 페이지가 도움이 되었나요?