> ## 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-3.1-flash-image

> Generate images using Gemini model.



## OpenAPI

````yaml api-reference/model-api/google/openapi/gemini-3.1-flash-image/openapi.yaml POST /v1beta/models/gemini-3.1-flash-image:generateContent
openapi: 3.1.0
info:
  title: Gemini 3.1 Flash Image
  description: Google Gemini 3.1 Flash Image via Anyfast proxy
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security: []
paths:
  /v1beta/models/gemini-3.1-flash-image:generateContent:
    post:
      summary: Image Generation
      description: Generate images using Gemini model.
      operationId: Gemini31FlashImageGenerateImage
      parameters:
        - name: key
          in: query
          description: API Key
          required: true
          schema:
            type: string
          example: YOUR_API_KEY
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
                - generationConfig
              properties:
                contents:
                  type: array
                  description: >
                    Array of conversation turns. Each turn has a role and parts.
                    A part can be a text prompt, or an inline_data image
                    (base64). To use a reference image, include both a text part
                    and an inline_data part in the same parts array.
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - model
                        example: user
                      parts:
                        type: array
                        description: >
                          List of content parts. Combine text and inline_data in
                          the same array to send a prompt alongside a reference
                          image.
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: Text prompt
                              example: >-
                                Hi, this is a picture of me. Can you add a llama
                                next to me?
                            inline_data:
                              type: object
                              description: >
                                Reference image encoded as base64. Replace
                                `data` with your actual base64-encoded image
                                string.
                              properties:
                                mime_type:
                                  type: string
                                  description: >-
                                    MIME type of the image. Supported:
                                    image/jpeg, image/png, image/webp
                                  enum:
                                    - image/jpeg
                                    - image/png
                                    - image/webp
                                  example: image/jpeg
                                data:
                                  type: string
                                  description: >
                                    Base64-encoded image data. Paste your base64
                                    string here. Example: convert your image
                                    with `base64 image.jpg` or use an online
                                    tool.
                                  example: >-
                                    iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                  example:
                    - role: user
                      parts:
                        - text: >-
                            Hi, this is a picture of me. Can you add a llama
                            next to me?
                        - inline_data:
                            mime_type: image/jpeg
                            data: >-
                              iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                generationConfig:
                  type: object
                  required:
                    - responseModalities
                  properties:
                    responseModalities:
                      type: array
                      description: >
                        Output modalities. Use ["IMAGE"] for image-only output,
                        or ["TEXT", "IMAGE"] to receive both a caption and the
                        image.
                      items:
                        type: string
                        enum:
                          - TEXT
                          - IMAGE
                      example:
                        - TEXT
                        - IMAGE
                    imageConfig:
                      type: object
                      description: Image generation configuration
                      properties:
                        aspectRatio:
                          type: string
                          description: |
                            Desired aspect ratio of the generated image.
                          enum:
                            - '1:1'
                            - '4:3'
                            - '3:4'
                            - '16:9'
                            - '9:16'
                          example: '9:16'
                        imageSize:
                          type: string
                          description: >
                            Resolution of the generated image. 512 ≈ 512px, 1K ≈
                            1024px, 2K ≈ 2048px, 4K ≈ 4096px on the long edge.
                          enum:
                            - '512'
                            - 1K
                            - 2K
                            - 4K
                          example: 1K
      responses:
        '200':
          description: Image generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateContentResponse'
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - text: Here is the image with a llama added next to you.
                        - inline_data:
                            mime_type: image/jpeg
                            data: >-
                              iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                    finishReason: STOP
                usageMetadata:
                  promptTokenCount: 10
                  candidatesTokenCount: 1
                  totalTokenCount: 11
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            type: object
            properties:
              content:
                type: object
                properties:
                  parts:
                    type: array
                    items:
                      type: object
                      properties:
                        text:
                          type: string
                          description: >-
                            Text caption (present when TEXT is in
                            responseModalities)
                        inline_data:
                          type: object
                          description: Generated image data
                          properties:
                            mime_type:
                              type: string
                              example: image/jpeg
                            data:
                              type: string
                              description: Base64-encoded generated image
                              example: >-
                                iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                  role:
                    type: string
                    example: model
              finishReason:
                type: string
                enum:
                  - STOP
                  - MAX_TOKENS
                  - SAFETY
                  - RECITATION
                  - OTHER
                example: STOP
        usageMetadata:
          type: object
          properties:
            promptTokenCount:
              type: integer
            candidatesTokenCount:
              type: integer
            totalTokenCount:
              type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string

````