Skip to main content
skill CX Codex

firebase-ai — Claude Code skill: what it does, how to install

This skill gives the agent working patterns for wiring up Firebase AI Logic in a Flutter app and writing Gemini text and chat calls.

MIT ★ 674 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules
Open on GitHub

What firebase-ai does

The skill covers the core firebase_ai setup in Flutter: calling Firebase.initializeApp, creating a model with FirebaseAI.googleAI().generativeModel, running single-turn generation, keeping a multi-turn conversation through model.startChat(), and streaming output via generateContentStream so the UI updates as text arrives. It also shows how to send a combined text-and-image prompt using Content.multi and InlineDataPart.

A separate section walks through catching FirebaseAIException, detecting quota errors, and applying exponential backoff, plus configuring safetySettings with HarmCategory values and turning on App Check to guard the AI endpoints. Windows isn't supported at all, and macOS and other Apple platforms are marked beta.

The agent uses these patterns when touching Dart code, but the project still needs Firebase AI Logic enabled in the Firebase console before any of this runs.

What it helps with

  • wire up firebase_ai in a Flutter project
  • generate a text response with Gemini
  • build a multi-turn chat that keeps conversation history
  • stream a Gemini response into the UI as it's generated
  • send a Gemini prompt that mixes text and an image

Example prompts for the agent

  • Set up firebase_ai in this project and initialize a Gemini model
  • Stream the Gemini response into the UI as chunks arrive
  • Add quota error handling around the generateContent call

How to install firebase-ai

1Plugin marketplace

/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules

This installs the whole flutter-ai-skills plugin with all its skills

2Skills CLI (Vercel)

npx skills add evanca/flutter-ai-rules --skill firebase-ai -a claude-code

3Manually: put the files in place

~/.claude/skills/firebase-ai/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/firebase-ai/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about firebase-ai

How do I install firebase-ai in Claude Code?

Run /plugin marketplace add evanca/flutter-ai-rules, then /plugin install flutter-ai-skills@flutter-ai-rules.

What does the firebase-ai skill do?

It gives the agent correct code patterns for Firebase AI Logic in Flutter: setup, Gemini text and chat generation, streaming output, multimodal prompts, and error handling.

Which platforms does Firebase AI Logic support?

iOS, Android and Web are fully supported, macOS and other Apple platforms are in beta, and Windows isn't supported.

Source text

SKILL.md · MIT
---
name: firebase-ai
description: "Use when setting up firebase_ai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors."
license: MIT
---

# Firebase AI Skill

This skill defines how to correctly use Firebase AI Logic in Flutter applications.

## When to Use

Use this skill when:

* Setting up and configuring Firebase AI in a Flutter project.
* Generating text content or chat responses with Gemini models.
* Implementing streaming AI responses for real-time UI updates.
* Sending multimodal prompts (text + images) to Gemini.
* Handling errors, offline scenarios, and rate limits for AI operations.
* Applying security and privacy considerations for AI features.

---

## 1. Setup and Configuration

```
flutter pub add firebase_ai
```

```dart
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

// Initialize FirebaseApp
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

// Initialize the Gemini Developer API backend service
final model =
    FirebaseAI.googleAI().generativeModel(model: 'gemini-2.5-flash');
```

- Ensure the Firebase project is configured for AI services via the Firebase AI Logic page in the Firebase Console.
- Initialize Firebase before using any Firebase AI features.
- Use `FirebaseAI.googleAI()` for the **Gemini Developer API** backend (recommended starting point).
- Implement **App Check** to prevent abuse of Firebase AI endpoints.

**Platform support:**

| Platform | Support |
|---|---|
| iOS | Full |
| Android | Full |
| Web | Full |
| macOS / other Apple | Beta |
| Windows | Not supported |

---

## 2. Generating Content

### Single-turn text generation

```dart
final response = await model.generateContent([
  Content.text('Summarize the benefits of Flutter for mobile development'),
]);
final text = response.text; // The generated summary string
```

### Multi-turn chat

```dart
final chat = model.startChat();
final response = await chat.sendMessage(
  Content.text('What is the difference between StatelessWidget and StatefulWidget?'),
);
print(response.text);

// Follow-up in the same conversation
final followUp = await chat.sendMessage(
  Content.text('When should I use StatefulWidget?'),
);
print(followUp.text);
```

### Streaming responses

Use streaming to display partial results as they arrive:

```dart
final stream = model.generateContentStream([
  Content.text('Write a step-by-step guide to implementing dark mode in Flutter'),
]);

await for (final chunk in stream) {
  // Append chunk.text to the UI progressively
  setState(() => _output += chunk.text ?? '');
}
```

### Multimodal prompts (text + image)

```dart
final imageBytes = await File('photo.jpg').readAsBytes();
final response = await model.generateContent([
  Content.multi([
    TextPart('Describe what you see in this image'),
    InlineDataPart('image/jpeg', imageBytes),
  ]),
]);
```

---

## 3. Error Handling

Wrap AI calls in structured error handling:

```dart
try {
  final response = await model.generateContent([Content.text(prompt)]);
  return response.text;
} on FirebaseAIException catch (e) {
  if (e.message?.contains('quota') ?? false) {
    // Handle rate limiting — show retry message or queue the request
    return 'Service is busy. Please try again shortly.';
  }
  return 'AI service error: ${e.message}';
} catch (e) {
  return 'Unexpected error: $e';
}
```

- Provide meaningful error messages to users when AI operations fail.
- Handle **offline scenarios** with appropriate fallback behavior (e.g., cached responses).
- Implement **exponential backoff** for rate-limited or transient errors.

---

## 4. Security and Privacy

- Follow Firebase Security Rules best practices when using AI services alongside other Firebase products.
- Ensure proper **authentication and authorization** for AI feature access.
- Sanitize user input before sending it to the model to prevent prompt injection.
- Be mindful of **data privacy requirements** when processing user content with AI services.
- Implement appropriate **content filtering and moderation** using safety settings:

```dart
final model = FirebaseAI.googleAI().generativeModel(
  model: 'gemini-2.5-flash',
  safetySettings: [
    SafetySetting(HarmCategory.harassment, HarmBlockThreshold.medium),
    SafetySetting(HarmCategory.dangerousContent, HarmBlockThreshold.high),
  ],
);
```

---

## References

- [Firebase AI Logic Flutter documentation](https://firebase.google.com/docs/ai-logic/get-started?platform=flutter)

© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules

Similar skills

All skills for Mobile →

From the same set39

The whole set →
firebase-data-connect Get guidance for Firebase Data Connect in Flutter, from GraphQL operations and typed SDK generation to access rules and offline handling. CX Codex +1 ★ 674repo stars firebase-remote-config A Flutter skill that keeps the agent on track with Firebase Remote Config: feature flags, in-app defaults, A/B tests and live config updates. CX Codex +1 ★ 674repo stars firebase-cloud-functions Guides your coding agent on calling Firebase Cloud Functions in Flutter with error handling, region configs, and local emulator support. CX Codex +1 ★ 674repo stars testing The testing skill guides Flutter and Dart test writing and review, helps investigate flaky tests, and clarifies when to use unit or widget tests. CX Codex +1 ★ 674repo stars flutterfire-configure Guides Firebase integration in Flutter apps, runs flutterfire configure, and structures multi-flavor project environments. CX Codex +1 ★ 674repo stars flutter-use-column-row-first The flutter-use-column-row-first skill guides Flutter screen layouts with Row, Column, and flexible space. Use it when building a screen that must adapt to different constraints. CX Codex +1 ★ 674repo stars firebase-crashlytics Skill teaches the agent to set up Firebase Crashlytics in Flutter projects: catch fatal and non-fatal errors, log async exceptions, add custom keys, and upload obfuscated build symbols. CX Codex +1 ★ 674repo stars firebase-in-app-messaging Guides Firebase In-App Messaging setup in Flutter: trigger and suppress popups during sensitive flows, configure GDPR opt-in collection, and run tests via test device IDs. CX Codex +1 ★ 674repo stars

Project sponsors

Companies that keep this analytics open