gemini-nano-banana-2.1 is a Gemini series image generation/editing model that supports text-to-image and multi-image reference editing (face swapping, outfit changing, style transfer, etc.).generateContentinlineData (base64) in candidates[0].content.parts[]; returns image URL when response_format: "url" is passed (only non-streaming)imageConfig.imageSize only supports 1K / 2K / 4K, default is 1K, does not support 512imageConfig.aspectRatio supports 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 4:5, 5:4, 1:4, 4:1, 1:8, 8:1, 21:9thinkingConfig.thinkingLevel only supports minimal / high, does not support thinkingBudget; can also use model name suffix -thinking / -nothinkingcurl --location 'https://api.key4u.vn/v1beta/models/gemini-nano-banana-2.1:generateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"parts": [
{
"text": "Completely replace the face and hair of the person in Figure 2 with those of the person in Figure 1: the facial features and facial details must come entirely from Figure 1, with none of Figure 2'\''s facial characteristics retained; adjust the face angle to match the head pose in Figure 2; keep the clothing, body except for hair accessories, and background in Figure 2 unchanged; blend the skin tone, lighting, and shadows naturally, with no visible compositing seams; photorealistic style."
},
{
"text": "Reference Image 1 (\"Image 1\" in the prompt):"
},
{
"inlineData": {
"data": "<Base64 of Figure 1, excluding the data:image/jpeg;base64, prefix>",
"mimeType": "image/jpeg"
}
},
{
"text": "Reference Figure 2 (\"Figure 2\" in the prompt):"
},
{
"inlineData": {
"data": "<Base64 of Figure 2, excluding the data:image/jpeg;base64, prefix>",
"mimeType": "image/jpeg"
}
}
],
"role": "user"
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "3:4",
"imageSize": "2K"
},
"responseModalities": [
"TEXT",
"IMAGE"
]
},
"response_format": "base64"
}'{
"candidates": [
{
"content": {
"parts": [
{
"text": "The face from Figure 1 has been placed onto Figure 2, while preserving the clothing and background from Figure 2."
},
{
"inlineData": {
"data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/...(truncated)",
"mimeType": "image/jpeg"
}
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"modelVersion": "gemini-nano-banana-2.1",
"responseId": "abc123xyz",
"usageMetadata": {
"candidatesTokenCount": 1290,
"promptTokenCount": 1083,
"totalTokenCount": 2373
}
}