The latest Gemini models, like Gemini 3.5 Flash, are available to use with Firebase AI Logic! Learn more.
Gemini 2.0 Flash and Flash-Lite models were shut down on June 1, 2026. To avoid service disruption, update to a newer model like gemini-3.1-flash-lite. Learn more.
本页面介绍了 Gemini API
和 Firebase AI Logic SDK 的常见错误代码的排查方法。
400 错误:API key not valid. Please pass a valid API key.
如果您收到 400 错误,并显示 API key not valid. Please pass a valid API key.,通常意味着 Firebase 配置文件/对象中的 API 密钥不存在,或者未设置为与您的应用和/或 Firebase 项目搭配使用。
检查 Firebase 配置文件/对象中列出的 API 密钥是否与应用的 API 密钥匹配。您可以在
API 和服务 > 凭据
面板中查看所有 API 密钥。Google Cloud
如果您发现它们不匹配,请
获取新的 Firebase 配置文件/对象,
然后替换应用中的文件/对象。新的配置文件/对象
应包含适用于您的应用和 Firebase 项目的有效 API 密钥。
400 错误: Service agents are being provisioned ... Service agents are needed to read the Cloud Storage file provided.
如果您尝试使用 Cloud Storage for Firebase
网址发送多模态请求,可能会遇到以下 400 错误: Service agents are being provisioned ... Service agents are needed to read the Cloud Storage file provided.
此错误是由以下原因造成的:在项目中启用 Vertex AI API 时,项目未正确自动预配所需的服务代理
。这是某些项目的已知问题,我们正在努力进行全局修复。
以下是解决项目问题并正确预配这些服务
代理的解决方法,以便您开始在多模态请求中添加 Cloud Storage for Firebase 网址,以便在多模态请求中使用。您必须是项目上的
所有者,并且只需为项目
完成一次这组任务。
访问 gcloud CLI 并进行身份验证。
最简单的方法是通过 Cloud Shell 进行访问。如需了解详情,请参阅
Google Cloud文档。
403 错误: Requests to this API firebasevertexai.googleapis.com ... are blocked.
如果您收到 403 错误,并显示 Requests to this API firebasevertexai.googleapis.com ... are blocked.,通常意味着应用中 Firebase 配置的 API 密钥具有限制,阻止其调用所需的 API。
如需解决此问题,您需要在 API 密钥的限制中更新
Google Cloud 控制台,以包含所需的 API。对于 Firebase AI Logic,
您必须确保 Firebase AI Logic API
(firebasevertexai.googleapis.com) 包含在可以使用 API 密钥调用的所选
API 列表中。
404 错误:模型“was not found or your project does not have access to it”?
例如:“Publisher Model projects/PROJECT-ID/locations/us-central1/publishers/google/models/gemini-3-pro-image-preview was not found or your project does not have access to it. Please ensure you are using a valid model version.”