Ship a 'Nano Banana' Image Generator in 3 Minutes (No AWS S3 Required)

Published: (December 13, 2025 at 01:57 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

Cover image for Ship a "Nano Banana" Image Generator in 3 Minutes (No AWS S3 Required)

Everyone is talking about Gemini 2.0 Flash (affectionately known as the “Nano Banana” model). It’s fast, it’s multimodal, and it’s finally giving developers a run for their money against other image‑generation models.

If you’re building an AI agent, a Discord bot, or a simple web app, you’ll quickly hit a common wall: Storage.
The Gemini API returns the image as raw bytes, which you can’t drop directly into a Slack channel or an <img> tag—you need a URL.

Usually this means setting up an AWS S3 bucket, configuring IAM roles, fighting CORS, and writing boilerplate. Today we’ll skip all of that and use Lab Nocturne Images, a zero‑config image API, to build a text‑to‑image generator that returns a shareable link in less than 50 lines of Python.

The Stack

  • Engine: Google Gemini 2.0 Flash
  • Storage: Lab Nocturne Images
  • Language: Python

Step 1: Get your Storage Key (1 second)

Lab Nocturne provides a “curl‑to‑start” feature. Run the following command in your terminal:

curl https://images.labnocturne.com/key

You’ll receive a JSON response containing your API key. Copy it—this is your storage key.

Step 2: The Python Script

Install the required packages:

pip install google-generativeai requests
import os
import requests
import google.generativeai as genai
import io

# CONFIGURATION
GOOGLE_API_KEY = "YOUR_GEMINI_API_KEY"
LAB_NOCTURNE_KEY = "YOUR_LN_TEST_KEY_FROM_STEP_1"

# Setup Gemini
genai.configure(api_key=GOOGLE_API_KEY)
model = genai.GenerativeModel('gemini-2.0-flash-exp')

def host_image(image_bytes):
    """
    Uploads raw bytes to Lab Nocturne and returns a public URL.
    No AWS config, no buckets, just a POST request.
    """
    url = "https://images.labnocturne.com/upload"
    headers = {"Authorization": f"Bearer {LAB_NOCTURNE_KEY}"}
    files = {'file': ('generated.jpg', image_bytes, 'image/jpeg')}

    response = requests.post(url, headers=headers, files=files)

    if response.status_code == 200:
        return response.json()['url']
    else:
        raise Exception(f"Upload failed: {response.text}")

def generate_and_share(prompt):
    print(f"🎨 Generating: '{prompt}'...")

    # Generate the image
    response = model.generate_content(prompt)

    # Gemini returns parts; we want the image blob
    if response.parts:
        img_part = response.parts[0]
        img_bytes = io.BytesIO(img_part.inline_data.data)

        print("☁️  Uploading to CDN...")
        public_url = host_image(img_bytes)

        return public_url
    else:
        return "Failed to generate image."

# --- RUN IT ---
if __name__ == "__main__":
    prompt = "A cyberpunk banana wearing sunglasses, 3d render, 4k"
    link = generate_and_share(prompt)

    print("-" * 30)
    print(f"🚀 Image Live at: {link}")
    print("-" * 30)

Why this matters for AI Agents

Autonomous agents (e.g., built with LangChain, CrewAI, or AutoGen) need “tools.” Granting them S3 access is risky and complex, whereas a Lab Nocturne key is safe and trivial. Drop the host_image function into any LLM tool definition, and your text‑based bot can create persistent visual artifacts instantly.

The Limits

  • The key generated in Step 1 is a Test Key.
  • Images persist for 7 days (ideal for testing/prototyping).
  • 100 MB size limit per upload.

For production use, obtain a permanent key, but for hackathons, side projects, and “Nano Banana” experiments, this is the fastest path from PromptURL.

Happy Shipping! 🚢

Back to Blog

Related posts

Read more »

GPT Image 1.5

https://platform.openai.com/docs/models/gpt-image-1.5 Comments URL: https://news.ycombinator.com/item?id=46291941 Points: 41 Comments: 20...