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

# Generate content

> Send the prompt and reference images in `contents`; generated images come back as Base64 in `candidates[].content.parts[].inlineData`, possibly alongside text. The request is synchronous and usually takes 5–60 seconds.



## OpenAPI

````yaml /openapi/en/gemini-nano-banana-2-1.json post /v1beta/models/gemini-nano-banana-2.1:generateContent
openapi: 3.1.0
info:
  description: >-
    Nano Banana 2.1: Google's latest high-efficiency model for image generation
    and conversational editing, with better image quality and text rendering, up
    to 4K.
  title: Gemini Nano Banana 2.1
  version: v1beta
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
  - googApiKey: []
tags:
  - name: Gemini Nano Banana 2.1
paths:
  /v1beta/models/gemini-nano-banana-2.1:generateContent:
    post:
      tags:
        - Gemini Nano Banana 2.1
      summary: Generate content
      description: >-
        Send the prompt and reference images in `contents`; generated images
        come back as Base64 in `candidates[].content.parts[].inlineData`,
        possibly alongside text. The request is synchronous and usually takes
        5–60 seconds.
      operationId: geminiImageGenerateContent
      requestBody:
        content:
          application/json:
            examples:
              Text to image:
                description: >-
                  Send the prompt in `contents` and set the aspect ratio in
                  `imageConfig`.
                summary: Text to image
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            An elegant dessert in a fancy banana-themed
                            restaurant, soft lighting, food photography
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    imageConfig:
                      aspectRatio: '16:9'
                      imageSize: 2K
              Edit an image (Base64):
                description: >-
                  Send the image to edit as Base64 in `inlineData` and describe
                  the change in the prompt.
                summary: Edit an image (Base64)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Replace the background with a neon street after
                            rain; keep the person unchanged
                        - inlineData:
                            mimeType: image/png
                            data: <BASE64_IMAGE_DATA>
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    imageConfig:
                      aspectRatio: '1:1'
                      imageSize: 1K
              Edit an image (image link):
                description: Pass a public `https` image link in `fileData.fileUri`.
                summary: Edit an image (image link)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Remove the stains on the top of the keyboard and
                            keep everything else
                        - fileData:
                            fileUri: https://your-cdn.example.com/keyboard.png
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    imageConfig:
                      aspectRatio: '4:3'
                      imageSize: 1K
              Combine images:
                description: >-
                  Send several reference images in order and say what each one
                  is for; 4K output.
                summary: Combine images
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Put the dress from the second image on the model
                            from the first image; outdoor natural light,
                            full-body shot
                        - fileData:
                            fileUri: https://your-cdn.example.com/model.png
                        - fileData:
                            fileUri: https://your-cdn.example.com/dress.png
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    imageConfig:
                      aspectRatio: '9:16'
                      imageSize: 4K
            schema:
              $ref: '#/components/schemas/GeminiImageRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                example:
                  value:
                    candidates:
                      - content:
                          role: model
                          parts:
                            - inlineData:
                                mimeType: image/png
                                data: <BASE64_IMAGE_DATA>
                        finishReason: STOP
                        index: 0
                    usageMetadata:
                      promptTokenCount: 18
                      candidatesTokenCount: 1120
                      totalTokenCount: 1138
                      promptTokensDetails:
                        - modality: TEXT
                          tokenCount: 18
                      candidatesTokensDetails:
                        - modality: IMAGE
                          tokenCount: 1120
                    modelVersion: gemini-nano-banana-2.1
                    responseId: 8bQWadqLHo-vz7IPpLWdkQ4
              schema:
                $ref: '#/components/schemas/GeminiImageResponse'
          description: Content generated.
          headers:
            X-Request-Id:
              description: ID of this request; include it when reporting issues.
              schema:
                type: string
        '400':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: invalid_request
                      http_status: 400
                      message: Invalid request.
                      request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                      type: invalid_request_error
              schema:
                $ref: '#/components/schemas/ImageAPIErrorResponse'
          description: >-
            Invalid request: a required parameter is missing, a value is invalid
            or a parameter is not supported. Not charged.
        '401':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: unauthorized
                      http_status: 401
                      message: Unauthorized.
                      request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                      type: authentication_error
              schema:
                $ref: '#/components/schemas/ImageAPIErrorResponse'
          description: Missing or invalid API Key.
        '402':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: insufficient_balance
                      http_status: 402
                      message: Insufficient balance.
                      request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                      type: insufficient_balance_error
              schema:
                $ref: '#/components/schemas/ImageAPIErrorResponse'
          description: Insufficient balance.
        '429':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: rate_limit_exceeded
                      http_status: 429
                      message: Rate limit exceeded. Please try again later.
                      request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                      type: rate_limit_error
              schema:
                $ref: '#/components/schemas/ImageAPIErrorResponse'
          description: Too many requests; retry later.
        '502':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: service_unavailable
                      http_status: 502
                      message: Service temporarily unavailable. Please try again later.
                      request_id: req_7c1e9a4b2d3f5a6b8c9d0e1f
                      type: api_error
              schema:
                $ref: '#/components/schemas/ImageAPIErrorResponse'
          description: >-
            Upstream generation failed (including content moderation refusals).
            Not charged; you may retry.
components:
  schemas:
    GeminiImageRequest:
      additionalProperties: false
      description: Request body of generateContent.
      properties:
        contents:
          description: >-
            Conversation content. A single-turn request has one `user` item; for
            multi-turn edits send the turns in order.
          items:
            $ref: '#/components/schemas/GeminiImageContent'
          type: array
        generationConfig:
          $ref: '#/components/schemas/GeminiImageGenerationConfig'
          description: Generation config.
      required:
        - contents
      type: object
    GeminiImageResponse:
      additionalProperties: false
      description: generateContent response.
      properties:
        candidates:
          description: Generated candidates, usually one.
          items:
            $ref: '#/components/schemas/GeminiImageCandidate'
          type: array
        usageMetadata:
          $ref: '#/components/schemas/GeminiImageUsage'
          description: Token usage.
        modelVersion:
          description: Model version used.
          type: string
        responseId:
          description: Response ID.
          type: string
      required:
        - candidates
      type: object
    ImageAPIErrorResponse:
      additionalProperties: false
      description: Error response.
      properties:
        error:
          $ref: '#/components/schemas/ImageAPIError'
          description: Error details.
      required:
        - error
      type: object
    GeminiImageContent:
      additionalProperties: false
      description: One turn of content.
      properties:
        role:
          description: |-
            Author of the turn; default `user`.

            **Allowed values:**
            - `user`: The user.
            - `model`: The model (earlier replies in multi-turn edits).
          enum:
            - user
            - model
          type: string
        parts:
          description: >-
            Content parts in order; each part sets exactly one of `text`,
            `inlineData` or `fileData`.
          items:
            $ref: '#/components/schemas/GeminiImagePart'
          type: array
      required:
        - parts
      type: object
    GeminiImageGenerationConfig:
      additionalProperties: false
      description: Generation config.
      properties:
        responseModalities:
          description: >-
            Output modalities; text and images by default. Pass `["IMAGE"]` for
            images only.


            **Allowed values:**

            - `TEXT`: Text.

            - `IMAGE`: Images.
          items:
            enum:
              - TEXT
              - IMAGE
            type: string
          type: array
        imageConfig:
          $ref: '#/components/schemas/GeminiImageConfig'
          description: Image output config.
      type: object
    GeminiImageCandidate:
      additionalProperties: false
      description: One candidate.
      properties:
        content:
          $ref: '#/components/schemas/GeminiImageOutputContent'
          description: Generated content.
        finishReason:
          description: >-
            Why generation stopped.


            **Allowed values:**

            - `STOP`: Finished normally.

            - `MAX_TOKENS`: Hit the output token limit.

            - `SAFETY`: Stopped for safety reasons.

            - `PROHIBITED_CONTENT`: Prohibited content.

            - `IMAGE_SAFETY`: The generated image failed the safety check.

            - `IMAGE_PROHIBITED_CONTENT`: The generated image contains
            prohibited content.

            - `NO_IMAGE`: No image was generated; adjust the prompt and retry.

            - `OTHER`: Other reasons.
          enum:
            - STOP
            - MAX_TOKENS
            - SAFETY
            - PROHIBITED_CONTENT
            - IMAGE_SAFETY
            - IMAGE_PROHIBITED_CONTENT
            - NO_IMAGE
            - OTHER
          type: string
        index:
          description: Candidate index, from 0.
          format: int64
          type: integer
      required:
        - content
        - index
      type: object
    GeminiImageUsage:
      additionalProperties: false
      description: Token usage.
      properties:
        promptTokenCount:
          description: Input tokens (text and images).
          format: int64
          type: integer
        candidatesTokenCount:
          description: Output tokens.
          format: int64
          type: integer
        thoughtsTokenCount:
          description: Thinking tokens.
          format: int64
          type: integer
        totalTokenCount:
          description: Total tokens.
          format: int64
          type: integer
        promptTokensDetails:
          description: Input tokens by modality.
          items:
            $ref: '#/components/schemas/GeminiImageTokenCount'
          type: array
        candidatesTokensDetails:
          description: Output tokens by modality.
          items:
            $ref: '#/components/schemas/GeminiImageTokenCount'
          type: array
      required:
        - promptTokenCount
        - candidatesTokenCount
        - totalTokenCount
      type: object
    ImageAPIError:
      additionalProperties: false
      description: Error details.
      properties:
        code:
          description: Error code.
          type: string
        http_status:
          description: HTTP status code.
          format: int64
          type: integer
        message:
          description: Human-readable error message.
          type: string
        request_id:
          description: Request ID; include it when reporting issues.
          type: string
        type:
          description: |-
            Error type.

            **Allowed values:**
            - `invalid_request_error`: Invalid request.
            - `authentication_error`: Authentication failed.
            - `insufficient_balance_error`: Insufficient balance.
            - `permission_error`: Permission denied.
            - `rate_limit_error`: Rate limited.
            - `api_error`: Server or upstream error.
          enum:
            - invalid_request_error
            - authentication_error
            - insufficient_balance_error
            - permission_error
            - rate_limit_error
            - api_error
          type: string
      required:
        - code
        - http_status
        - message
        - request_id
        - type
      type: object
    GeminiImagePart:
      additionalProperties: false
      description: One content part.
      properties:
        text:
          description: Text (the prompt).
          type: string
        inlineData:
          $ref: '#/components/schemas/GeminiImageInlineData'
          description: An image inlined as Base64.
        fileData:
          $ref: '#/components/schemas/GeminiImageFileData'
          description: An image referenced by link.
      type: object
    GeminiImageConfig:
      additionalProperties: false
      description: Image output config.
      properties:
        aspectRatio:
          description: >-
            Output aspect ratio. When omitted, `1:1` for text-to-image and the
            input image's ratio for edits.


            **Allowed values:**

            - `1:1`: Square; 1024x1024 at 1K.

            - `1:4`: Extra tall; 512x2048 at 1K.

            - `1:8`: Extreme tall; 384x3072 at 1K.

            - `2:3`: Portrait; 848x1264 at 1K.

            - `3:2`: Landscape; 1264x848 at 1K.

            - `3:4`: Portrait; 896x1200 at 1K.

            - `4:1`: Extra wide; 2048x512 at 1K.

            - `4:3`: Landscape; 1200x896 at 1K.

            - `4:5`: Portrait; 928x1152 at 1K.

            - `5:4`: Landscape; 1152x928 at 1K.

            - `8:1`: Extreme wide; 3072x384 at 1K.

            - `9:16`: Vertical; 768x1376 at 1K.

            - `16:9`: Widescreen; 1376x768 at 1K.

            - `21:9`: Ultra-wide; 1584x672 at 1K.
          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'
          type: string
        imageSize:
          description: >-
            Output resolution tier, default `1K`; the `K` must be uppercase
            (lowercase is rejected).


            **Allowed values:**

            - `1K`: 1K (default); 1024x1024 for 1:1.

            - `2K`: 2K; 2048x2048 for 1:1.

            - `4K`: 4K; 4096x4096 for 1:1.
          enum:
            - 1K
            - 2K
            - 4K
          type: string
      type: object
    GeminiImageOutputContent:
      additionalProperties: false
      description: Model output content.
      properties:
        role:
          description: |-
            Always `model`.

            **Allowed values:**
            - `user`: The user.
            - `model`: The model (earlier replies in multi-turn edits).
          enum:
            - user
            - model
          type: string
        parts:
          description: 'Output parts: text and images in order.'
          items:
            $ref: '#/components/schemas/GeminiImageOutputPart'
          type: array
      required:
        - role
        - parts
      type: object
    GeminiImageTokenCount:
      additionalProperties: false
      description: Tokens of one modality.
      properties:
        modality:
          description: |-
            Modality.

            **Allowed values:**
            - `TEXT`: Text.
            - `IMAGE`: Images.
          enum:
            - TEXT
            - IMAGE
          type: string
        tokenCount:
          description: Token count.
          format: int64
          type: integer
      required:
        - modality
        - tokenCount
      type: object
    GeminiImageInlineData:
      additionalProperties: false
      description: Inline image data.
      properties:
        mimeType:
          description: |-
            Image MIME type.

            **Allowed values:**
            - `image/png`: PNG.
            - `image/jpeg`: JPEG.
            - `image/webp`: WebP.
            - `image/heic`: HEIC.
            - `image/heif`: HEIF.
          enum:
            - image/png
            - image/jpeg
            - image/webp
            - image/heic
            - image/heif
          type: string
        data:
          description: Base64 image data (no `data:` prefix).
          type: string
      required:
        - mimeType
        - data
      type: object
    GeminiImageFileData:
      additionalProperties: false
      description: Image link.
      properties:
        fileUri:
          description: A publicly downloadable `https` image link.
          type: string
      required:
        - fileUri
      type: object
    GeminiImageOutputPart:
      additionalProperties: false
      description: One output part.
      properties:
        text:
          description: Text returned by the model.
          type: string
        inlineData:
          $ref: '#/components/schemas/GeminiImageOutputInlineData'
          description: A generated image.
        thought:
          description: >-
            `true` when the part is part of the model's thinking, not the final
            result.
          type: boolean
        thoughtSignature:
          description: >-
            Thought signature. For multi-turn edits, send the model's parts back
            in `contents` unchanged.
          type: string
      type: object
    GeminiImageOutputInlineData:
      additionalProperties: false
      description: Image data.
      properties:
        mimeType:
          description: Image MIME type, e.g. `image/png`.
          type: string
        data:
          description: Base64 image data.
          type: string
      required:
        - mimeType
        - data
      type: object
  securitySchemes:
    bearerAuth:
      description: >-
        API Key created in the DreamTo console, sent as `Authorization: Bearer
        <API Key>`.
      scheme: bearer
      type: http
    googApiKey:
      description: >-
        The DreamTo API Key can also be sent in the `x-goog-api-key` header, the
        way the Google SDKs do by default.
      in: header
      name: x-goog-api-key
      type: apiKey

````

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