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

# Gemini 텍스트 이미지 생성 API

> BetterToken의 Gemini API로 Nano Banana 이미지를 생성하세요. 모델, 프롬프트, 해상도와 비율을 선택하고 문서의 API Playground에서 요청과 응답을 확인하세요.

Nano Banana Pro, 2, 2.1로 텍스트 설명에서 이미지를 생성합니다.

`POST /v1beta/models/{model}:generateContent`

텍스트 이미지 생성과 이미지 편집은 같은 API를 사용합니다. 편집할 때는 요청에 참조 이미지를 추가합니다.

## 요청 테스트

**x-goog-api-key**에 BetterToken API Key를 입력하고 **model**을 선택한 뒤 **contents**의 텍스트를 수정하세요. `1K`, `1:1`로 시작하고 **Send**를 누르세요.

<Note>
  **Send**를 누르면 실제 생성 요청이 전송되며 요금이 발생할 수 있습니다. 동기 응답을 기다리세요. 시간 초과나 연결 끊김 후에는 사용 기록과 요청 결과를 확인한 뒤 다시 전송하세요.
</Note>

세 모델 모두 `1K`, `2K`, `4K`를 제공합니다. Nano Banana 2와 2.1은 14개, Pro는 10개 비율을 지원합니다. `X-BetterToken-Max-Images`는 반환 및 과금 이미지 수의 상한이며 생성 수를 보장하지 않습니다. [지원 비율](/ko/api-reference/nano-banana#aspect-ratios)

<Warning>
  BetterToken API는 Google 웹 검색 및 이미지 검색 기반 이미지 생성을 지원하지 않습니다. 검색 도구를 추가하지 마세요.
</Warning>

텍스트로 이미지를 생성할 때는 설명만 있으면 되며 참조 이미지는 필요하지 않습니다. 비스트리밍 `generateContent`를 사용하며 Files, Batch, Interactions 및 스트리밍은 지원하지 않습니다.

## 응답 읽기

이미지는 `candidates[].content.parts[].inlineData`에 반환됩니다. 모든 part를 순회하고 `thought: true`를 건너뛴 뒤 `data`를 디코딩하고 `mimeType`에 따라 확장자를 선택하세요. 이미지가 항상 첫 part이거나 PNG인 것은 아닙니다.

## 관련 가이드

* [이미지 편집](/ko/api-reference/gemini-images-edits)
* [SDK, 이미지 저장과 연속 편집](/ko/api-reference/nano-banana)
* [모델 소개](/ko/model-updates/nano-banana)
* <a href={"https://bettertoken.ai/pricing"}>모델 카탈로그</a>


## OpenAPI

````yaml api-reference/gemini-images-generations.ko.json POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: Gemini 텍스트 이미지 생성 API
  description: >-
    BetterToken의 Gemini API로 Nano Banana 이미지를 생성하세요. 모델, 프롬프트, 해상도와 비율을 선택하고 문서의
    API Playground에서 요청과 응답을 확인하세요.
  version: 1.0.0
servers:
  - url: https://bettertoken.ai
security:
  - geminiApiKey: []
paths:
  /v1beta/models/{model}:generateContent:
    post:
      summary: Gemini 텍스트 이미지 생성 API
      description: >-
        Nano Banana Pro, 2, 2.1로 텍스트 설명에서 이미지를 생성합니다. BetterToken API는 Google 웹
        검색 및 이미지 검색 기반 이미지 생성을 지원하지 않습니다. 검색 도구를 추가하지 마세요.
      operationId: generateGeminiImage_ko
      parameters:
        - name: model
          in: path
          required: true
          description: BetterToken 모델 ID. Nano Banana 모델 세 개 중 선택하세요.
          schema:
            type: string
            enum:
              - nano-banana-pro
              - nano-banana-2
              - nano-banana-2.1
            default: nano-banana-2.1
        - name: X-BetterToken-Max-Images
          in: header
          description: 반환 및 과금 이미지 수의 상한이며 수량 보장이 아닙니다. 기본값은 1.
          schema:
            type: integer
            minimum: 1
            maximum: 4
            default: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
              properties:
                contents:
                  type: array
                  description: 대화 기록. 후속 편집 시 모델의 전체 content와 thoughtSignature를 유지하세요.
                  minItems: 1
                  items:
                    type: object
                    required:
                      - parts
                    properties:
                      role:
                        type: string
                        description: 새 요청은 user, 편집 기록의 이전 모델 응답은 model.
                        enum:
                          - user
                          - model
                        default: user
                      parts:
                        type: array
                        description: 텍스트 및 이미지. text와 inlineData를 별도 part에 넣으세요.
                        minItems: 1
                        items:
                          anyOf:
                            - type: object
                              required:
                                - text
                              properties:
                                text:
                                  type: string
                                  description: 이미지 설명 또는 편집 지시.
                                  example: 흰색 테이블 위 파란색 세라믹 머그잔의 스튜디오 제품 사진.
                              additionalProperties: true
                            - type: object
                              required:
                                - inlineData
                              properties:
                                inlineData:
                                  type: object
                                  description: base64로 포함한 참조 이미지.
                                  required:
                                    - mimeType
                                    - data
                                  properties:
                                    mimeType:
                                      type: string
                                      description: 참조 이미지의 MIME 유형.
                                      enum:
                                        - image/png
                                        - image/jpeg
                                      example: image/png
                                    data:
                                      type: string
                                      description: Data URL 접두사가 없는 이미지 바이트의 base64.
                                      contentEncoding: base64
                                      example: REPLACE_WITH_IMAGE_BASE64
                                  additionalProperties: false
                              additionalProperties: true
                    additionalProperties: false
                generationConfig:
                  type: object
                  description: 이미지 생성 설정.
                  properties:
                    responseModalities:
                      type: array
                      description: 이미지 출력을 명시하세요.
                      items:
                        type: string
                        enum:
                          - IMAGE
                      default:
                        - IMAGE
                    candidateCount:
                      type: integer
                      enum:
                        - 1
                      default: 1
                      description: 생략하거나 정수 1을 사용하세요. 루트에 n을 넣지 마세요.
                    imageConfig:
                      type: object
                      description: 출력 이미지 설정.
                      properties:
                        imageSize:
                          type: string
                          description: 출력 해상도. 대문자 K를 사용하세요.
                          enum:
                            - 1K
                            - 2K
                            - 4K
                          default: 1K
                        aspectRatio:
                          type: string
                          description: 비율. Pro는 10개, 2와 2.1은 1:4, 4:1, 1:8, 8:1도 지원합니다.
                          enum:
                            - '1:1'
                            - '1:4'
                            - '1:8'
                            - '2:3'
                            - '3:2'
                            - '3:4'
                            - '4:1'
                            - '4:3'
                            - '4:5'
                            - '5:4'
                            - '8:1'
                            - '9:16'
                            - '16:9'
                            - '21:9'
                          default: '1:1'
                      additionalProperties: false
                  additionalProperties: false
              additionalProperties: false
            example:
              contents:
                - role: user
                  parts:
                    - text: 흰색 테이블 위 파란색 세라믹 머그잔의 스튜디오 제품 사진.
              generationConfig:
                responseModalities:
                  - IMAGE
                candidateCount: 1
                imageConfig:
                  imageSize: 1K
                  aspectRatio: '1:1'
      responses:
        '200':
          description: 생성 결과. 최종 이미지 part와 finishReason을 확인하세요.
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          properties:
                            role:
                              type: string
                            parts:
                              type: array
                              items:
                                type: object
                                properties:
                                  text:
                                    type: string
                                  thought:
                                    type: boolean
                                  thoughtSignature:
                                    type: string
                                  inlineData:
                                    type: object
                                    properties:
                                      mimeType:
                                        type: string
                                      data:
                                        type: string
                                        contentEncoding: base64
                        finishReason:
                          type: string
                  promptFeedback:
                    type: object
                    additionalProperties: true
                  usageMetadata:
                    type: object
                    additionalProperties: true
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - inlineData:
                            mimeType: image/png
                            data: BASE64_IMAGE_DATA
                    finishReason: STOP
        '400':
          description: 잘못된 매개변수 또는 미지원 기능.
        '401':
          description: API Key 누락 또는 무효.
        '402':
          description: 잔액 부족.
        '429':
          description: 요청 제한 또는 상위 서비스 혼잡.
        '500':
          description: 생성 오류. 재시도 전에 결과를 확인하세요.
components:
  securitySchemes:
    geminiApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: BetterToken API Key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.