Google’s Gemini Nano Banana 2.1 now available in AI Gateway

October 6, 2026

Google’s Gemini Nano Banana 2.1 is now available through Netlify AI Gateway. You can call this image generation model from Netlify Functions without configuring API keys; AI Gateway provides the connection to Google for you.

Use the Google Gen AI SDK with the model ID gemini-nano-banana-2.1. Here’s an example that generates an image from a prompt and returns it directly from a Function:

import { GoogleGenAI } from '@google/genai';
// Netlify Function: Generate an image with Gemini Nano Banana 2.1 and return it directly.
// Usage (GET): /.netlify/functions/nano-banana-2-1?prompt=Your+prompt+here
// Returns: binary image (PNG/JPEG/etc) with proper content-type. If no image, JSON error.
export default async (request: Request) => {
const url = new URL(request.url);
const prompt = url.searchParams.get('prompt') || 'two happy bananas holding flashlights';
const ai = new GoogleGenAI({});
try {
const response = await ai.models.generateContent({
model: 'gemini-nano-banana-2.1',
contents: prompt,
config: {
imageConfig: {
aspectRatio: '16:9',
imageSize: '1K'
}
}
});
let imagePart = null;
for (const part of response.candidates[0].content.parts) {
if (part.inlineData) {
imagePart = part.inlineData;
break;
}
}
const bytes = Buffer.from(imagePart.data, 'base64');
const mimeType = imagePart.mimeType || 'image/png';
return new Response(bytes, {
status: 200,
headers: {
'Content-Type': mimeType,
'Cache-Control': 'no-store'
}
});
} catch (err) {
return new Response(JSON.stringify({ error: String(err), prompt }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
};

Gemini Nano Banana 2.1 is also available across Scheduled Functions, Background Functions, and Edge Functions. You get automatic access to Netlify’s caching, rate limiting, and authentication infrastructure.

Learn more in the AI Gateway documentation.