Google AI (Gemini API)图像生成AI 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.

价格
$0.165/success按供应商原价
成功率
99.2%近 30 天 · 1,058 次
延迟 p50
11 秒p95 23 秒
最后验证
2026年9月30日实测可用
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%2CpromptFeedback预览
  • 可用平台额度调用
  • 同步返回
  • 读取公开数据

参数

参数类型必填说明示例
路径参数
model字符串必填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
查询参数
fields字符串可选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
  • 路径参数
  • model字符串必填

    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

  • 查询参数
  • fields字符串可选

    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

代码示例

将 $TOOLSWITCH_KEY 替换为你在控制台创建的密钥。

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

网关接口为预览版,地址与鉴权方式可能调整。 示例参数仅为样例数据。 调用按 $0.165/success 计费,已含服务费。