# Firebase AI

Use when setting up firebase_ai, generating text/chat with Gemini, streaming AI output...

- Repository: https://github.com/evanca/flutter-ai-rules (668 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add evanca/flutter-ai-rules --skill firebase-ai -g -a claude-code -y`
Codex: `npx skills add evanca/flutter-ai-rules --skill firebase-ai -g -a codex -y`
Cursor: `npx skills add evanca/flutter-ai-rules --skill firebase-ai -g -a cursor -y`
Gemini CLI: `npx skills add evanca/flutter-ai-rules --skill firebase-ai -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add evanca/flutter-ai-rules`

## Description

Use when setting up firebase_ai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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);

The rest: https://github.com/evanca/flutter-ai-rules/blob/HEAD/skills/firebase-ai/SKILL.md
