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

# Generate images with Gemini

> Generate or edit images synchronously with Google native image models through the GENGEN Image API.

Use the normalized GENGEN request schema with one of these public model IDs:

* `gemini-3-pro-image`
* `gemini-3.1-flash-image`
* `gemini-3.1-flash-lite-image`

| Property | Value |
| - | - |
| Method | `POST` |
| Endpoint | `/api/gengen/v1/images/generations` |
| Processing | Synchronous |
| Output | Public HTTPS URLs in `outputs.images` |
| URL retention | 24 hours |

## Text-to-image request

```bash theme={"dark"}
curl --request POST \
  --url https://gengen.farm/api/gengen/v1/images/generations \
  --header 'Authorization: Bearer gengen_live_xxxxxxxxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gemini-3.1-flash-image",
    "prompt": "A cyan greenhouse at sunrise, editorial photography",
    "controls": {
      "size": "1K",
      "aspectRatio": "16:9"
    }
  }'
```

## Image editing request

Add public or signed HTTPS URLs, or Base64 data URLs, under `assets.referenceImages`. Raw `gs://` URIs are not accepted; use a signed HTTPS URL instead.

```bash theme={"dark"}
curl --request POST \
  --url https://gengen.farm/api/gengen/v1/images/generations \
  --header 'Authorization: Bearer gengen_live_xxxxxxxxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gemini-3-pro-image",
    "prompt": "Keep the product unchanged and replace the background with a clean studio scene.",
    "assets": {
      "referenceImages": [
        "https://example.com/product.png"
      ]
    },
    "controls": {
      "size": "2K",
      "aspectRatio": "1:1"
    }
  }'
```

## Response

Read generated media from `outputs.images`. Google image responses are URL-only: GENGEN stores each generated image in a dedicated Vercel Blob path and never returns the generated image as Base64. Each URL is retained for 24 hours. The response uses only the normalized top-level fields shown below; duplicate compatibility aliases and provider billing usage are omitted.

```json theme={"dark"}
{
  "id": "image:550e8400-e29b-41d4-a716-446655440000",
  "model": "gemini-3.1-flash-image",
  "status": "succeeded",
  "outputs": {
    "images": [
      "https://example.public.blob.vercel-storage.com/gengen/google-generated-images/2026/08/21/image_550e8400/01-example.png"
    ],
    "expiresAt": "2026-08-22T08:00:00.000Z"
  }
}
```

<Warning>
  Generated image URLs expire after 24 hours. Download or copy every image to storage you control before `outputs.expiresAt`.
</Warning>

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `model` | string | Required Google native image model ID. |
| `prompt` | string | Generation or editing instruction. Required unless at least one reference image is supplied. |
| `assets.referenceImages` | string\[] | Up to 14 public or signed HTTPS URLs, or Base64 reference images. Raw `gs://` URIs are not accepted. |
| `controls.size` | string | Pro: `1K`, `2K`, `4K`; Nano Banana 2: `512`, `1K`, `2K`, `4K`; Lite: `1K`. |
| `controls.aspectRatio` | string | Supports `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`, `1:4`, `4:1`, and `1:8`/`8:1`. Pro and Nano Banana 2 also support `9:21`; Lite does not. |
| `providerOptions.google.generationConfig` | object | Advanced Google image sampling settings such as `temperature` and `topP`. |
| `providerOptions.google.safetySettings` | array | Vertex AI safety settings forwarded to Google. |

GENGEN fixes `candidateCount` to `1`; request multiple alternatives with separate calls. Reference image formats are PNG, JPEG, WebP, HEIC, and HEIF.

<Note>
  Supported sizes vary by model: Nano Banana Pro (Gemini 3 Pro Image) supports `1K`, `2K`, and `4K`; Nano Banana 2 (Gemini 3.1 Flash Image) supports `512`, `1K`, `2K`, and `4K`; Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) supports `1K`.
</Note>

See the [Google model pages](/models/gemini-3.1-flash-image) for detailed capabilities.


## OpenAPI

````yaml openapi/google.yaml POST /images/generations
openapi: 3.1.0
info:
  title: Google models API
  version: 1.0.0
  description: GENGEN endpoints backed by Google Gemini models on Vertex AI.
servers:
  - url: https://gengen.farm/api/gengen/v1
    description: Production
security:
  - bearerAuth: []
paths:
  /images/generations:
    post:
      summary: Generate or edit an image with Gemini
      description: >-
        Generate or edit an image synchronously with a Google native image
        model.
      operationId: createGoogleImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GoogleImageRequest'
            example:
              model: gemini-3.1-flash-image
              prompt: A cyan greenhouse at sunrise, editorial photography
              controls:
                size: 1K
                aspectRatio: '16:9'
      responses:
        '200':
          description: The generated image URLs and their expiry time.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResult'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    GoogleImageRequest:
      type: object
      required:
        - model
      anyOf:
        - required:
            - prompt
        - required:
            - assets
      properties:
        model:
          type: string
          enum:
            - gemini-3-pro-image
            - gemini-3.1-flash-image
            - gemini-3.1-flash-lite-image
          description: Google native image model ID.
        prompt:
          type: string
          description: Generation or editing instruction.
        assets:
          type: object
          properties:
            referenceImages:
              type: array
              maxItems: 14
              description: >-
                Public or signed HTTPS URLs, or Base64 reference images. Raw
                `gs://` URIs are not accepted. Google supports at most 14.
              items:
                type: string
        controls:
          type: object
          properties:
            size:
              type: string
              enum:
                - '512'
                - 1K
                - 2K
                - 4K
              description: >-
                Nano Banana Pro supports 1K/2K/4K; Nano Banana 2 supports
                512/1K/2K/4K; Lite supports 1K.
            aspectRatio:
              type: string
              enum:
                - '1:1'
                - '2:3'
                - '3:2'
                - '3:4'
                - '4:3'
                - '4:5'
                - '5:4'
                - '9:16'
                - '16:9'
                - '21:9'
                - '1:4'
                - '4:1'
                - '1:8'
                - '8:1'
                - '9:21'
              description: >-
                Requested output aspect ratio. `9:21` is supported by Pro and
                Nano Banana 2, but not Lite.
        providerOptions:
          type: object
          properties:
            google:
              type: object
              properties:
                generationConfig:
                  type: object
                  description: >-
                    Additional Vertex AI generation settings. Output modalities
                    and candidate count remain fixed by GENGEN.
                  properties:
                    temperature:
                      type: number
                    topP:
                      type: number
                      minimum: 0
                      maximum: 1
                safetySettings:
                  type: array
                  items:
                    type: object
                    additionalProperties: true
    ImageResult:
      type: object
      required:
        - id
        - model
        - status
        - outputs
      properties:
        id:
          type: string
        model:
          type: string
        status:
          type: string
          const: succeeded
        outputs:
          type: object
          required:
            - images
            - expiresAt
          properties:
            images:
              type: array
              items:
                type: string
            text:
              type: string
            expiresAt:
              type: string
              format: date-time
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
  responses:
    Error:
      description: The request could not be completed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: GENGEN API key
      description: A workspace API key beginning with `gengen_live_`.

````