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

# Flux 2.0 이미지 생성

>  - 비동기 처리 모드, 후속 쿼리를 위한 작업 ID 반환
- 텍스트-이미지, 이미지-이미지 생성 지원
- 생성된 이미지 링크는 24시간 동안 유효합니다. 빠르게 저장해 주세요 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/images/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flux-2-flex",
      "prompt": "잔디 위의 파란 고양이",
      "resolution": "1K",
      "size": "16:9"
    }'
  ```

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

  url = "https://api.apimart.ai/v1/images/generations"

  payload = {
      "model": "flux-2-flex",
      "prompt": "잔디 위의 파란 고양이",
      "resolution": "1K",
      "size": "16:9"
  }

  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://api.apimart.ai/v1/images/generations";

  const payload = {
    model: "flux-2-flex",
    prompt: "잔디 위의 파란 고양이",
    resolution: "1K",
    size: "16:9"
  };

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

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

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "잘못된 요청 매개변수",
      "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"
    }
  }
  ```
</ResponseExample>

## 지원되는 모델

| 모델명           | 설명                                         | 과금 방식           |
| ------------- | ------------------------------------------ | --------------- |
| `flux-2-flex` | Flux 2.0 Flex 이미지 생성 모델 (빠름, 빠른 반복에 적합)    | 해상도별 과금 (1K/2K) |
| `flux-2-pro`  | Flux 2.0 Pro 이미지 생성 모델 (더 높은 품질, 더 나은 디테일) | 해상도별 과금 (1K/2K) |

## 인증

<ParamField header="Authorization" type="string" required>
  모든 엔드포인트는 Bearer Token 인증이 필요합니다

  API Key 받기:

  [API Key 관리 페이지](https://apimart.ai/keys)에서 API Key를 받으세요

  요청 헤더에 추가:

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

## Body

<ParamField body="model" type="string" required>
  모델 이름

  * `flux-2-flex` - Flux 2.0 Flex 모델 (빠름, 빠른 반복에 적합)
  * `flux-2-pro` - Flux 2.0 Pro 모델 (더 높은 품질, 더 나은 디테일)
</ParamField>

<ParamField body="prompt" type="string" required>
  이미지 생성을 위한 텍스트 설명
</ParamField>

<ParamField body="resolution" type="string" default="1K">
  이미지 해상도

  지원되는 해상도:

  * `1K` - 기본값, 1080p 수준
  * `2K` - HD, 최대 2048 픽셀

  > 대소문자 구분 없음: `1k`, `1K`, `2k`, `2K` 모두 사용 가능
</ParamField>

<ParamField body="size" type="string" default="1:1">
  이미지 가로세로 비율

  지원되는 가로세로 비율:

  * `1:1` - 정사각형 (기본값)
  * `4:3` - 가로
  * `3:4` - 세로
  * `16:9` - 와이드스크린
  * `9:16` - 세로
  * `3:2` - 클래식 가로
  * `2:3` - 클래식 세로

  > 위 7가지 비율만 지원, 지원되지 않는 비율은 오류 반환
</ParamField>

<ParamField body="image_urls" type="array">
  참조 이미지 URL 목록

  **제한:**

  * 최대 8장
  * 공개적으로 접근 가능한 URL이어야 함
  * Base64 형식은 지원되지 않음
</ParamField>

## 해상도 참조 표

| 비율     | 이름     | 1K 크기     | 2K 크기     |
| ------ | ------ | --------- | --------- |
| `1:1`  | 정사각형   | 1440×1440 | 1536×1536 |
| `4:3`  | 가로     | 1664×1248 | 1824×1368 |
| `3:4`  | 세로     | 1248×1664 | 1368×1824 |
| `16:9` | 와이드스크린 | 1920×1080 | 2048×1152 |
| `9:16` | 세로     | 1080×1920 | 1152×2048 |
| `3:2`  | 클래식 가로 | 1728×1152 | 1872×1248 |
| `2:3`  | 클래식 세로 | 1152×1728 | 1248×1872 |

## 사용 예시

**기본 텍스트-이미지**

```json theme={null}
{
    "model": "flux-2-flex",
    "prompt": "파란 고양이",
    "resolution": "1K",
    "size": "16:9"
}
```

**고해상도 생성**

```json theme={null}
{
    "model": "flux-2-pro",
    "prompt": "산과 강이 있는 세밀한 풍경화",
    "resolution": "2K",
    "size": "16:9"
}
```

**이미지-이미지 (최대 8장 참조 이미지)**

```json theme={null}
{
    "model": "flux-2-flex",
    "prompt": "이미지를 수채화 스타일로 변환",
    "image_urls": [
        "https://example.com/input1.jpg",
        "https://example.com/input2.jpg"
    ],
    "resolution": "1K"
}
```

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

## 주의사항

1. **이미지 URL 요구사항**: 입력 이미지는 공개적으로 접근 가능한 URL이어야 합니다, base64는 지원되지 않습니다
2. **결과 저장**: 생성된 이미지는 자동으로 저장되며, URL은 24시간 동안 유효합니다
3. **작업 폴링**: 작업은 비동기로 처리됩니다, 결과를 얻으려면 `/v1/tasks/{task_id}`를 폴링하세요
4. **입력 이미지 제한**: 최대 8장까지 지원
