firebase-vertex-ai

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Firebase Vertex AI

Firebase Vertex AI

Operate Firebase projects end-to-end (Auth, Firestore, Functions, Hosting) and integrate Gemini/Vertex AI safely for AI-powered features.
端到端操作Firebase项目(身份验证、Firestore、云函数、托管),并安全集成Gemini/Vertex AI以实现AI驱动功能。

Overview

概述

Use this skill to design, implement, and deploy Firebase applications that call Vertex AI/Gemini from Cloud Functions (or other GCP services) with secure secrets handling, least-privilege IAM, and production-ready observability.
使用此技能设计、实现并部署Firebase应用,这些应用可通过Cloud Functions(或其他GCP服务)调用Vertex AI/Gemini,同时具备安全的密钥管理、最小权限IAM配置以及生产级可观测性。

Prerequisites

前置条件

  • Node.js runtime and Firebase CLI access for the target project
  • A Firebase project (billing enabled for Functions/Vertex AI as needed)
  • Vertex AI API enabled and permissions to call Gemini/Vertex AI from your backend
  • Secrets managed via env vars or Secret Manager (never in client code)
  • 目标项目需具备Node.js运行时环境及Firebase CLI访问权限
  • 一个Firebase项目(根据需要为云函数/Vertex AI启用计费)
  • 已启用Vertex AI API,且后端具备调用Gemini/Vertex AI的权限
  • 通过环境变量或Secret Manager管理密钥(绝不要在客户端代码中存储)

Instructions

操作步骤

  1. Initialize Firebase (or validate an existing repo): Hosting/Functions/Firestore as required.
  2. Implement backend integration:
    • add a Cloud Function/HTTP endpoint that calls Gemini/Vertex AI
    • validate inputs and return structured responses
  3. Configure data and security:
    • Firestore rules + indexes
    • Storage rules (if applicable)
    • Auth providers and authorization checks
  4. Deploy and verify:
    • deploy Functions/Hosting
    • run smoke tests against deployed endpoints
  5. Add ops guardrails:
    • logging/metrics
    • alerting for error spikes
    • basic cost controls (budgets/quotas) where appropriate
  1. 初始化Firebase(或验证现有仓库):根据需要配置托管/云函数/Firestore。
  2. 实现后端集成:
    • 添加一个调用Gemini/Vertex AI的Cloud Function/HTTP端点
    • 验证输入并返回结构化响应
  3. 配置数据与安全:
    • Firestore规则及索引
    • 存储规则(如适用)
    • 身份验证提供商及授权检查
  4. 部署与验证:
    • 部署云函数/托管服务
    • 针对已部署端点运行冒烟测试
  5. 添加运维防护措施:
    • 日志/指标监控
    • 错误峰值告警
    • 酌情配置基础成本控制(预算/配额)

Output

输出结果

  • A deployable Firebase project structure (configs + Functions/Hosting as needed)
  • Secure backend code that calls Gemini/Vertex AI (with secrets handled correctly)
  • Firestore/Storage rules and index guidance
  • A verification checklist (local + deployed) and CI-ready commands
  • 可部署的Firebase项目结构(含配置文件及所需的云函数/托管代码)
  • 安全调用Gemini/Vertex AI的后端代码(密钥处理合规)
  • Firestore/存储规则及索引配置指南
  • 本地及部署环境的验证清单,以及适用于CI的命令

Error Handling

错误处理

  • Auth failures: identify the principal and missing permission/role; fix with least privilege.
  • Billing/API issues: detect which API or quota is blocking and provide remediation steps.
  • Firestore rule/index problems: provide minimal repro queries and rule fixes.
  • Vertex AI call failures: surface model/region mismatches and add retries/backoff for transient errors.
  • 身份验证失败:识别主体及缺失的权限/角色,通过最小权限原则修复。
  • 计费/API问题:检测被阻塞的API或配额,并提供修复步骤。
  • Firestore规则/索引问题:提供最小化复现查询及规则修复方案。
  • Vertex AI调用失败:排查模型/区域不匹配问题,为瞬时错误添加重试/退避机制。

Examples

示例

Example: Gemini-backed chat API on Firebase
  • Request: “Deploy Hosting + a Function that powers a Gemini chat endpoint.”
  • Result:
    /api/chat
    function, Secret Manager wiring, and smoke tests.
Example: Firestore-powered RAG
  • Request: “Build a RAG flow that embeds docs and answers with citations.”
  • Result: ingestion plan, embedding + index strategy, and evaluation prompts.
示例:基于Gemini的Firebase聊天API
  • 请求:“部署托管服务+一个支持Gemini聊天端点的云函数。”
  • 结果:
    /api/chat
    云函数、Secret Manager配置及冒烟测试。
示例:基于Firestore的RAG系统
  • 请求:“构建一个嵌入文档并带引用回答的RAG流程。”
  • 结果:数据摄入方案、嵌入+索引策略及评估提示词。

Resources

参考资源