Docs Native format /v1beta/models/gemini-3.1-flash-lite-image:generateContent
API reference

gemini-3.1-flash-lite-image

Official docs: https://ai.google.dev/gemini-api/docs/image-generation — Gemini 3.1 Flash-Lite Image (Nano Banana 2 Lite) text-to-image, image-to-image, video-to-image, and image editing.

POST/v1beta/models/gemini-3.1-flash-lite-image:generateContent

Body Parametersapplication/json

contents* array

Conversation content list, required. At least 1 user message must be included when creating a graph; inlineData or fileData must be attached to parts when creating a graph/editing; historical messages must be appended in chronological order during multiple rounds of editing. Upstream constraints: The total input tokens do not exceed 65536; the single file input does not exceed 500MB.

items
object object
generationConfig object

Generate configuration. In raw image scenarios, responseModalities must contain IMAGE; imageConfig controls the aspect ratio and output format; thinkingConfig is optional.

properties
candidateCount integer

Number of candidate results. This model is fixed to 1, other values ​​passed in may be ignored or an error will be reported.

imageConfig object

Image generation configuration. This model only supports 1K output; 512px / 2K / 4K is not supported.

maxOutputTokens integer

The maximum number of output tokens. The model output is capped at 4096. Image output is charged at 1120 tokens/image.

responseModalities array

Output modal list. IMAGE must be included when generating a picture; if text description is also required, ["IMAGE", "TEXT"] can be passed. No image will be returned when only TEXT is passed.

temperature number

Sampling temperature. The higher the value, the more diverse the results. The upstream default is 1.0.

thinkingConfig object

Thinking mode configuration, optional. Do internal reasoning before using it in complex compositions. MINIMAL is suitable for low latency; HIGH is suitable for complex prompts. Think tokens count towards output billing.

topP number

Kernel sampling threshold. Upstream default value 0.95.

response_format string

Fill in the url and return the url, if not fill in the default base64

safetySettings array

Security settings, optional. Control the filtering thresholds for various types of harmful content.

items
object object
systemInstruction object

System command, optional. Used to constrain the output style, language, format, etc. When generating pictures, it is required to "output only descriptions related to pictures" or translation scenarios limit the output content.

properties
parts* array

List of content parts; may include text, inline_data / inlineData, etc.

Responses

200 application/json
response-200 object
properties
candidates* array

Model candidate replies

createTime* string

Response creation time

modelVersion* string

Actual model version used

responseId* string

Unique ID for this response

usageMetadata* object

Token usage metadata

400 Bad request or validation failed application/json
response-400 object
properties
error* object
401 Missing or invalid API Key application/json
response-401 object
Request Body Example Recommended for beginners · Vincentian picture · 1:1
1{
2"contents": [
3{
4"parts": [
5{
6"text": "A cute cat sitting on a wooden table, watercolor style."
7}
8],
9"role": "user"
10}
11],
12"generationConfig": {
13"imageConfig": {
14"aspectRatio": "1:1"
15},
16"responseModalities": [
17"IMAGE"
18]
19},
20"response_format": "url"
21}
Code Sample cURL
1curl -X POST "https://api.digislash.com/v1beta/models/gemini-3.1-flash-lite-image:generateContent" \
2-H "Authorization: Bearer <API Key>" \
3-H "Content-Type: application/json" \
4-d '{
5"contents": [
6{
7"parts": [
8{
9"text": "A cute cat sitting on a wooden table, watercolor style."
10}
11],
12"role": "user"
13}
14],
15"generationConfig": {
16"imageConfig": {
17"aspectRatio": "1:1"
18},
19"responseModalities": [
20"IMAGE"
21]
22},
23"response_format": "url"
24}'
Response
1▼{
2▼"candidates": [
3▶{ 2 keys }
4],
5"createTime": "string",
6"modelVersion": "string",
7"responseId": "string",
8▼"usageMetadata": {
9"candidatesTokenCount": 0,
10▶"candidatesTokensDetails": [ 1 items ],
11"promptTokenCount": 0,
12▶"promptTokensDetails": [ 1 items ],
13"totalTokenCount": 0,
14"trafficType": "string"
15}
16}