Angaben zum Datum
Datum aus der Quelle.
Erstmals gesehen am .
Google Gemini Nano Banana 2.1 jetzt im Netlify AI Gateway
Google Gemini Nano Banana 2.1 steht jetzt über Netlify AI Gateway zur Bildgenerierung in Netlify Functions bereit, ohne dass API-Keys konfiguriert werden müssen (Model-ID gemini-nano-banana-2.1).
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: Stri…