dentvega/firebase-agent-skills/firebase-ai-logic
Claude Code and agent skill by dentvega/firebase-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Integrates the Gemini API into client apps via Firebase AI Logic — text generation, multimodal (image / video / audio) inference, structured JSON output, streaming, and chat sessions. Use whenever the user wants Gemini in a web or mobile app without proxying through their own backend, with App Check protection. Pair with firebase-app-check to prevent quota theft.
Install
npx vskill@latest install dentvega/firebase-agent-skills/firebase-ai-logicSKILL.md
The same SKILL.md was published earlier as dentvega/firebase-agent-skills/firebase-ai-logic.
Firebase AI Logic (Gemini)
Firebase AI Logic lets you call Gemini directly from the client without managing a backend or API key. The SDK exchanges App Check tokens for short-lived Gemini credentials — abuse-resistant by default.
There are two providers under the same SDK:
- Vertex AI in Firebase — billed via your Google Cloud project, enterprise SLAs, available in more regions, supports all Gemini models including 2.5 Pro/Flash.
- Google AI (Gemini Developer API) — billed via Firebase, simpler quota model, good for early-stage apps and prototypes.
Pick one per project. Migrating later requires re-init code; pick deliberately.
Minimum viable example
App Check must be initialized first — without it, anyone with your client bundle can spend your tokens. This is non-negotiable for production.
1. Enable the provider
Firebase Console → Build → AI Logic → Get Started → choose Vertex AI or Google AI. The console walks through enabling the underlying API.
2. Enable App Check (mandatory in production)
Without App Check, anyone with your web Firebase config can bill your project. See the firebase-app-check skill — initialize App Check before the AI SDK on every platform.
3. Install
Web
Expo / React Native
4. Model selection
| Model | When to use | |
|---|---|---|
gemini-2.5-flash | Default for most apps — fast, cheap, multimodal. Start here. | |
gemini-2.5-pro | Complex reasoning, long-context analysis, code generation. | |
gemini-2.5-flash-lite | Highest-volume / lowest-latency tasks. Classification, extraction. |
Pin to a specific version in production (gemini-2.5-flash-002) — unversioned aliases roll forward and can change behavior overnight.
5. Single-turn generation
6. Multimodal (image + text)
On React Native, load the image as base64 and pass:
For videos and audio, the same inlineData shape works with the appropriate MIME (video/mp4, audio/mp3). Files > 20 MB must be uploaded via Cloud Storage and referenced by URI.
7. Streaming responses
Streaming gives a much better UX — show tokens as they arrive instead of waiting 5+ seconds for a full response.
8. Structured JSON output
To get strictly-typed output instead of parsing free-form text:
The model is constrained to emit valid JSON matching the schema — no try/catch ladders.
9. Chat sessions (multi-turn)
Persist getHistory() to Firestore if you need conversations to survive app restarts.
For tool use / function calling — letting Gemini invoke your APIs or query Firestore as part of a conversation — see references/function-calling.md.
10. System instructions
Set persistent context that applies to every turn without consuming chat history:
11. Cost and quota
- All requests count against your provider's quota (Vertex AI quota for Vertex; Google AI free/paid tier for Google AI)
- Token-priced: input + output tokens. Multimodal inputs cost more per "token" because images/audio expand significantly.
- Cache long static prompts using context caching (Vertex AI feature) for repeated system prompts — drops cost by ~75%.
- Monitor in Firebase Console → AI Logic → Usage.
12. Common mistakes
- Shipping without App Check. Your Firebase web config + an AI Logic call = anyone can spend your money. Always enforce App Check before going to prod.
- Pinning to an unversioned model alias. Behavior changes silently. Pin to
gemini-2.5-flash-002or specific dates. - Calling from a server. Use the Vertex AI Node SDK or
firebase-admindirectly — Firebase AI Logic is client-only. - Treating JSON output as guaranteed valid. Even with
responseSchema, schema misses are rare but possible. WrapJSON.parsein try/catch and retry on failure. - Loading 100MB videos as inlineData. Use Cloud Storage URIs for anything > 20 MB.
- Forgetting `await` on `getHistory()`. It's async.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/firebase-ai-logic/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dentvega/firebase-agent-skills/firebase-ai-logic)