<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq" -->

---
title: Get Started with Firebase AI Logic + Flutter: Build A...
description: Firebase AI Logic (formerly Vertex AI in Firebase) provides Flutter apps with direct access to Google's Gemini models. A step-by-step walkthrough shows how to...
canonical: https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Get Started with Firebase AI Logic + Flutter: Build A Simple Caption Generator | daily.dev
og:description: Firebase AI Logic (formerly Vertex AI in Firebase) provides Flutter apps with direct access to Google's Gemini models. A step-by-step walkthrough shows how to...
og:url: https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq
og:image: https://api.daily.dev/og/posts/QBIallgsQ.png
og:image:alt: Get Started with Firebase AI Logic + Flutter: Build A Simple Caption Generator
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started with Firebase AI Logic + Flutter: Build A Simple Caption Generator

**[Samuel Adekunle](https://daily.dev/sources/on_leuwcq)** · [@techwithsam](https://daily.dev/techwithsam) · 3 min read · 5 upvotes · 0 comments

## Summary

Firebase AI Logic (formerly Vertex AI in Firebase) provides Flutter apps with direct access to Google's Gemini models. A step-by-step walkthrough shows how to set up the firebase_ai package, initialize Firebase in a Flutter project, and build a simple caption generator using the Gemini 3.1 Flash Lite model. The guide also covers production best practices including App Check, Firebase Auth, Remote Config for prompts, Firestore caching, and when to offload complex workflows to Genkit on the backend.

## Content

This will be a continuation from the last article on Genkit Dart for Flutter Developers; you can check it out [here](https://dly.to/8zqiFOQFJMH).

## WHAT IS FIREBASE AI LOGIC?

Firebase AI Logic (previously known as Vertex AI in Firebase) is Google’s official way to give your Flutter (iOS, Android, and web) apps direct, secure access to the latest Gemini models.

Today, we will build a simple app with Firebase AI Logic. We will learn how to use Firebase AI Logic with Gemini models in real Flutter apps.

Watch full tutorial on YouTube: [https://youtu.be/beA-xr_TcLQ](https://youtu.be/beA-xr_TcLQ)

To get started, create a new [Firebase project](https://console.firebase.google.com/) or use an existing one. Once you have your Firebase project set up, you also need to connect it to your Flutter project. Under project categories on Firebase → AI services → AI Logic → Get started (Gemini Developer API — Vertex AI Gemini API), we’ll continue with the Gemini Developer API

![Firebase screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iauvxigbjxdb21jbzkmo.png)

That’s all for the setup.

## QUICK SETUP IN FLUTTER

```
flutter pub add firebase_ai
```

You must added `firebase_core` package

In `main.dart`

```
void main() async {
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  runApp(const MyApp());
}
```

Then we can create a new file `caption_generator.dart`

```
void _generateCaption() async {
    if (_captionController.text.isEmpty) {
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(
          content: Text('Please enter a description to generate a caption.'),
        ),
      );
      return;
    }
    try {
      setState(() => _isGenerating = true);

      final model = FirebaseAI.googleAI().generativeModel(
        model: 'gemini-3.1-flash-lite-preview',
        generationConfig: GenerationConfig(
          maxOutputTokens: 50,
          temperature: 0.7,
        ),
        systemInstruction: Content.system(
          'You generate concise captions that are catchy and engaging, suitable for social media posts or advertisements.'
          'Do not use markdown, bullet points, headings, code blocks, or JSON.',
        ),
      );

      final response = await model.generateContent([
        Content.text(_captionController.text),
      ]);

      setState(() => _generatedCaption = response.text!);
    } catch (e) {
      print('Error generating caption: $e');
      ScaffoldMessenger.of(
        context,
      ).showSnackBar(SnackBar(content: Text('Error generating caption: $e')));
    } finally {
      setState(() => _isGenerating = false);
    }
  }
```

Full Source Code: [https://github.com/techwithsam/ai_content_generator](https://github.com/techwithsam/ai_content_generator)

## BEST PRACTICES FOR PRODUCTION

- Always use App Check + Firebase Auth — never trust the client blindly
- Start with Flash models for speed and cost, upgrade to Pro only when you need heavy reasoning
- Keep prompts in Remote Config so you can iterate without redeploying the app
- Cache frequent responses in Firestore to save cost and latency

Monitor usage in Firebase console — set budgets early

- For complex multi-step workflows or heavy tool use, consider moving logic to Genkit on the backend instead of doing everything client-side

There you have it — Firebase AI Logic lets Flutter developers finally build real full-stack AI apps without leaving the Dart ecosystem.

If this article helped you even a little, smash that clap button and subscribe so you don’t miss the next deep-dive.

Lastly, if you’re serious about mastering AI tools like this, join my free Flutter + AI newsletter. Every week, I share the exact prompts, workflows, and early access to new agent skills that I test before they hit YouTube. Completely free, no spam. [https://techwithsam.dev/newsletter](https://techwithsam.dev/newsletter) — I’d love to see you there!

Thanks for reading, Flutter fam.

See you in the next one — peace! ✌️

Samuel Adekunle Tech With Sam [YouTube.](https://youtube.com/@techwithsam)

## Similar posts on daily.dev

- [How to Build Production-Ready AI Features with Flutter \[Full Handbook for Devs\]](https://daily.dev/posts/how-to-build-production-ready-ai-features-with-flutter-full-handbook-for-devs--dvqqtnhpi) · freeCodeCamp · 3 upvotes · 0 comments
- [Build smarter apps with Gemini 3 Flash](https://daily.dev/posts/build-smarter-apps-with-gemini-3-flash-rgootmsr4) · Android Developers Blog · 76 upvotes · 2 comments
- [Serverless AI for Android with Firebase AI Logic](https://daily.dev/posts/serverless-ai-for-android-with-firebase-ai-logic-33d7pefc4) · ProAndroidDev · 0 upvotes · 0 comments
- [5 ways to use Gemini text-to-speech \(TTS\) in your apps with Firebase AI Logic](https://daily.dev/posts/5-ways-to-use-gemini-text-to-speech-tts-in-your-apps-with-firebase-ai-logic-zem9xw3nl) · Firebase · 1 upvotes · 1 comments

---

Tags: [#genai](https://daily.dev/tags/genai), [#flutter](https://daily.dev/tags/flutter), [#firebase](https://daily.dev/tags/firebase), [#dart](https://daily.dev/tags/dart), [#google-gemini](https://daily.dev/tags/google-gemini)

[View this post on daily.dev](https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq","headline":"Get Started with Firebase AI Logic + Flutter: Build A Simple Caption Generator","text":"Firebase AI Logic (formerly Vertex AI in Firebase) provides Flutter apps with direct access to Google's Gemini models. A step-by-step walkthrough shows how to set up the firebase_ai package, initialize Firebase in a Flutter project, and build a simple caption generator using the Gemini 3.1 Flash Lite model. The guide also covers production best practices including App Check, Firebase Auth, Remote Config for prompts, Firestore caching, and when to offload complex workflows to Genkit on the backend.","url":"https://daily.dev/posts/get-started-with-firebase-ai-logic-flutter-build-a-simple-caption-generator-qbiallgsq","datePublished":"2026-04-15T10:30:02.739Z","dateModified":"2026-04-15T10:36:12.801Z","author":{"@type":"Person","name":"Samuel Adekunle","url":"https://daily.dev/techwithsam","image":"https://avatars2.githubusercontent.com/u/42917957?v=4","description":"Building myvista.app | Software Engineer | Building Scalable Solution | Tech Educator & Speaker","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":740}},"image":"https://media.daily.dev/image/upload/s--ODldThj3--/f_auto/v1776249004/posts/QBIallgsQ?_a=BAMAMiWQ0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/on_leuwcq","name":"Samuel Adekunle"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Samuel Adekunle","item":"https://daily.dev/sources/on_leuwcq"},{"@type":"ListItem","position":3,"name":"Get Started with Firebase AI Logic + Flutter: Build A Simple Caption Generator"}]}
```

