GEMINI LABJP
NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20
Articles/Dev Tools
Dev Tools/2026-06-30Advanced

Building an AI-Powered Content Site with Gemini API and Astro

Combine Astro Server Endpoints and Content Collections with the Gemini API to add AI summaries, related-article recommendations, and auto-tagging.

gemini-api277astrocontent-sitessrai-content

Premium Article

"I'm running my blog on Astro, but every Gemini tutorial I find assumes Next.js with app/api." This is a question I've been hearing more and more lately. Astro leans toward static-first by design, so the standard Next.js patterns for AI features don't translate cleanly, and many developers get stuck.

I run a content site on Astro myself, and pairing it with the Gemini API has been a pleasant experience. You get to keep Astro's lightness and speed while adding AI summaries, related-article suggestions, and auto-tagging without much friction. This post walks through how I do it, with working code you can actually run.

Why Astro and Gemini API Pair Well

Astro is fundamentally a static site generator, but switching output to 'server' or 'hybrid' lets you opt individual pages into server execution. AI features that need per-request generation can use this targeted SSR — only the pages that need it pay the dynamic cost, and the rest of your site stays as fast as a pure static build.

What I particularly like is how Astro's Content Collections (src/content/) give you type-safe access to Markdown/MDX metadata. Pour Gemini-generated summaries and related tags into the schema, and your existing list and category pages just keep working.

For comparison, Next.js 15 App Router with Gemini API: The Complete Full-Stack covers a similar pattern in Next.js. Reading both side by side helps clarify the framework-specific tradeoffs.

Setup: Astro 5 in Hybrid Mode

Here's the minimal project setup, assuming Astro 5.

# Create a new project
npm create astro@latest my-ai-blog -- --template minimal --typescript strict
cd my-ai-blog
 
# Add the official Gemini SDK and Node adapter
npm install @google/genai
npx astro add node

Configure astro.config.mjs like this. Choosing output: 'hybrid' gives you static-by-default with opt-in SSR per page.

// astro.config.mjs
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
 
export default defineConfig({
  output: 'hybrid',         // Static by default, SSR where needed
  adapter: node({ mode: 'standalone' }),
  server: { port: 4321 },
});

Manage the API key via .env. Astro reads it through import.meta.env, but it's important to omit the PUBLIC_ prefix so it stays server-only.

# .env
GEMINI_API_KEY=YOUR_GEMINI_API_KEY

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A decision framework for choosing per-request SSR, prebuild static, or hybrid generation by cost and latency
Auto-tagging that closes the vocabulary with a responseSchema enum to stop spelling drift and duplicate tag pages
Incremental embeddings keyed on a body hash so CI build time stays flat as your article count grows
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-07-11
Never Generate the Same Narration Twice: Cache-Key Design and Invalidation for Gemini TTS Output
For apps that replay the same audio over and over—meditation, language learning, storytelling—caching the Gemini TTS output itself drives the variable cost to near zero. This is a working design: how to build a cache key that text alone can't cover, a two-tier server-plus-device cache, and an invalidation policy that survives model shutdowns like the August 17 image-model deprecation.
Dev Tools2026-06-28
Gemini API × PWA Complete Implementation Guide — Service Workers, Offline AI, and Web Push Notifications for App Store-Quality Web Apps
Build production-grade AI web apps by combining Gemini API with Progressive Web App techniques — Service Worker caching, IndexedDB for AI context persistence, offline fallbacks, and Web Push notifications — plus instrumentation to surface API cost from your cache hit rate.
Dev Tools2026-06-25
Gemini API × Android Jetpack Compose Complete Integration Guide — Production Design Patterns for Kotlin Native AI Apps
Build native Android AI apps with Kotlin and Jetpack Compose. Covers Google AI SDK, MVVM, multimodal chat UI, Room DB, WorkManager, and production security.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →