# model 에는 "gpt-image-2" 를 입력할 수 있으며, 별칭 "gpt-image-2-ext" 도 지원합니다
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-2",
"prompt" => "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n" => 1,
"size" => "16:9",
"resolution" => "2k"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
}
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 = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-2"",
""prompt"": ""창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일"",
""n"": 1,
""size"": ""16:9"",
""resolution"": ""2k""
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-2',
'prompt': '창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일',
'n': 1,
'size': '16:9',
'resolution': '2k'
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-2",
prompt = "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n = 1,
size = "16:9",
resolution = "2k"
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA"
}
]
}
{
"error": {
"code": 400,
"message": "파라미터 오류: size 가 유효하지 않음 / resolution 미지원 / 픽셀 위반 등",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "인증 실패, API 키를 확인하세요",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "계정 잔액 부족, 충전 후 다시 시도하세요",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "요청이 너무 많습니다. 잠시 후 다시 시도하세요",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "build_request_failed: invalid size: 3:5, allowed: 1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 2:1 / 1:2 / 3:1 / 1:3 / 21:9 / 9:21",
"type": "server_error"
}
}
{
"error": {
"code": 503,
"message": "업스트림이 일시적으로 사용할 수 없습니다. 잠시 후 다시 시도하세요",
"type": "service_unavailable"
}
}
GPT-Image-2
GPT-Image-2 이미지 생성
-
비동기 처리 모드, 후속 조회를 위해 작업 ID 반환
-
OpenAI Images 호환 프로토콜 기반, 텍스트→이미지 / 이미지→이미지 지원
-
size필드를 통해 15가지 이미지 비율 지원 -
resolution(1k/2k/4k)으로 실제 출력 픽셀 단계 제어 -
참조 이미지 최대 16장, URL 과 base64 혼합 사용 가능
-
해상도 단계(1K / 2K / 4K)에 따라 과금
POST
/
v1
/
images
/
generations
# model 에는 "gpt-image-2" 를 입력할 수 있으며, 별칭 "gpt-image-2-ext" 도 지원합니다
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-2",
"prompt" => "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n" => 1,
"size" => "16:9",
"resolution" => "2k"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
}
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 = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-2"",
""prompt"": ""창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일"",
""n"": 1,
""size"": ""16:9"",
""resolution"": ""2k""
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-2',
'prompt': '창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일',
'n': 1,
'size': '16:9',
'resolution': '2k'
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-2",
prompt = "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n = 1,
size = "16:9",
resolution = "2k"
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA"
}
]
}
{
"error": {
"code": 400,
"message": "파라미터 오류: size 가 유효하지 않음 / resolution 미지원 / 픽셀 위반 등",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "인증 실패, API 키를 확인하세요",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "계정 잔액 부족, 충전 후 다시 시도하세요",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "요청이 너무 많습니다. 잠시 후 다시 시도하세요",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "build_request_failed: invalid size: 3:5, allowed: 1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 2:1 / 1:2 / 3:1 / 1:3 / 21:9 / 9:21",
"type": "server_error"
}
}
{
"error": {
"code": 503,
"message": "업스트림이 일시적으로 사용할 수 없습니다. 잠시 후 다시 시도하세요",
"type": "service_unavailable"
}
}
모델명 호환 안내: 이 엔드포인트는 별칭
gpt-image-2-ext도 지원하며, 이는 gpt-image-2와 동일하므로 서로 바꿔 사용할 수 있고 효과도 동일합니다.# model 에는 "gpt-image-2" 를 입력할 수 있으며, 별칭 "gpt-image-2-ext" 도 지원합니다
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-2",
"prompt" => "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n" => 1,
"size" => "16:9",
"resolution" => "2k"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-2",
prompt: "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n: 1,
size: "16:9",
resolution: "2k"
}
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 = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
"n": 1,
"size": "16:9",
"resolution": "2k"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-2"",
""prompt"": ""창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일"",
""n"": 1,
""size"": ""16:9"",
""resolution"": ""2k""
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-2',
'prompt': '창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일',
'n': 1,
'size': '16:9',
'resolution': '2k'
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-2",
prompt = "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일",
n = 1,
size = "16:9",
resolution = "2k"
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA"
}
]
}
{
"error": {
"code": 400,
"message": "파라미터 오류: size 가 유효하지 않음 / resolution 미지원 / 픽셀 위반 등",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "인증 실패, API 키를 확인하세요",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "계정 잔액 부족, 충전 후 다시 시도하세요",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "요청이 너무 많습니다. 잠시 후 다시 시도하세요",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "build_request_failed: invalid size: 3:5, allowed: 1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 2:1 / 1:2 / 3:1 / 1:3 / 21:9 / 9:21",
"type": "server_error"
}
}
{
"error": {
"code": 503,
"message": "업스트림이 일시적으로 사용할 수 없습니다. 잠시 후 다시 시도하세요",
"type": "service_unavailable"
}
}
Authorizations
모든 엔드포인트는 Bearer Token 인증이 필요합니다API 키 받기:API 키 관리 페이지 에서 API 키를 받으세요사용 시 요청 헤더에 다음을 추가:
Authorization: Bearer YOUR_API_KEY
Body
이미지 생성 모델 이름
gpt-image-2 로 고정 (호환 별칭 gpt-image-2-ext 사용 가능)구버전 호출과의 호환을 위해 별칭
gpt-image-2-ext(gpt-image-2에 해당)는 계속 정상적으로 사용할 수 있습니다.이미지 생성을 위한 텍스트 설명
- 한국어 / 영어 / 중국어 지원, 상세한 설명을 권장
- 제출 전에 플랫폼의 민감어 / 안전 심사를 거칩니다. 위반 내용은 즉시 오류를 반환합니다
생성할 이미지 장수범위:
1 - 10반드시 순수 숫자(예:
1)를 입력하세요. 따옴표로 감싸지 마세요이미지 생성 비율다음 비율 지원,
auto 를 전달하면 서버에서 적절한 비율을 자동 선택합니다:| size | 유형 |
|---|---|
auto | 자동 |
1:1 | 정사각형 |
3:2 | 가로 |
2:3 | 세로 |
4:3 | 가로 |
3:4 | 세로 |
5:4 | 가로 |
4:5 | 세로 |
16:9 | 가로 |
9:16 | 세로 |
2:1 | 가로 |
1:2 | 세로 |
3:1 | 가로 |
1:3 | 세로 |
21:9 | 가로 |
9:21 | 세로 |
1881x836 / 887x1774 같은 픽셀 크기도 직접 전달할 수 있습니다.size 에 auto 를 전달하면 기본 비율은 1:1 입니다.출력 해상도 단계선택 가능 값:
1k / 2k / 4ksize × resolution → 실제 픽셀 매핑:| size | 1k | 2k | 4k |
|---|---|---|---|
1:1 | 1024×1024 / 1254×1254 | 2048×2048 | 2880×2880 |
3:2 | 1536×1024 | 2048×1360 | 3520×2336 |
2:3 | 1024×1536 | 1360×2048 | 2336×3520 |
4:3 | 1024×768 | 2048×1536 | 3312×2480 |
3:4 | 768×1024 | 1536×2048 | 2480×3312 |
5:4 | 1280×1024 / 1448×1086 | 2560×2048 | 3216×2576 |
4:5 | 1024×1280 / 1122×1402 | 2048×2560 | 2576×3216 |
16:9 | 1536×864 / 1672×941 | 2048×1152 | 3840×2160 |
9:16 | 864×1536 / 941×1672 | 1152×2048 | 2160×3840 |
2:1 | 2048×1024 / 1774×887 | 2688×1344 | 3840×1920 |
1:2 | 1024×2048 / 887×1774 | 1344×2688 | 1920×3840 |
3:1 | 1881×836 / 1536×512 | 3072×1024 | 3840×1280 |
1:3 | 887×1774 / 512×1536 | 1024×3072 | 1280×3840 |
21:9 | 2016×864 / 1915×821 | 2688×1152 | 3840×1648 |
9:21 | 864×2016 / 821×1915 | 1152×2688 | 1648×3840 |
4K 는 위 15가지 비율을 지원합니다. 표의 픽셀 크기를
size 로 직접 전달할 수도 있습니다.참조 이미지 배열 (OpenAI 표준 필드). 전달하면 이미지-이미지 모드로 전환됩니다
표시 세부사항
표시 세부사항
- 참조 이미지 최대 16장, 초과 시
image_urls exceeds max 16반환 - 이미지당 최대 20MB, 전체 상한 256MB
이미지 URL(공개 접근 가능한 안정 링크) 지원base64 data URI(data:image/png;base64,...형식) 지원- 동일 배열 내에 URL 과 base64 혼합 가능, 서버가 처리합니다
size미전달 시 출력 해상도 = 입력 이미지 해상도.size전달 시 지정 크기로 강제
기타 OpenAI 표준 필드(
response_format, style 등)는 현재 지원되지 않으며 무시됩니다. 작업 결과는 url 만 반환됩니다. base64 가 필요하면 직접 다운로드하여 변환하세요.공식 채널을 폴백으로 사용할지 여부
false:사용 안 함 (기본값)true:공식 채널 사용
사용 시나리오 예시
텍스트-이미지 (최소 요청){
"model": "gpt-image-2",
"prompt": "창가에 앉아 석양을 바라보는 주황색 고양이, 수채화 스타일"
}
{
"model": "gpt-image-2",
"prompt": "a corgi astronaut on the moon, cinematic, 8k",
"size": "16:9",
"resolution": "2k"
}
{
"model": "gpt-image-2",
"prompt": "별이 빛나는 하늘 아래의 고대 성",
"size": "16:9",
"resolution": "4k"
}
{
"model": "gpt-image-2",
"prompt": "별이 빛나는 하늘 아래의 고대 성",
"size": "16:9",
"resolution": "4k",
"n": 2
}
{
"model": "gpt-image-2",
"prompt": "이 사진을 수채화 스타일로 변환",
"image_urls": [
"https://example.com/photo.jpg"
]
}
{
"model": "gpt-image-2",
"prompt": "이 사진을 수채화 스타일로 변환",
"image_urls": [
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
]
}
{
"model": "gpt-image-2",
"prompt": "이 두 사진을 하나의 포스터로 융합",
"size": "4:3",
"resolution": "2k",
"image_urls": [
"https://example.com/photo-a.jpg",
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
]
}
Response
응답 상태 코드
작업 결과 조회
제출 성공 후task_id 가 반환됩니다. GET /v1/tasks/{task_id} 로 작업 상태를 폴링하세요. 자세한 내용은 작업 조회 API 참조.
성공 응답 예시
{
"code": 200,
"data": {
"id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
"status": "completed",
"progress": 100,
"created": 1776748674,
"completed": 1776748726,
"actual_time": 52,
"cost": 0.05279,
"credits_cost": 0.5279,
"estimated_time": 100,
"result": {
"images": [
{
"url": [
"https://upload.apimart.ai/f/image/xxxxxxxx-gpt_image_2_task_xxx_0.png"
],
"expires_at": 1776835126
}
]
}
}
}
data.result.images[0].url[0]
작업 상태
| 상태 | 의미 |
|---|---|
submitted | 제출됨 |
processing | 업스트림 처리 중 |
completed | 성공, result.images 사용 가능 |
failed | 실패, error.message 확인 |
⌘I