A New Collection of Thoughtful Learning Apps — Now Available on iOS & Android

Image
I’m excited to share a set of mobile apps I’ve recently completed and published on both the Google Play Store and the Apple App Store. These apps are designed with a simple goal in mind: to make meaningful, structured content more accessible, whether you’re studying theology or improving your English vocabulary. 📱 Now Available on Both Platforms All apps are live and available for download: Google Play Developer Page: https://play.google.com/store/apps/dev?id=5835943159853189043 Apple App Store Developer Page: https://apps.apple.com/ca/developer/q-z-l-corp/id1888794100 📖 Theology & Confession Study Apps For those interested in Reformed theology and classical Christian teachings, I’ve developed a series of apps that present foundational texts in a clean, focused reading format: The Belgic Confession Canons of Dort Heidelberg Catechism Westminster Shorter Catechism Each app is designed to provide a distraction-free experience, making it easier to read, reflect, and revisit these im...

Building the qz-l AI Chat Assistant Using Google Gemini 2.5 Flash Lite + Next.js

 

Building the qz-l AI Chat Assistant Using Google Gemini 2.5 Flash Lite + Next.js

Learn how qz-l.com's new AI chat assistant works using Gemini 2.5 Flash Lite, Next.js API routes, and function calling --- all free on the Google AI tier.

November 20, 2025By qz-l team

🤖 Building the qz-l AI Chat Assistant Using Google Gemini 2.5 Flash Lite + Next.js

I recently added a new feature to qz-l.com: an AI-powered chat assistant that can shorten URLs, show analytics, search blog posts, and help users navigate the service --- all through natural language.

This post explains how the assistant works under the hood using the modern @google/genai SDK and the free-tier model gemini-2.5-flash-lite, which runs entirely at zero cost within Google's usage limits.

🚀 Why Build an AI Assistant?

qz-l's mission is simple: privacy-first URL shortening with analytics.

But users often ask:

  • "How do I create a short link?"
  • "Where's the dashboard?"
  • "Can I delete a URL?"
  • "What does this blog post say?"

Instead of building a whole help UI, I added a chat interface that can perform real actions using function calling.

🧠 Model Choice: gemini-2.5-flash-lite (Free)

The assistant uses:

  • SDK: @google/genai
  • Model: gemini-2.5-flash-lite
  • Platform: Google AI Studio (free tier)

Why this model?

  • ✓ Completely free within quota
  • ✓ Very fast and low latency
  • ✓ Full function calling support
  • ✓ Perfect for automation + chat
  • ✓ Stable enough for production workloads

Inspired by this resource list: https://github.com/cheahjs/free-llm-api-resources

🏗️ System Architecture

The assistant lives inside a Next.js App Router API route:

/api/chat

High-level flow:

User Message
    ↓
Next.js API (/api/chat)
    ↓
Gemini LLM (with system prompt + tools)
    ↓
If function call → server executes logic
    ↓
LLM formats final Markdown response
    ↓
Chat UI displays answer (links, QR codes, etc.)

⚙️ Using @google/genai

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey });
const result = await ai.models.generateContent({
  model: "gemini-2.5-flash-lite",
  contents,
  config: {
    temperature: 0.7,
    maxOutputTokens: 1024,
    systemInstruction: {
      role: "system",
      parts: [{ text: SYSTEM_PROMPT }],
    },
    tools: [
      {
        functionDeclarations: [
          shortenUrlDeclaration,
          getUrlAnalyticsDeclaration,
          listRecentUrlsDeclaration,
          deleteUrlDeclaration,
          searchBlogPostsDeclaration,
        ],
      },
    ],
  },
});

🧩 Function Calling

const shortenUrlDeclaration = {
  name: "shortenUrl",
  description: "Generate a shortened URL",
  parameters: {
    type: "object",
    properties: {
      longUrl: { type: "string" },
    },
    required: ["longUrl"],
  },
};

Example function call return:

{
  "functionCall": {
    "name": "shortenUrl",
    "args": { "longUrl": "https://google.com" }
  }
}

🧵 The Function-Call Loop

  1. Ask Gemini for the next message
  2. Detect if it requested a function
  3. Execute the function on the server
  4. Append the result
  5. Call Gemini again for the final answer

🎯 Why This Approach Works

  • ✓ Zero cost (Gemini free tier)
  • ✓ Fast responses
  • ✓ Deterministic output
  • ✓ Secure
  • ✓ Extendable

📈 Current Capabilities

  • Shorten URLs
  • Generate QR codes
  • Fetch analytics
  • Delete links
  • Show recent URLs
  • Search blog posts
  • Explain features

🔮 Coming Enhancements

  • Auth-protected actions
  • Rate limiting
  • Streaming responses
  • Better UI

🎉 Final Thoughts

You don't need expensive models to build production AI features --- just solid architecture and a good system prompt.

❤️ Support This Blog


If this post helped you, you can support my writing with a small donation. Thank you for reading.


Comments

Popular Posts

Fix “A problem occurred starting process 'command node'” in Android Studio for React Native

Fix up watchman issue with Ghost

Using Mutual TLS (mTLS) in Next.js (Server-Side Only)