# Gemini Nano Banana 2.1 Image Generation

> Image Generation

Send a text prompt to generate an image, or text and inline image data to edit an image. The response contains candidates and usage information.
Nano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.

## Endpoint

`POST https://api.modelverse.cn/v1beta/models/gemini-nano-banana-2.1:generateContent`

## Request Body

## Responses

- **200** — Candidate content; inspect finishReason and promptFeedback to determine whether an image was generated.
- **400** — Invalid request parameters.
Nano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.

- **default** — Error response.

## OpenAPI Definition

```json
{
  "openapi": "3.1.0",
  "x-language": "en-US",
  "info": {
    "title": "Gemini Nano Banana 2.1 Image Generation and Editing API",
    "version": "1.0.0",
    "description": "Call `gemini-nano-banana-2.1` through the ModelVerse Gemini-compatible API for text-to-image generation and image editing.\nNano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.\nOfficial specifications: supports 1K, 2K, and 4K resolutions; do not reuse Nano Banana 2 examples with imageSize 512. Up to 14 input images per prompt, with a maximum of 7 MB per inline image. The context window is 131,072 tokens and the output limit is 32,768 tokens.\n"
  },
  "externalDocs": {
    "description": "Official Google model documentation",
    "url": "https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/nano-banana-2-1"
  },
  "servers": [
    {
      "url": "https://api-us-ca.umodelverse.ai",
      "description": "ModelVerse API"
    }
  ],
  "tags": [
    {
      "name": "gemini-nano-banana-2.1",
      "description": "Gemini-compatible image generation and editing."
    }
  ],
  "security": [
    {
      "geminiApiKeyAuth": []
    }
  ],
  "paths": {
    "/v1beta/models/gemini-nano-banana-2.1:generateContent": {
      "post": {
        "tags": [
          "gemini-nano-banana-2.1"
        ],
        "operationId": "generateGeminiNanoBanana21Content",
        "summary": "Gemini Nano Banana 2.1 Image Generation",
        "description": "Send a text prompt to generate an image, or text and inline image data to edit an image. The response contains candidates and usage information.\nNano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateContentRequest"
              },
              "examples": {
                "textToImage": {
                  "summary": "1K text-to-image generation",
                  "value": {
                    "contents": [
                      {
                        "role": "user",
                        "parts": [
                          {
                            "text": "Create a watercolor painting of a small orange cat in a garden."
                          }
                        ]
                      }
                    ],
                    "generationConfig": {
                      "responseModalities": [
                        "TEXT",
                        "IMAGE"
                      ],
                      "imageConfig": {
                        "aspectRatio": "1:1",
                        "imageSize": "1K"
                      }
                    }
                  }
                },
                "imageEditing": {
                  "summary": "2K image editing (replace the Base64 placeholder)",
                  "value": {
                    "contents": [
                      {
                        "role": "user",
                        "parts": [
                          {
                            "text": "Turn this photo into a watercolor painting."
                          },
                          {
                            "inlineData": {
                              "mimeType": "image/jpeg",
                              "data": "<BASE64_IMAGE_DATA>"
                            }
                          }
                        ]
                      }
                    ],
                    "generationConfig": {
                      "responseModalities": [
                        "TEXT",
                        "IMAGE"
                      ],
                      "imageConfig": {
                        "aspectRatio": "1:1",
                        "imageSize": "2K"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Candidate content; inspect finishReason and promptFeedback to determine whether an image was generated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateContentResponse"
                },
                "examples": {
                  "generatedImage": {
                    "summary": "Illustrative image response (image data abbreviated)",
                    "value": {
                      "candidates": [
                        {
                          "content": {
                            "role": "model",
                            "parts": [
                              {
                                "inlineData": {
                                  "mimeType": "image/png",
                                  "data": "<BASE64_IMAGE_DATA>"
                                }
                              }
                            ]
                          },
                          "finishReason": "STOP"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters.\nNano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "default": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "geminiApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-goog-api-key",
        "description": "ModelVerse API Key"
      }
    },
    "schemas": {
      "GenerateContentRequest": {
        "type": "object",
        "required": [
          "contents"
        ],
        "properties": {
          "contents": {
            "type": "array",
            "minItems": 1,
            "description": "Request messages containing text or images.",
            "items": {
              "$ref": "#/components/schemas/RequestContent"
            }
          },
          "generationConfig": {
            "$ref": "#/components/schemas/GenerationConfig"
          }
        }
      },
      "RequestContent": {
        "type": "object",
        "required": [
          "parts"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "model"
            ],
            "description": "Message role; the single-turn examples use user."
          },
          "parts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/RequestPart"
            }
          }
        }
      },
      "RequestPart": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "text"
            ]
          },
          {
            "required": [
              "inlineData"
            ]
          }
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "Prompt for image generation or editing."
          },
          "inlineData": {
            "$ref": "#/components/schemas/InputImage"
          }
        }
      },
      "InputImage": {
        "type": "object",
        "required": [
          "mimeType",
          "data"
        ],
        "properties": {
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/heic",
              "image/heif"
            ],
            "description": "Input image MIME type."
          },
          "data": {
            "type": "string",
            "description": "Base64-encoded image bytes without a data URI prefix; maximum 7 MB per inline image."
          }
        }
      },
      "GenerationConfig": {
        "type": "object",
        "description": "Nano Banana 2.1 does not support `seed`, `topK`, `logprobs`, `temperature`, or `topP`. Setting any of these parameters returns an API error. Remove them from generationConfig and check whether your SDK or request wrapper adds them automatically.\n",
        "not": {
          "anyOf": [
            {
              "required": [
                "seed"
              ]
            },
            {
              "required": [
                "topK"
              ]
            },
            {
              "required": [
                "logprobs"
              ]
            },
            {
              "required": [
                "temperature"
              ]
            },
            {
              "required": [
                "topP"
              ]
            }
          ]
        },
        "properties": {
          "responseModalities": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "description": "Requested response modalities; the examples use TEXT and IMAGE.",
            "items": {
              "type": "string",
              "enum": [
                "TEXT",
                "IMAGE"
              ]
            },
            "examples": [
              [
                "TEXT",
                "IMAGE"
              ]
            ]
          },
          "imageConfig": {
            "$ref": "#/components/schemas/ImageConfig"
          }
        }
      },
      "ImageConfig": {
        "type": "object",
        "properties": {
          "aspectRatio": {
            "type": "string",
            "description": "Output image aspect ratio.",
            "enum": [
              "1:1",
              "3:2",
              "2:3",
              "3:4",
              "1:4",
              "4:1",
              "4:3",
              "4:5",
              "5:4",
              "1:8",
              "8:1",
              "9:16",
              "16:9",
              "21:9",
              "9:21"
            ]
          },
          "imageSize": {
            "type": "string",
            "description": "Output resolution with an uppercase K; the official documentation lists only 1K, 2K, and 4K.",
            "enum": [
              "1K",
              "2K",
              "4K"
            ]
          }
        }
      },
      "GenerateContentResponse": {
        "type": "object",
        "properties": {
          "candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Candidate"
            }
          },
          "promptFeedback": {
            "type": "object",
            "description": "Prompt feedback, such as why a request was blocked."
          },
          "usageMetadata": {
            "$ref": "#/components/schemas/UsageMetadata"
          }
        }
      },
      "Candidate": {
        "type": "object",
        "properties": {
          "content": {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "examples": [
                  "model"
                ]
              },
              "parts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ResponsePart"
                }
              }
            }
          },
          "finishReason": {
            "type": "string",
            "description": "Reason generation ended, such as STOP.",
            "examples": [
              "STOP"
            ]
          }
        }
      },
      "ResponsePart": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "Text returned by the model."
          },
          "inlineData": {
            "type": "object",
            "required": [
              "mimeType",
              "data"
            ],
            "properties": {
              "mimeType": {
                "type": "string",
                "examples": [
                  "image/png"
                ]
              },
              "data": {
                "type": "string",
                "description": "Base64-encoded output image."
              }
            }
          },
          "thought": {
            "type": "boolean",
            "description": "Whether this is a thought part; skip parts marked true when saving final images."
          },
          "thoughtSignature": {
            "type": "string",
            "description": "Thought signature returned by the model; preserve it in multi-turn conversations."
          }
        }
      },
      "UsageMetadata": {
        "type": "object",
        "properties": {
          "promptTokenCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Input token count."
          },
          "candidatesTokenCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Candidate token count."
          },
          "totalTokenCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Total token count."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "description": "Error details; fields depend on the error source.",
            "properties": {
              "message": {
                "type": "string",
                "description": "Error message."
              },
              "code": {
                "type": [
                  "string",
                  "integer"
                ],
                "description": "Error code."
              },
              "status": {
                "type": "string",
                "description": "Upstream error status, if returned."
              },
              "type": {
                "type": "string",
                "description": "Error type, if returned."
              },
              "param": {
                "type": "string",
                "description": "Related parameter or request identifier, if returned."
              }
            }
          }
        }
      }
    }
  }
}
```
