
firebase-ai-logic-basics
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.
- Installs
- 136.2K
- Last 24h
- +496
- Trending rank
- #696
- Security
- Pass
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/firebase/agent-skills --skill firebase-ai-logic-basics- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads firebase-ai-logic-basics automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
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
npxon every platform, so they need Node.js 20+ and npm. Use thefirebase-basicsskill 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 withsudo 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:
-
Make sure that you're in a firebase directory (with a
firebase.json). -
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 -
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 -
Provision Firebase AI Logic for the Firebase Project:
npx -y firebase-tools@latest init ailogicThis 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 ailogicto provision the service. The configuration files ofGoogleService-Info.plist,google-services.json, andfirebase_options.dartONLY handle client configuration and do NOT enable the Firebase AI Logic service, leading toPERMISSION_DENIEDerrors.
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
gemini-2.0-proorgemini-2.0-flashor other older models that are shutdown.
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) viaSpeechConfig/MultiSpeakerVoiceConfig - Direct audio responses by setting
responseModalitiesto audio - Streaming speech responses with
generateContentStreamfor 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)
- Single-speaker voice persona selection (
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)
- 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.
- Run your app in the emulator/localhost.
- Look at your runtime debugger console / Logcat logs for the generated UUID:
- Example:
AppCheck debug token: "123a4567-b89c-12d3-e456-789012345678"
- Example:
- 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)
- Generate and register a new debug token in the Firebase Console under Security > App Check > Apps > Manage debug tokens.
- Add this token string as an encrypted secret in your CI system (e.g.
APP_CHECK_DEBUG_TOKEN). - 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
-
Android (Kotlin)
- Gemini API Provider: Gemini Developer API
- Reference: usage_patterns_android.md
-
iOS (Swift)
- Gemini API Provider: Gemini Developer API
- Reference: ios_setup.md
-
Web Modular API
- Gemini API Provider: Gemini Developer API
- Reference: usage_patterns_web.md
-
Flutter (Dart)
- Gemini API Provider: Gemini Developer API
- Reference: flutter_setup.md
[!WARNING] CRITICAL: Use current model names: Always check the Firebase AI Logic Models documentation for the currently supported model names. Do NOT use
gemini-2.0-proorgemini-2.0-flashor other older models that are shutdown.
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
FAQ
What does the firebase-ai-logic-basics skill do?
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.
How do I install firebase-ai-logic-basics?
Run npx skills add https://github.com/firebase/agent-skills --skill firebase-ai-logic-basics in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/firebase-ai-logic-basics/ (personal) or .claude/skills/firebase-ai-logic-basics/ (project).
Which AI agents can use firebase-ai-logic-basics?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is firebase-ai-logic-basics safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains firebase-ai-logic-basics?
It is published by firebase in firebase/agent-skills, and it is an official skill from the maker of the technology it covers. It has 136,225 recorded installs.
More from firebase/agent-skills
firebase-basics
firebase/agent-skills
Provides foundational Firebase CLI setup, CLI installation, version checks (firebase-tools@latest --version), CLI login (including --no-localhost), project creation, project selection (firebase use), and app config file downloads (google-services.json, GoogleService-Info.plist). Use ONLY for CLI login, project creation/switching, or downloading app config files. Don't use for Firebase Hosting deploy, Firestore, Auth, App Hosting, Data Connect, Crashlytics, or Remote Config.
firebase-auth-basics
firebase/agent-skills
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.
firebase-hosting-basics
firebase/agent-skills
Deploys and configures classic Firebase Hosting for static websites, single-page apps (SPAs), and microservices. Use when deploying static sites/SPAs, setting up custom domains, configuring firebase.json hosting settings (redirects, rewrites, headers, multi-site), or managing preview channels. Don't use for Firebase App Hosting (Next.js/SSR), Auth, Firestore queries/rules, Data Connect, or Crashlytics.
firebase-app-hosting-basics
firebase/agent-skills
Deploys and manages full-stack web applications (Next.js, Angular) with Server-Side Rendering (SSR) using Firebase App Hosting. Use when deploying Next.js/Angular apps, configuring apphosting.yaml or firebase.json apphosting blocks, managing secrets, setting up GitHub CI/CD, or configuring Blaze billing requirements. Don't use for classic static web hosting, Auth, Firestore, Crashlytics, or Xcode.
firebase-data-connect
firebase/agent-skills
Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational database with Firebase, or when the user mentions SQL Connect or Data Connect.
firebase-security-rules-auditor
firebase/agent-skills
Audits Firebase (Firestore, Cloud Storage) security rules for vulnerabilities, privilege escalation, role bypasses, create vs update inconsistencies, resource exhaustion, type safety, size limits, and hasOnly ownership checks. Use when auditing/reviewing rules, running red-team rule assessments, or scoring against auditor checklists. Don't use for Firebase CLI (login, deploy), Auth, Crashlytics, Remote Config, or database queries.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available