> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aireiter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT-Image-2 공식 채널 이미지 생성

> - OpenAI 공식 gpt-image-2 모델, /v1/images/generations 호환 프로토콜 기반
- 비동기 처리 모드, 후속 조회를 위한 task_id 반환
- 텍스트 생성 이미지 / 이미지 변환 이미지 통합 지원
- resolution 레벨 필드 추가, 1K / 2K / 4K 해상도 선택 지원
- 13가지 비율 지원(4K 레벨은 6가지: 16:9 / 9:16 / 2:1 / 1:2 / 21:9 / 9:21)
- 참조 이미지는 최대 9장, URL 및 base64 혼합 입력 지원
- 제출한 prompt는 플랫폼의 민감어 및 보안 심사를 거쳐, 위반 내용은 직접 거부됨


export const apiKeyUrl = 'https://aireiter.com/keys';

## Authorizations

<ParamField header="Authorization" type="string" required>
  모든 엔드포인트는 Bearer Token을 사용하여 인증해야 합니다.

  API 키 얻기:

  <a href={apiKeyUrl} target="_blank">API Key 관리 페이지</a>에 접속하여 API 키를 받으세요.

  사용할 때 요청 헤더에 다음을 추가하세요:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" default="gpt_image_2_official" required>
  이미지 생성 모델 이름

  `gpt_image_2_official` (OpenAI 공식 gpt-image-2 모델)로 고정 작성
</ParamField>

<ParamField body="params" type="object" required>
  모델 파라미터 객체

  <Expandable title="params 객체 속성">
    <ParamField body="prompt" type="string" required>
      이미지 생성을 위한 텍스트 설명

      * 한글과 영어 지원, 자세히 설명하는 것을 권장
      * 제출 전 플랫폼 민감 단어 / 안전성 검사를 거치며, 위반 내용이 있으면 오류를 즉시 반환
    </ParamField>

    <ParamField body="aspect_ratio" type="string" default="1:1">
      화면 비율

      외부에는 비율 값만 사용하며, 시스템 내부에서는 `resolution`에 따라 픽셀로 자동 매핑

      13가지 비율 지원:

      * `1:1` - 정사각형 구성 (기본, 소셜 프로필 사진 / 로고)
      * `3:2` - 가로 구성 (DSLR 카메라 일반 비율)
      * `2:3` - 세로 구성 (포스터 세로형)
      * `4:3` - 가로 구성 (전통 모니터 / PPT)
      * `3:4` - 세로 구성
      * `5:4` - 가로 구성
      * `4:5` - 세로 구성 (인스타그램 세로 게시물)
      * `16:9` - 가로 구성 (와이드 영상 표지)
      * `9:16` - 세로 구성 (휴대폰 전체 화면 / 짧은 영상 표지)
      * `2:1` - 가로 구성 (웹 배너)
      * `1:2` - 세로 구성
      * `21:9` - 가로 구성 (영화 울트라 와이드)
      * `9:21` - 세로 구성

      <Warning>
        비율 형식만 지원하며, 픽셀 크기(예: `1024x1024`)를 입력하면 오류 발생
      </Warning>
    </ParamField>

    <ParamField body="resolution" type="string" default="1K">
      해상도 단계

      실제 생성 이미지 해상도 조절:

      * `1K` - 1024 기준, 경제적이며 일상용으로 충분 (기본값)
      * `2K` - 2048 기준, 포스터 / 고화질 요구에 적합
      * `4K` - 3840 기준, **6개 비율만 지원**(`16:9` / `9:16` / `2:1` / `1:2` / `21:9` / `9:21`)

      <Warning>
        지원하지 않는 4K 조합은 400 오류 반환:

        * `1:1` × `4K` ❌ (초과 픽셀 한도)
        * `3:2` / `2:3` × `4K` ❌ (초과 픽셀 한도)
        * `4:3` / `3:4` × `4K` ❌ (초과 픽셀 한도)
        * `5:4` / `4:5` × `4K` ❌ (초과 픽셀 한도)

        위 비율에 고화질을 원할 시 `resolution=2K`로 변경
      </Warning>
    </ParamField>

    <ParamField body="quality" type="string" default="low">
      이미지 품질

      * `low` - 빠르고 경제적, 윤곽만 충분 (기본값)
      * `medium` - 균형 잡힌 품질
      * `high` - 최고의 정밀도 (4K + high는 120초 이상 소요)
    </ParamField>

    <ParamField body="image_url" type="array">
      참고 이미지 배열, 입력 시 이미지 기반 생성 모드로 동작

      * 최대 **9장** 참고 이미지 가능
      * 다음 두 가지 형식 지원:
        1. 공개 접근 가능한 URL
        2. Base64 인코딩 형식
           * 완전한 Data URI 형식이어야 함: `data:image/{포맷};base64,{base64 데이터}`
           * 지원 이미지 포맷: jpeg, png, webp
           * 예시: `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg...`
           * ⚠️ 주의: `data:image/jpeg;base64,` 접두사 반드시 포함
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="out_task_id" type="string" required>
  발신자 작업 ID

  사용자가 정의하는 작업 식별자, 필수 입력
</ParamField>

## 크기 × 해상도 매핑 표

`aspect_ratio × resolution` → OpenAI 실제 픽셀(13 비율 × 3 단계):

| aspect\_ratio | `1K`      | `2K`      | `4K`          |
| ------------- | --------- | --------- | ------------- |
| `1:1`         | 1024×1024 | 2048×2048 | ❌ 초과 픽셀 한도    |
| `3:2`         | 1536×1024 | 2048×1360 | ❌ 초과 픽셀 한도    |
| `2:3`         | 1024×1536 | 1360×2048 | ❌ 초과 픽셀 한도    |
| `4:3`         | 1024×768  | 2048×1536 | ❌ 초과 픽셀 한도    |
| `3:4`         | 768×1024  | 1536×2048 | ❌ 초과 픽셀 한도    |
| `5:4`         | 1280×1024 | 2560×2048 | ❌ 초과 픽셀 한도    |
| `4:5`         | 1024×1280 | 2048×2560 | ❌ 초과 픽셀 한도    |
| `16:9`        | 1536×864  | 2048×1152 | **3840×2160** |
| `9:16`        | 864×1536  | 1152×2048 | **2160×3840** |
| `2:1`         | 2048×1024 | 2688×1344 | **3840×1920** |
| `1:2`         | 1024×2048 | 1344×2688 | **1920×3840** |
| `21:9`        | 2016×864  | 2688×1152 | **3840×1648** |
| `9:21`        | 864×2016  | 1152×2688 | **1648×3840** |

> `3:2` / `2:3` @ 2K 실제는 2048×1360(근사 비율, 오차 \< 0.5%); 4K는 6개 비율만 지원(전체 픽셀 OpenAI 한도 초과 조합은 사용 불가).

## Response

<ResponseField name="code" type="integer">
  응답 상태 코드
</ResponseField>

<ResponseField name="data" type="array">
  반환 데이터 배열

  <Expandable title="속성">
    <ResponseField name="status" type="string">
      작업 상태

      * `submitted` - 제출됨
    </ResponseField>

    <ResponseField name="task_id" type="string">
      작업 고유 식별자, 후속 작업 결과 조회에 사용됨
    </ResponseField>
  </Expandable>
</ResponseField>

## 작업 결과 조회

제출이 성공하면 `task_id`가 반환되며, `GET /v1/tasks/{task_id}`를 통해 작업 상태를 폴링하여 확인할 수 있습니다. 자세한 내용은 [작업 조회 API](/en/api-reference/tasks/get-task)를 참조하세요.

### 폴링 권장사항

* **최초 조회 지연**: 제출 후 10\~20초 대기 후 조회 시작 권장
* **조회 간격**: 3\~5초마다 한 번 권장
* **타임아웃 참고**: `high + 2K/4K` 조합 작업은 최대 130초 소요될 수 있으니 클라이언트 타임아웃을 180초 이상으로 설정 권장

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://aireiter.com/api/openapi/submit \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gpt_image_2_official",
      "params": {
        "prompt": "별이 빛나는 밤하늘 아래의 오래된 성",
        "aspect_ratio": "16:9",
        "resolution": "2K",
        "quality": "high"
      },
      "out_task_id": "my_task_123456"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://aireiter.com/api/openapi/submit"

  payload = {
      "model": "gpt_image_2_official",
      "params": {
          "prompt": "별이 빛나는 밤하늘 아래의 오래된 성",
          "aspect_ratio": "16:9",
          "resolution": "2K",
          "quality": "high"
      },
      "out_task_id": "my_task_123456"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://aireiter.com/api/openapi/submit";

  const payload = {
    model: "gpt_image_2_official",
    params: {
      prompt: "별이 빛나는 밤하늘 아래의 오래된 성",
      aspect_ratio: "16:9",
      resolution: "2K",
      quality: "high",
    },
    out_task_id: "my_task_123456",
  };

  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));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://aireiter.com/api/openapi/submit"

      payload := map[string]interface{}{
          "model": "gpt_image_2_official",
          "params": map[string]interface{}{
              "prompt":     "별이 빛나는 밤하늘 아래의 오래된 성",
              "aspect_ratio":       "16:9",
              "resolution": "2K",
              "quality":    "high",
          },
          "out_task_id": "my_task_123456",
      }

      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))
  }
  ```

  ```java Java theme={null}
  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://aireiter.com/api/openapi/submit";

          String payload = """
          {
            "model": "gpt_image_2_official",
            "params": {
              "prompt": "별이 빛나는 밤하늘 아래의 오래된 성",
              "aspect_ratio": "16:9",
              "resolution": "2K",
              "quality": "high"
            },
            "out_task_id": "my_task_123456"
          }
          """;

          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 PHP theme={null}
  <?php

  $url = "https://aireiter.com/api/openapi/submit";

  $payload = [
      "model" => "gpt_image_2_official",
      "params" => [
          "prompt" => "별이 빛나는 밤하늘 아래의 오래된 성",
          "aspect_ratio" => "16:9",
          "resolution" => "2K",
          "quality" => "high"
      ],
      "out_task_id" => "my_task_123456"
  ];

  $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;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  url = URI("https://aireiter.com/api/openapi/submit")

  payload = {
    model: "gpt_image_2_official",
    params: {
      prompt: "별이 빛나는 밤하늘 아래의 오래된 성",
      aspect_ratio: "16:9",
      resolution: "2K",
      quality: "high"
    },
    out_task_id: "my_task_123456"
  }

  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
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://aireiter.com/api/openapi/submit")!

  let payload: [String: Any] = [
      "model": "gpt_image_2_official",
      "params": [
          "prompt": "별이 빛나는 밤하늘 아래의 오래된 성",
          "aspect_ratio": "16:9",
          "resolution": "2K",
          "quality": "high"
      ],
      "out_task_id": "my_task_123456"
  ]

  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()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://aireiter.com/api/openapi/submit";

          var payload = @"{
              ""model"": ""gpt_image_2_official"",
              ""params"": {
                  ""prompt"": ""별이 빛나는 밤하늘 아래의 오래된 성"",
                  ""aspect_ratio"": ""16:9"",
                  ""resolution"": ""2K"",
                  ""quality"": ""high""
              },
              ""out_task_id"": ""my_task_123456""
          }";

          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);
      }
  }
  ```

  ```dart Dart theme={null}
  import 'dart:convert';
  import 'package:http/http.dart' as http;

  void main() async {
    final url = Uri.parse('https://aireiter.com/api/openapi/submit');

    final payload = {
      'model': 'gpt_image_2_official',
      'params': {
        'prompt': '별이 빛나는 밤하늘 아래의 오래된 성',
        'aspect_ratio': '16:9',
        'resolution': '2K',
        'quality': 'high',
      },
      'out_task_id': 'my_task_123456',
    };

    final response = await http.post(
      url,
      headers: {
        'Authorization': 'Bearer <token>',
        'Content-Type': 'application/json',
      },
      body: jsonEncode(payload),
    );

    print(response.body);
  }
  ```

  ```r R theme={null}
  library(httr)
  library(jsonlite)

  url <- "https://aireiter.com/api/openapi/submit"

  payload <- list(
    model = "gpt_image_2_official",
    params = list(
      prompt = "별이 빛나는 밤하늘 아래의 오래된 성",
      aspect_ratio = "16:9",
      resolution = "2K",
      quality = "high"
    ),
    out_task_id = "my_task_123456"
  )

  response <- POST(
    url,
    add_headers(
      Authorization = "Bearer <token>",
      `Content-Type` = "application/json"
    ),
    body = toJSON(payload, auto_unbox = TRUE),
    encode = "raw"
  )

  cat(content(response, "text"))
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01KPTXXXXXXXXXXXXXXX"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "size 1:1에 대해 resolution 4K는 지원되지 않습니다. 허용 값: 1K / 2K",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "인증 실패, API 키를 확인하세요",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "계정 잔액 부족, 충전 후 다시 시도하세요",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "요청이 너무 자주 발생했습니다. 잠시 후 다시 시도하세요",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "서버 내부 오류, 잠시 후 다시 시도하세요",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>
