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

# gemini-nano-banana-2.1

> Generates image and optional text content from text, image, video, or PDF input.



## OpenAPI

````yaml api-reference/model-api/google/openapi/gemini-nano-banana-2-1/openapi.yaml POST /v1beta/models/gemini-nano-banana-2.1:generateContent
openapi: 3.1.0
info:
  title: Gemini Nano Banana 2.1
  description: >-
    Generate and edit images with Gemini Nano Banana 2.1 through the AnyFast
    native Gemini API.
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security: []
paths:
  /v1beta/models/gemini-nano-banana-2.1:generateContent:
    post:
      summary: Generate or edit an image
      description: >-
        Generates image and optional text content from text, image, video, or
        PDF input.
      operationId: GeminiNanoBanana21GenerateContent
      parameters:
        - name: key
          in: query
          required: true
          description: AnyFast API key.
          schema:
            type: string
          example: YOUR_API_KEY
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateContentRequest'
            examples:
              textToImage:
                summary: Text to image
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Create a clean 16:9 product poster for a translucent
                            blue mechanical keyboard.
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    responseFormat:
                      image:
                        aspectRatio: '16:9'
                        imageSize: 2K
              imageEditing:
                summary: Edit an image
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Keep the product unchanged and replace the
                            background with a warm wooden desk.
                        - inline_data:
                            mime_type: image/png
                            data: YOUR_BASE64_IMAGE_DATA
                  generationConfig:
                    responseModalities:
                      - IMAGE
                    responseFormat:
                      image:
                        aspectRatio: '4:3'
                        imageSize: 2K
      responses:
        '200':
          description: Content generated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateContentResponse'
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - text: Here is the generated product poster.
                        - inlineData:
                            mimeType: image/png
                            data: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ
                    finishReason: STOP
                usageMetadata:
                  promptTokenCount: 24
                  candidatesTokenCount: 1680
                  totalTokenCount: 1704
                modelVersion: gemini-nano-banana-2.1
                responseId: response_example
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >
            curl
            "https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:generateContent?key=YOUR_API_KEY"
            \
              -H "Content-Type: application/json" \
              -d '{
                "contents": [{
                  "role": "user",
                  "parts": [{
                    "text": "Create a clean 16:9 product poster for a translucent blue mechanical keyboard."
                  }]
                }],
                "generationConfig": {
                  "responseModalities": ["TEXT", "IMAGE"],
                  "thinkingConfig": {"thinkingLevel": "medium"},
                  "responseFormat": {
                    "image": {"aspectRatio": "16:9", "imageSize": "2K"}
                  }
                }
              }'
components:
  schemas:
    GenerateContentRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          minItems: 1
          description: Conversation turns containing prompts and reference media.
          items:
            $ref: '#/components/schemas/Content'
        generationConfig:
          $ref: '#/components/schemas/GenerationConfig'
    GenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/Candidate'
        promptFeedback:
          type: object
          additionalProperties: true
        usageMetadata:
          $ref: '#/components/schemas/UsageMetadata'
        modelVersion:
          type: string
          example: gemini-nano-banana-2.1
        responseId:
          type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string
    Content:
      type: object
      required:
        - parts
      properties:
        role:
          type: string
          enum:
            - user
            - model
          default: user
        parts:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Part'
    GenerationConfig:
      type: object
      properties:
        responseModalities:
          type: array
          description: >-
            Return image only, or both text and image. The model defaults to
            text and image.
          minItems: 1
          uniqueItems: true
          items:
            type: string
            enum:
              - TEXT
              - IMAGE
          example:
            - TEXT
            - IMAGE
        responseFormat:
          type: object
          properties:
            image:
              $ref: '#/components/schemas/ImageResponseFormat'
        thinkingConfig:
          $ref: '#/components/schemas/ThinkingConfig'
    Candidate:
      type: object
      properties:
        content:
          type: object
          properties:
            role:
              type: string
              example: model
            parts:
              type: array
              items:
                $ref: '#/components/schemas/ResponsePart'
        finishReason:
          type: string
          enum:
            - STOP
            - MAX_TOKENS
            - SAFETY
            - RECITATION
            - OTHER
        index:
          type: integer
        safetyRatings:
          type: array
          items:
            type: object
            additionalProperties: true
    UsageMetadata:
      type: object
      properties:
        promptTokenCount:
          type: integer
        candidatesTokenCount:
          type: integer
        totalTokenCount:
          type: integer
        thoughtsTokenCount:
          type: integer
    Part:
      type: object
      description: >-
        A text or media content part. Supply the field that matches the part
        type.
      properties:
        text:
          type: string
          description: Text prompt or editing instruction.
        inline_data:
          $ref: '#/components/schemas/InlineDataInput'
        file_data:
          $ref: '#/components/schemas/FileDataInput'
        video_metadata:
          $ref: '#/components/schemas/VideoMetadata'
    ImageResponseFormat:
      type: object
      properties:
        aspectRatio:
          type: string
          description: Output image aspect ratio.
          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'
          example: '16:9'
        imageSize:
          type: string
          description: Output resolution. The default is 1K.
          enum:
            - 1K
            - 2K
            - 4K
          default: 1K
    ThinkingConfig:
      type: object
      properties:
        thinkingLevel:
          type: string
          description: Thinking effort. The default is medium.
          enum:
            - minimal
            - medium
            - high
          default: medium
        includeThoughts:
          type: boolean
          default: false
          description: Whether thought parts may be included in the response.
    ResponsePart:
      type: object
      properties:
        text:
          type: string
        inlineData:
          type: object
          required:
            - mimeType
            - data
          properties:
            mimeType:
              type: string
              example: image/png
            data:
              type: string
              format: byte
              description: Base64-encoded generated image.
        thought:
          type: boolean
          description: >-
            True when the part contains model thinking rather than the final
            answer.
        thoughtSignature:
          type: string
          description: >-
            Opaque signature that must be preserved when continuing a
            conversation.
    InlineDataInput:
      type: object
      required:
        - mime_type
        - data
      description: Base64-encoded inline image, video, or PDF data.
      properties:
        mime_type:
          type: string
          description: MIME type of the encoded content.
          example: image/png
        data:
          type: string
          format: byte
          description: Base64-encoded bytes without a data URL prefix.
    FileDataInput:
      type: object
      required:
        - mime_type
        - file_uri
      description: A file previously uploaded through the Gemini Files API.
      properties:
        mime_type:
          type: string
          example: application/pdf
        file_uri:
          type: string
          description: >-
            URI returned by the file upload operation or a supported public
            video URI.
    VideoMetadata:
      type: object
      description: Optional controls for video input sampling.
      properties:
        fps:
          type: number
          exclusiveMinimum: 0
          example: 0.5

````

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