{
 "kind": "api",
 "slug": "google-gemini-image",
 "path": "apis/google-gemini-image/",
 "name": "Gemini API image generation (Nano Banana / Imagen)",
 "logo": "https://agentgid.com/media/avatars/googleapis.png",
 "maker": "Google",
 "density": "full",
 "crumbs": [
  [
   "APIs",
   "apis/"
  ],
  [
   "Image generation APIs",
   "apis/image-generation/"
  ]
 ],
 "lead": "Make and edit pictures.",
 "chips": [
  {
   "label": "Image generation APIs",
   "path": "apis/image-generation/"
  }
 ],
 "primary": {
  "label": "Copy prompt for your agent",
  "copy": "Add image generation to my app with Gemini Nano Banana (model gemini-nano-banana-2.1) through the google-genai package: call it from the server with GEMINI_API_KEY, save the returned image to storage, and never put the key in browser code."
 },
 "links": [
  {
   "label": "Website",
   "href": "https://ai.google.dev"
  },
  {
   "label": "Pricing",
   "href": "https://ai.google.dev/gemini-api/docs/pricing"
  },
  {
   "label": "GitHub",
   "href": "https://github.com/googleapis/js-genai"
  }
 ],
 "track": "Outages, price changes and new versions on your dashboard",
 "verdicts": [
  {
   "key": "price",
   "label": "Price",
   "value": "Paid",
   "status": "info",
   "sub": "from $0.0336 per 1K image",
   "quote": null,
   "note": "No free tier on the pricing page. As reported on the official pricing page, checked Nov 9, 2026.",
   "src": "https://ai.google.dev/gemini-api/docs/pricing"
  },
  {
   "key": "commercial",
   "label": "Commercial use",
   "value": "With conditions",
   "status": "cond",
   "sub": "Does not train on your data",
   "quote": "Google won't claim ownership over that content.",
   "note": "Business use by adults on the paid tier; you need rights to uploaded photos, images carry a SynthID watermark, and Google may make similar images for others.",
   "src": "https://aistudio.google.com/docs/terms"
  },
  {
   "key": "key",
   "label": "Key & sign-up",
   "value": "API key, server only",
   "status": "info",
   "sub": "Env var GEMINI_API_KEY",
   "quote": "Set the environment variable GEMINI_API_KEY or GOOGLE_API_KEY.",
   "note": "API key in the x-goog-api-key header (the official packages read it from the environment)",
   "src": "https://aistudio.google.com/docs/api-key"
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Community MCP server",
   "status": "cond",
   "sub": "SDK",
   "quote": "The public Gemini Docs MCP server (https://gemini-api-docs-mcp.dev) gives your agent live access to the entire documentation site.",
   "note": " Our agent check: 3 of 6 (Nov 13, 2026).",
   "src": "https://aistudio.google.com/docs/coding-agents"
  }
 ],
 "vfoot": "Checked against the maker's official pages, pricing on Nov 9, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Gemini API image generation (Nano Banana / Imagen) does",
   "parts": [
    {
     "t": "prose",
     "text": "Nano Banana is the name for Google's Gemini image models. Your app describes a picture in words, or sends a photo with a change to make, and gets back a finished image. It can mix several reference pictures, write readable text into the image, and make large images; every image carries an invisible Google watermark."
    },
    {
     "t": "list",
     "items": [
      "Gemini API image generation (Nano Banana / Imagen) is one of 13 APIs in the Image generation APIs category on AgentGid.",
      "It is not among the 3 that can be started for free.",
      "4 of them ship an official MCP server; Gemini API image generation (Nano Banana / Imagen) does not.",
      "Its official SDK is the 2nd most downloaded in the category (74.9M a week)."
     ],
     "muted": true
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Product photos for your shop",
       "text": "Make clean product shots for an online shop, an ad or a brand page from a short description.",
       "idea": false
      },
      {
       "title": "Edit a photo with words",
       "text": "Upload a photo and ask to remove an object, add something, change the style or adjust the colors.",
       "idea": false
      },
      {
       "title": "Logos, menus and infographics",
       "text": "Make images that contain readable words, such as a cafe menu, a simple logo idea or a diagram for a post.",
       "idea": false
      },
      {
       "title": "Backgrounds for websites and slides",
       "text": "Make a calm background picture with empty space where your page title or slide text will go, in a wide format.",
       "idea": false
      },
      {
       "title": "Comic panels and storyboards",
       "text": "Draw a short story in several panels with the same characters, for a comic, a lesson or a video plan.",
       "idea": false
      },
      {
       "title": "Cover images for blog posts",
       "text": "Make a matching cover picture for each new article from its title, in the same style every time.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Gemini API image generation (Nano Banana / Imagen) popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "70M",
       "l": "SDK downloads a week",
       "d": "+12.6% on the 4-week average",
       "up": true
      },
      {
       "n": "1,717",
       "l": "GitHub stars, googleapis/js-genai"
      }
     ]
    },
    {
     "t": "small",
     "text": "SDK downloads from npm and PyPI, weekly. Numbers as of Nov 17, 2026."
    }
   ]
  },
  {
   "id": "pricing",
   "nav": "Pricing and limits",
   "h2": "Pricing",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Free tier",
       "v": "None"
      },
      {
       "l": "Cheapest plan",
       "v": "No monthly plan"
      },
      {
       "l": "Usage price",
       "v": "Nano Banana 2.1: $0.0336 per 1K image, $0.0504 per 2K, $0.113 per 4K"
      },
      {
       "l": "Plans",
       "v": "Imagen 4 endpoints are deprecated and shut down on August 17, 2026; it no longer appears on the pricing page. Image output is $30 per 1M tokens (Batch $15). Free tier 'Not available' for image models. Gemini 3.1 Flash Image: $0.067 per 1K image."
      }
     ]
    },
    {
     "t": "h3",
     "text": "What one action costs"
    },
    {
     "t": "table",
     "head": [
      "Action",
      "Price"
     ],
     "num": true,
     "rows": [
      [
       "1 image at 1K, Nano Banana 2.1",
       "$0.0336"
      ],
      [
       "1 image at 2K, Nano Banana 2.1",
       "$0.0504"
      ],
      [
       "1 image at 4K, Nano Banana 2.1",
       "$0.113"
      ],
      [
       "1 image at 1K, Nano Banana 2.1 through the Batch API",
       "$0.0168"
      ],
      [
       "1 image at 1K, Nano Banana 2 (gemini-3.1-flash-image)",
       "$0.067"
      ],
      [
       "1 image at 1K or 2K, Nano Banana Pro",
       "$0.134"
      ]
     ]
    },
    {
     "t": "small",
     "text": "As reported on the official pricing page, checked Nov 9, 2026. Prices change: confirm before you buy.",
     "link": "ai.google.dev/gemini-api/docs/pricing",
     "href": "https://ai.google.dev/gemini-api/docs/pricing"
    }
   ]
  },
  {
   "id": "limits",
   "nav": null,
   "spy_as": "pricing",
   "h2": "Limits",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Paid tiers",
       "v": "Images per minute (IPM) limit for Nano Banana models, plus request limits; exact numbers are shown in Google AI Studio.",
       "src": "https://aistudio.google.com/docs/rate-limits"
      },
      {
       "l": "All tiers",
       "v": "Limits count per project, not per key; daily limits reset at midnight Pacific time.",
       "src": "https://aistudio.google.com/docs/rate-limits"
      },
      {
       "l": "Tier 1 (billing linked)",
       "v": "$10 of spend per rolling 10 minutes",
       "src": "https://aistudio.google.com/docs/rate-limits"
      }
     ]
    },
    {
     "t": "small",
     "text": "From the official docs.",
     "link": "aistudio.google.com/docs/rate-limits",
     "href": "https://aistudio.google.com/docs/rate-limits"
    }
   ]
  },
  {
   "id": "access",
   "nav": "Access and terms",
   "h2": "Key and access",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "How it signs in",
       "v": "API key in the x-goog-api-key header (the official packages read it from the environment)"
      },
      {
       "l": "Environment variable",
       "v": "GEMINI_API_KEY",
       "code": true
      },
      {
       "l": "Safe in browser code",
       "v": "No, keep it on your server",
       "status": "no"
      },
      {
       "l": "Card at sign-up",
       "v": "Yes"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Steps only a person can do"
    },
    {
     "t": "list",
     "items": [
      "Sign in to Google AI Studio and copy or create a Gemini API key. Put it in .env as GEMINI_API_KEY (kept out of git); the official packages read it automatically.",
      "Set up billing and prepay credits; image models are paid only. No code change; the same key starts working for image models."
     ]
    }
   ]
  },
  {
   "id": "terms",
   "nav": null,
   "spy_as": "access",
   "h2": "Commercial use and your data",
   "parts": [
    {
     "t": "prose",
     "text": "It is a paid Google service, meant for business use by adults. Google does not claim ownership of the images, but may make similar ones for others. You need the rights to any photo you upload, and every image carries a hidden watermark."
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In a paid app",
       "v": "With conditions",
       "status": "cond",
       "sub": "Business use by adults on the paid tier; you need rights to uploaded photos, images carry a SynthID watermark, and Google may make similar images for others.",
       "quote": "Google won't claim ownership over that content.",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "In monetized videos",
       "v": "With conditions",
       "status": "cond",
       "sub": "Allowed as your own generated content; do not make images that deceive, harass or harm, or that infringe others' rights.",
       "quote": "Don't generate content that infringe on others' rights, including videos or images that deceive, harass, or harm.",
       "src": "https://aistudio.google.com/docs/image-generation"
      },
      {
       "l": "To train your own AI",
       "v": "No",
       "status": "no",
       "sub": "You may not use the service to build models that compete with it.",
       "quote": "You may not use the Services to develop models that compete with the Services (e.g., Gemini API or Google AI Studio).",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "client-work",
       "v": "With conditions",
       "status": "cond",
       "sub": "Fine as business use when the client's photos you upload are cleared for this use.",
       "quote": "Make sure you have the necessary rights to any images you upload.",
       "src": "https://aistudio.google.com/docs/image-generation"
      },
      {
       "l": "Trains on what you send",
       "v": "“when you use Paid Services, Google does not use your prompts (including associated system instructions, cached content, and files such as images, videos, or documents) or responses to improve our products.”",
       "quote": null,
       "src": "https://aistudio.google.com/docs/zdr"
      },
      {
       "l": "Keeps your data",
       "v": "Paid requests are logged for a limited time only to detect misuse; Google Search grounding data is kept 30 days.",
       "quote": "For Paid Services, Google logs prompts and responses for a limited period of time, solely for detecting and preventing violations of the Prohibited Use Policy",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "Where data is stored",
       "v": "Data may be stored or cached in any country where Google has facilities.",
       "quote": "This data may be stored transiently or cached in any country in which Google or its agents maintain facilities.",
       "src": "https://aistudio.google.com/docs/terms"
      }
     ]
    }
   ]
  },
  {
   "id": "errors",
   "nav": null,
   "spy_as": "access",
   "h2": "Errors to handle",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "image_safety / image_prohibited_content",
       "v": "Safety rules or prohibited content guidelines blocked the image.",
       "sub": "Change the prompt or the input image and try again; do not retry unchanged."
      },
      {
       "l": "no_image",
       "v": "The model was unable to generate an image.",
       "sub": "Rephrase the prompt or ask explicitly for an image, then retry."
      },
      {
       "l": "402 payment_required",
       "v": "The prepaid credit balance is used up.",
       "sub": "Top up credits or turn on auto-reload; do not retry until credits are added."
      },
      {
       "l": "429 rate_limit_exceeded",
       "v": "Too many requests or images in a short time.",
       "sub": "Wait and retry with exponential backoff."
      }
     ]
    }
   ]
  },
  {
   "id": "agent",
   "nav": "For agents",
   "h2": "Use it from an agent",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Our agent check",
       "v": "3 of 6: llms.txt no, OpenAPI no, SDK yes, MCP no, status page yes, AI assistants allowed yes",
       "sub": "Checked Nov 13, 2026."
      },
      {
       "l": "MCP server",
       "v": "Gemini Docs MCP server (documentation search only; it does not make images)",
       "sub": "claude mcp add --transport http geminiDocs https://gemini-api-docs-mcp.dev"
      },
      {
       "l": "npm",
       "v": "npm install @google/genai",
       "code": true
      },
      {
       "l": "PyPI",
       "v": "pip install google-genai",
       "code": true
      }
     ]
    },
    {
     "t": "h3",
     "text": "Instructions in its docs to check first"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The docs say",
       "v": "“Building with an AI coding agent? Install the skill and then paste the prompt to get started with the Gemini API using Interactions:”",
       "sub": "Ask the person first. The suggested command is npx skills add google-gemini/gemini-skills (an unpinned package) and it changes the agent's setup."
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Gemini API image generation (Nano Banana / Imagen)",
       "me": true,
       "facts": [
        "from $0.0336 per 1K image",
        "No free tier"
       ]
      },
      {
       "name": "OpenAI Image API (GPT Image)",
       "why": "Pick OpenAI GPT Image when you already use OpenAI; our catalog lists it from $0.006 per image (list price on 2026-11-10).",
       "path": "apis/openai-gpt-image/",
       "facts": [
        "from $0.006",
        "No free tier"
       ]
      },
      {
       "name": "Recraft API",
       "why": "Pick Recraft when you need vector (SVG) images or want to turn pictures into vectors.",
       "path": "apis/recraft/",
       "facts": [
        "from $0.04 per raster image",
        "No free tier",
        "Official MCP"
       ]
      },
      {
       "name": "FLUX API",
       "why": "Pick the FLUX API when you want FLUX models; our catalog lists it from $0.014 per image (list price on 2026-11-10).",
       "path": "apis/bfl-flux/",
       "facts": [
        "from $0.03/image",
        "No free tier",
        "Official MCP"
       ]
      }
     ],
     "more": "All image generation apis APIs",
     "more_path": "apis/image-generation/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Add image generation to my app with Gemini Nano Banana (model gemini-nano-banana-2.1) through the google-genai package: call it from the server with GEMINI_API_KEY, save the returned image to storage, and never put the key in browser code."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Get a Gemini API key in Google AI Studio and set up billing; the image models have no free tier.",
       "code": "export GEMINI_API_KEY=\"YOUR_API_KEY\"",
       "src": "https://aistudio.google.com/docs/get-started"
      },
      {
       "text": "Install the official Google GenAI package.",
       "code": "pip install -U google-genai",
       "src": "https://aistudio.google.com/docs/get-started"
      },
      {
       "text": "Ask a Nano Banana model for an image and save the returned picture to a file.",
       "code": "from google import genai\nimport base64\nclient = genai.Client()\ninteraction = client.interactions.create(\n model=\"gemini-3.1-flash-image\",\n input=\"Generate an image of a futuristic city skyline at sunset\",\n)\nwith open(\"generated_image.png\", \"wb\") as f:\n f.write(base64.b64decode(interaction.output_image.data))",
       "src": "https://aistudio.google.com/docs/get-started"
      }
     ]
    },
    {
     "t": "h3",
     "text": "First request"
    },
    {
     "t": "tabs",
     "label": "First request",
     "items": [
      {
       "tab": "Request",
       "code": "curl -s -X POST \"https://generativelanguage.googleapis.com/v1beta/interactions\" \\\n -H \"x-goog-api-key: $GEMINI_API_KEY\" \\\n -H 'Content-Type: application/json' \\\n -H \"Api-Revision: 2026-05-20\" \\\n -d '{\n \"model\": \"gemini-3.1-flash-image\",\n \"input\": [\n {\"type\": \"text\", \"text\": \"Generate an image of a futuristic city skyline at sunset\"}\n ]\n }'",
       "intro": null
      },
      {
       "tab": "Response",
       "code": "{\n \"id\": \"v1_Chd...\",\n \"status\": \"completed\",\n \"steps\": [\n {\n \"type\": \"model_output\",\n \"content\": [\n {\n \"type\": \"image\",\n \"data\": \"BASE64_ENCODED_IMAGE\",\n \"mime_type\": \"image/png\"\n }\n ]\n }\n ],\n \"object\": \"interaction\",\n \"model\": \"gemini-3.1-flash-image\"\n}"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Calling an Imagen model such as imagen-4.0-generate.",
       "fix": "Use a Nano Banana model, for example gemini-nano-banana-2.1.",
       "why": "Imagen is shut down on the Gemini API."
      },
      {
       "dont": "Asking for a long headline and the image in one step and getting misspelled text.",
       "fix": "First generate the exact text, then ask for an image that uses that text.",
       "why": "The docs say this order works best."
      },
      {
       "dont": "Reading only output_image when the answer mixes text and several pictures, such as an illustrated story.",
       "fix": "Loop over interaction.steps and save every image block.",
       "why": "The convenience property returns only the last image."
      },
      {
       "dont": "Asking Nano Banana 2.1 for small 512px images to save money.",
       "fix": "Use gemini-3.1-flash-image for 512px, or 1K on Nano Banana 2.1.",
       "why": "The 0.5K size is not supported on Nano Banana 2.1."
      },
      {
       "dont": "Calling the image model from browser code with the key inside.",
       "fix": "Generate on your server and send the finished image (or its stored address) to the page.",
       "why": "Keys in web or mobile apps can be extracted and spent by anyone."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Is there a free tier for images?",
       "a": "No. The pricing page lists the image models as not available on the free tier, so you need billing set up.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/pricing",
        "quote": "Not available * $1.50 (text/image/video)"
       }
      },
      {
       "q": "Which model should I start with?",
       "a": "Google recommends Nano Banana 2.1 for new projects; Nano Banana Pro is the premium choice for complex layouts and text.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/image-generation",
        "quote": "Recommended for all new projects to use Nano Banana 2.1."
       }
      },
      {
       "q": "Are the images marked as AI-made?",
       "a": "Yes. Every generated image carries a SynthID watermark.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/image-generation",
        "quote": "All generated images include a SynthID watermark."
       }
      },
      {
       "q": "Can I choose the shape and size of the image?",
       "a": "Yes, with aspect_ratio and image_size; by default the output matches your input image or is square.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/image-generation",
        "quote": "By default, the model matches the output image size to that of your input image, or otherwise generates 1:1 squares."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Maker",
   "Google"
  ],
  [
   "Category",
   "Image generation APIs"
  ],
  [
   "Price",
   "from $0.0336 per 1K image"
  ],
  [
   "Official SDK",
   "npm @google/genai, PyPI google-genai"
  ],
  [
   "Latest SDK",
   "3.0.0 on npm"
  ],
  [
   "Agent check",
   "3 of 6"
  ],
  [
   "Pricing checked",
   "Nov 9, 2026"
  ]
 ],
 "good": [
  "There is no free tier for the image models; every image is paid.",
  "Older Imagen models are shut down; use the Nano Banana models instead.",
  "The model may not make the exact number of pictures you ask for."
 ],
 "checked_line": "Read by AgentGid from 14 official pages, card checked Nov 10, 2026; usage numbers update daily."
}