# Nano Banana 2 Image Generation

Source: https://docs.aicentos.com/en/nano-banana2

Language: en

> Generate images with gemini-3.1-flash-image-preview (Nano Banana 2) via aicentos — examples for the Gemini native format and the OpenAI-compatible format

This page shows request examples for generating images with **Nano Banana 2** (`gemini-3.1-flash-image-preview`) through aicentos. Both the **Gemini native format** and the **OpenAI-compatible format** are supported.

Through `imageConfig` you can specify the aspect ratio (`aspectRatio`) and resolution (`imageSize`, e.g. `2K`, `4K`).

## Gemini native format

Generate a 1:1 4K image:

```bash
export AICENTOS_API_KEY="sk-your-API-Key"

curl --location --request POST 'https://aicentos.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent' \
--header "x-goog-api-key: $AICENTOS_API_KEY" \
--header 'content-type: application/json' \
--header 'Accept: */*' \
--data-raw '{
  "contents": [
    {
      "parts": [
        {
          "text": "Retro promotional poster style, highlighting Chinese text, with a red and yellow radial burst background. At the center, a beautiful young woman drawn in a refined vintage style, smiling, elegant and approachable. The theme is an ad promotion for the latest AI painting service, 4K resolution\n"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "image"
    ],
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "4K"
    }
  }
}'
```

## OpenAI-compatible format

Generate a 9:16 2K image:

```bash
export AICENTOS_API_KEY="sk-your-API-Key"

curl --location --request POST 'https://aicentos.com/v1/chat/completions' \
--header "Authorization: Bearer $AICENTOS_API_KEY" \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--data-raw '{
    "model": "gemini-3.1-flash-image-preview",
    "extra_body": {
        "imageConfig": {
            "aspectRatio": "9:16",
            "imageSize": "2K"
        }
    },
    "messages": [
        {
            "role": "system",
            "content": "{\"imageConfig\": {\"aspectRatio\": \"9:16\", \"imageSize\": \"2K\"}}"
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Draw an auspicious Year of the Horse"
                }
            ]
        }
    ],
    "max_tokens": 4096,
    "temperature": 0.8
}'
```

## Parameters

* `aspectRatio`: aspect ratio, e.g. `1:1`, `9:16`, `16:9`.
* `imageSize`: resolution, e.g. `2K`, `4K`.
* The Gemini native format authenticates with `x-goog-api-key`; the OpenAI-compatible format authenticates with `Authorization: Bearer`.
* In the OpenAI-compatible format, `imageConfig` can go either in `extra_body` or in the JSON of the `system` message.
* Replace `sk-your-API-Key` in the examples with the API Key you created in the aicentos console.