firebase-ai-logic

Integrates Firebase AI Logic Gemini API into web apps for multimodal inference and structured output.

Updated Aug 5, 2024
One-click install
npx skills add https://github.com/nikhilkakarla/nikhilkakarla.github.io --skill firebase-ai-logic-nikhilkakarla
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: firebase-ai-logic
Source: https://github.com/nikhilkakarla/nikhilkakarla.github.io/tree/main/.agents/skills/firebase-ai-logic
Command: npx skills add https://github.com/nikhilkakarla/nikhilkakarla.github.io --skill firebase-ai-logic-nikhilkakarla

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires firebase, and includes references (resource) components.

What problem does it solve? Adding generative AI to mobile and web apps normally requires managing a backend server and API keys. This Skill guides you through integrating Firebase AI Logic so you can call Gemini models directly from client-side code with proper setup, security, and production practices. ## Core Features & Use Cases - Setup & Initialization: Install the Firebase SDK, select a project, and initialize AI Logic with the Gemini Developer API or Vertex AI Gemini API backend. - Multimodal Inference: Generate text, analyze images, audio, video, and PDFs, run multi-turn chat sessions, stream responses, and generate images with Gemini image models. - Structured Output & Security: Enforce JSON schemas on responses, protect API quota with Firebase App Check, and manage model versions via Remote Config. - Use Case: Build a web app feature where users upload a photo and ask questions about it, streaming Gemini's answer in real time while App Check prevents unauthorized API usage. ## Quick Start Set up Firebase AI Logic in my web app and write code that sends a text prompt to the Gemini model and streams the response.

Frequently Asked Questions about firebase-ai-logic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Gemini AI to my web app with Firebase?▼

Install the Firebase SDK with npm, initialize your Firebase app, then call getAI with a GoogleAIBackend and create a model with getGenerativeModel. Run npx firebase-tools init and choose AI Logic to enable the Gemini Developer API automatically.

Gemini Developer API vs Vertex AI Gemini API, which should I use?▼

Use the Gemini Developer API by default since it offers a free tier for prototyping and pay-as-you-go for production. Choose the Vertex AI Gemini API only when you need enterprise-grade scale, which requires the Blaze plan.

Can Firebase AI Logic analyze images, audio, and PDF files?▼

Yes, Gemini models accept images, audio, video, and PDFs as inline base64 data with their MIME type. For files larger than 20 megabytes, upload them to Cloud Storage for Firebase and pass the file URL instead to avoid HTTP 413 errors.

How do I get structured JSON output from Gemini in Firebase?▼

Set responseMimeType to application/json in the generation config and optionally define a schema using Schema.object when creating the model. The model response can then be parsed directly with JSON.parse.

How do I protect my Gemini API quota from unauthorized clients?▼

Enable Firebase App Check, for example with the reCAPTCHA Enterprise provider, so only verified app instances can call the API. You can also use Remote Config to change model names without redeploying client code.