Google AI (Gemini API)Image GenerationAI generation

Google: Gemini 3.1 Flash Image (Nano Banana 2)

google-ai.image-gen.gemini-3-1-flash-image

Generate 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/successAt provider cost
Success rate
99.2%Last 30 days · 1,058 calls
Latency p50
11 sp95 23 s
Last verified
Sep 30, 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

Parameters

ParameterTypeRequiredDescriptionExample
Path parameters
modelstringRequiredgemini-3.1-flash-image is the stable model; the -preview alias is the same model at the same price.gemini-3.1-flash-image
Query parameters
fieldsstringOptionalGoogle'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
  • Path parameters
  • modelstringRequired

    gemini-3.1-flash-image is the stable model; the -preview alias is the same model at the same price.

    Example: gemini-3.1-flash-image

  • Query parameters
  • fieldsstringOptional

    Google's partial-response mask; the example drops the multi-megabyte thoughtSignature. Keep usageMetadata in any mask you send.

    Example: candidates(content(parts(text,inlineData)),finishReason),usageMetadata,modelVersion,responseId,promptFeedback

Code samples

Replace $TOOLSWITCH_KEY with the key you created in the console.

Preview
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"]}}'

This gateway API is in preview; its URL and authentication may change. The example parameters are sample data. Calls are billed at $0.165/success, including the service fee.