Google: Gemini 3.1 Flash Image (Nano Banana 2)
google-ai.image-gen.gemini-3-1-flash-imageGenerate or edit one image with Gemini 3.1 Flash Image at 512px, 1K, 2K or 4K on Google's own API, from a prompt and optional reference images; the image returns inline as base64.
- Price
- $0.165/successAl precio del proveedor
- Success rate
- 99,2 %Last 30 days · 1058 calls
- Latency p50
- 11 sp95 23 s
- Last verified
- 30 sept 2026Verified working
POSThttps://toolswitch.dev/v1/tools/google-ai.image-gen.gemini-3-1-flash-image?fields=candidates%28content%28parts%28text%2CinlineData%29%29%2CfinishReason%29%2CusageMetadata%2CmodelVersion%2CresponseId%2CpromptFeedbackPreview- Uses platform quota
- Synchronous response
- Reads public data
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción | Ejemplo |
|---|---|---|---|---|
| Parámetros de ruta | ||||
model | cadena | Obligatorio | gemini-3.1-flash-image is the stable model; the -preview alias is the same model at the same price. | gemini-3.1-flash-image |
| Parámetros de consulta | ||||
fields | cadena | Opcional | Google's partial-response mask; the example drops the multi-megabyte thoughtSignature. Keep usageMetadata in any mask you send. | candidates(content(parts(text,inlineData)),finishReason),usageMetadata,modelVersion,responseId,promptFeedback |
- Parámetros de ruta
modelcadenaObligatoriogemini-3.1-flash-image is the stable model; the -preview alias is the same model at the same price.
Ejemplo:
gemini-3.1-flash-image- Parámetros de consulta
fieldscadenaOpcionalGoogle's partial-response mask; the example drops the multi-megabyte thoughtSignature. Keep usageMetadata in any mask you send.
Ejemplo:
candidates(content(parts(text,inlineData)),finishReason),usageMetadata,modelVersion,responseId,promptFeedback
Ejemplos de código
Sustituye $TOOLSWITCH_KEY por la clave que creaste en la consola.
curl -X POST 'https://toolswitch.dev/v1/tools/google-ai.image-gen.gemini-3-1-flash-image?fields=candidates%28content%28parts%28text%2CinlineData%29%29%2CfinishReason%29%2CusageMetadata%2CmodelVersion%2CresponseId%2CpromptFeedback' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"contents":[{"parts":[{"text":"A clean editorial illustration of a paper airplane."}]}],"generationConfig":{"imageConfig":{"imageSize":"1K","aspectRatio":"1:1"},"responseModalities":["IMAGE"]}}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/google-ai.image-gen.gemini-3-1-flash-image?fields=candidates%28content%28parts%28text%2CinlineData%29%29%2CfinishReason%29%2CusageMetadata%2CmodelVersion%2CresponseId%2CpromptFeedback",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"contents\":[{\"parts\":[{\"text\":\"A clean editorial illustration of a paper airplane.\"}]}],\"generationConfig\":{\"imageConfig\":{\"imageSize\":\"1K\",\"aspectRatio\":\"1:1\"},\"responseModalities\":[\"IMAGE\"]}}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/google-ai.image-gen.gemini-3-1-flash-image?fields=candidates%28content%28parts%28text%2CinlineData%29%29%2CfinishReason%29%2CusageMetadata%2CmodelVersion%2CresponseId%2CpromptFeedback", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"contents\":[{\"parts\":[{\"text\":\"A clean editorial illustration of a paper airplane.\"}]}],\"generationConfig\":{\"imageConfig\":{\"imageSize\":\"1K\",\"aspectRatio\":\"1:1\"},\"responseModalities\":[\"IMAGE\"]}}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());La API de la pasarela está en versión preliminar; su URL y autenticación pueden cambiar. Los parámetros del ejemplo son datos de muestra. Las llamadas se facturan a $0.165/success, incluida la tarifa de servicio.