Generated banner for Firebase AI Logic Basics
Generated logo for Firebase AI Logic Basics

Firebase AI Logic Basics

Firebase (Google)OfficialCreated by Google LLCDistributed by Firebase (Google)

  • Skill
  • Tool integration
  • Software development
  • Apache-2.0
  • Low risk

From the author

Integrates Firebase AI Logic (formerly Vertex AI for Firebase) into mobile and web apps (Android, iOS, Web, and Flutter) to call Gemini models from client code. Use when provisioning or initializing Firebase AI Logic, or adding Gemini features to an app: text generation, multimodal input, chat, streaming, structured output, hybrid on-device inference, App Check protection, or switching models with Remote Config.
— the description by Google LLC

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Firebase AI Logic (formerly Vertex AI for Firebase) enables developers to incorporate generative AI features directly into client-side applications. By using the Firebase SDKs for Android, iOS, Web, and Flutter, developers can call Gemini models without managing a dedicated backend. The service supports text generation, multimodal inputs, chat sessions, streaming, and structured JSON outputs, while providing security through Firebase App Check and configuration management via Remote Config.

What it does

  • Provisions the Firebase AI Logic service via the Firebase CLI.
  • Integrates Gemini models into mobile and web client code.
  • Supports multimodal inputs including images, audio, video, and PDFs.
  • Enables multi-turn chat sessions and streaming responses.
  • Provides client-side Text-to-Speech generation using dedicated models.
  • Enforces security and quota protection using Firebase App Check.

When to use it

  • When adding generative AI features to a mobile or web application.
  • When you need to call Gemini models directly from client-side code.
  • When you require a managed service for AI features without building a custom backend.
  • When implementing features like image analysis, chat, or speech synthesis in an app.
  • When you need to secure AI model access using Firebase App Check.

Advantages

  • Eliminates the need for a dedicated AI backend.
  • Supports multiple platforms including Android, iOS, Web, and Flutter.
  • Provides built-in security and quota management via App Check.
  • Allows dynamic model updates using Firebase Remote Config.
  • Supports hybrid on-device inference for improved performance.

Usage examples

“How do I provision Firebase AI Logic for my project?”
The agent provides the command 'npx -y firebase-tools@latest init ailogic' to enable the service in the Firebase project.
“Show me how to initialize the Gemini model in a Flutter app.”
The agent provides the code to import 'firebase_ai', initialize the service, and call 'googleAI.generativeModel' with the latest supported model.
“How can I secure my AI calls in my iOS app?”
The agent explains the necessity of setting up Firebase App Check and provides the Swift code to initialize the AI service with 'useLimitedUseAppCheckTokens: true'.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/firebase/firebase-ai-logic-basics/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip firebase-ai-logic-basics.zip -d .agents/skills

Documentation by Google LLC

Firebase AI Logic Basics

Overview

Firebase AI Logic is a product of Firebase that allows developers to add gen AI to their mobile and web apps using client-side SDKs. The app can directly call Gemini models via Firebase AI Logic without the developer needing to manage a dedicated backend. Firebase AI Logic was previously known as "Vertex AI for Firebase".

It supports the two Gemini API providers:

  • Gemini Developer API: It has a free tier ideal for prototyping, and pay-as-you-go for production

  • Agent Platform Gemini API (formerly branded Vertex AI): Ideal for scale with enterprise-grade production readiness, requires Blaze pricing plan

Use the Gemini Developer API as a default, and only Agent Platform Gemini API (formerly branded Vertex AI) if the application requires it.


Setup & initialization

Prerequisites
  • Identify the platform the user is interested in building on prior to starting: Android, iOS, Web, or Flutter.

  • If their platform is unsupported, Direct the user to Firebase Docs to learn how to set up AI Logic for their application (share this link with the user https://firebase.google.com/docs/ai-logic/get-started)

  • The Firebase CLI commands below run through npx on every platform, so they need Node.js 20+ and npm. Use the firebase-basics skill to check for them and to log in to the Firebase CLI. If Node.js is missing or older than version 20, ask the user to install it as that skill describes. Don't install system packages yourself, for example with sudo apt-get, because that changes the user's machine without their consent.

1. Provision Firebase AI Logic (ALL platforms)

Use the Firebase CLI to provision Firebase AI Logic for the Firebase Project:

  1. Make sure that you're in a firebase directory (with a firebase.json).

  2. Verify that you're running Firebase CLI commands against the intended Firebase Project. When you run this command, the active project is marked with "current":

    npx -y firebase-tools@latest projects:list
  3. Make sure there's at least one Firebase App for the target platform registered with the current Firebase Project:

    npx -y firebase-tools@latest apps:list
  4. Provision Firebase AI Logic for the Firebase Project:

    npx -y firebase-tools@latest init ailogic

    This command will enable the Gemini Developer API in the Firebase project.

[!WARNING] CRITICAL: Provisioning Firebase AI Logic is Required For all platforms (Android, iOS, Web, or Flutter), even if the app already uses Firebase, you MUST run npx -y firebase-tools@latest init ailogic to provision the service. The configuration files of GoogleService-Info.plist, google-services.json, and firebase_options.dart ONLY handle client configuration and do NOT enable the Firebase AI Logic service, leading to PERMISSION_DENIED errors.

If you can't run init ailogic yourself (for example because Node.js is missing or the Firebase CLI isn't logged in) do NOT skip it. The app's requests to Gemini models will fail until the Firebase AI Logic service is provisioned. Tell the user to run this command in their project directory, and include it in your final summary:

npx -y firebase-tools@latest init ailogic
2. Add the SDK and initialize the service in the app

Adding the SDK dependency and initializing the service are platform-specific. Before writing code, read the reference for the target platform listed under Initialization Code References.

More info in Firebase AI Logic Getting Started


Core Capabilities

[!WARNING] CRITICAL: Use current model names: Always check the Firebase AI Logic Models documentation for the currently supported model names. Do NOT use any Gemini 1.x or Gemini 2.x models (such as gemini-1.5-flash, gemini-1.5-pro, gemini-2.0-flash, gemini-2.0-pro, gemini-2.5-flash, gemini-2.5-flash-lite, or gemini-2.5-pro), as older models are deprecated or shut down. Always use a currently supported Gemini 3+ model; if URL access is blocked in your environment, proceed directly without searching local files.

Text-Only Generation
Multimodal (Text + Images/Audio/Video/PDF input)

Firebase AI Logic allows Gemini models to analyze image files directly from your app. This enables features like creating captions, answering questions about images, detecting objects, and categorizing images. Beyond images, Gemini can analyze other media types like audio, video, and PDFs by passing them as inline data with their MIME type. For files larger than 20 megabytes (which can cause HTTP 413 errors as inline data), store them in Cloud Storage for Firebase and pass their URLs to the Gemini Developer API.

Chat Session (Multi-turn)

Maintain history automatically using startChat.

Streaming Responses

To improve the user experience by showing partial results as they arrive (like a typing effect), use generateContentStream instead of generateContent for faster display of results.

Text-to-Speech (TTS) Generation

Generate spoken audio directly on client devices without a custom speech backend. Firebase AI Logic supports speech synthesis using dedicated Gemini TTS models:

  • Supported Models: gemini-3.1-flash-tts-preview

  • Capabilities:

    • Single-speaker voice persona selection (voiceName) and multi-speaker dialogues (up to 2 distinct speakers) via SpeechConfig / MultiSpeakerVoiceConfig

    • Direct audio responses by setting responseModalities to audio

    • Streaming speech responses with generateContentStream for low-latency playback

    • Audio directives ([Audio Profile: ...], [Scene: ...], [Director's Note: ...]) and emotional tags ([whispers], [laughs], [slowly])

    • Client-side decoding and playback of 24 kHz 16-bit linear PCM (audio/l16) or WAV container format (audio/x-wav)

See the Text-to-Speech (TTS) Generation Guide for full implementation details, streaming patterns, and copy-paste code snippets for iOS (Swift), Android (Kotlin), and Web.

Generate Images with Nano Banana

[!WARNING] Use current Image model names: Always check the Firebase AI Logic Models documentation for the currently supported image generation (Nano Banana) model names.

  • Requires an upgraded Blaze pay-as-you-go billing plan.

Search Grounding with the built in googleSearch tool

Supported Platforms and Frameworks

Supported Platforms and Frameworks include Kotlin and Java for Android, Swift for iOS, JavaScript for web apps, Dart for Flutter, and C Sharp for Unity.

Advanced Features

Structured Output (JSON)

Enforce a specific JSON schema for the response.

On-Device AI (Hybrid)

Hybrid inference runs prompts with an on-device model when one is available and falls back to a cloud-hosted model otherwise (or vice versa). Availability and setup steps differ by platform, more info in the hybrid and on-device documentation, which links to each platform's guide.


Security & Production

Firebase App Check

[!WARNING] Critical Safety Requirement: In order to use AI Logic safely, you MUST set up App Check on your app. This prevents unauthorized clients from using your API quota and accessing your backend resources.

See App Check for Firebase AI Logic for setup instructions. Each platform uses its own attestation provider, so follow the instructions for the target platform.

App Check Debug Tokens for Local Development & CI/CD

Because App Check attestation providers (like Play Integrity or DeviceCheck) reject emulators, simulators, or CI environments, you must use App Check Debug Tokens during development and testing to bypass standard attestation.

[!WARNING] CRITICAL: Never Hardcode or Commit Debug Tokens App Check debug tokens allow clients to bypass attestation and access backend resources without a genuine device. Treat them as private secrets. Never commit debug tokens to version control or hardcode raw token strings in client code (Web, Android, iOS, or Flutter). Always inject them through local environment variables, gitignored local configurations, or CI secrets. If a token is compromised, revoke it immediately in the Firebase Console.

Local Development (Auto-Generated)
  1. Configure your code's App Check provider to use the debug factory. The API is platform-specific; see the App Check section of the platform reference or the App Check documentation linked above.

  2. Run your app in the emulator/localhost.

  3. Look at your runtime debugger console / Logcat logs for the generated UUID:

    • Example: AppCheck debug token: "123a4567-b89c-12d3-e456-789012345678"

  4. Register this token in the Firebase Console under Security > App Check > Apps > Manage debug tokens.

💡 Tip (Prevent Debug Token Churn): Simulator or emulator resets, fresh installs, and clearing browser data can make the SDK generate a new debug token that you must register again. To keep a stable debug token without hardcoding it, see the App Check section of the platform reference.

CI/CD Pipelines (Pre-Provisioned)
  1. Generate and register a new debug token in the Firebase Console under Security > App Check > Apps > Manage debug tokens.

  2. Add this token string as an encrypted secret in your CI system (e.g. APP_CHECK_DEBUG_TOKEN).

  3. Configure your build to pass this secret as an environment variable to the SDK during test execution.

Firebase Remote Config

Consider that you do not need to hardcode model names (e.g., a specific model version string). Use Firebase Remote Config to update model versions dynamically without deploying new client code. See Changing model names remotely


Initialization Code References

[!WARNING] CRITICAL: Use current model names: Always check the Firebase AI Logic Models documentation for the currently supported model names. Do NOT use any Gemini 1.x or Gemini 2.x models (such as gemini-1.5-flash, gemini-2.0-flash, gemini-2.5-flash, or gemini-2.5-flash-lite), as older models are deprecated or shut down.

References

Android (Kotlin) SDK usage patterns iOS SDK code examples and usage patterns Web SDK setup, code examples, and usage patterns

Flutter SDK code examples and usage patterns Client-side Text-to-Speech (TTS) generation

Files

LICENSE


                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Google LLC
Publisher
Firebase (Google) (Official)
Distributed by
Firebase (Google)
Source
firebase/agent-skills · skills/firebase-ai-logic-basics · commit b76be96
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google LLC or Firebase (Google).

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download firebase-ai-logic-basics.zip