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.
如果您收到一条显示 API key not valid. Please pass a valid API key. 的 400 错误,通常意味着 Firebase 配置文件/对象中的 API 密钥不存在,或者未设置为与您的应用和/或 Firebase 项目搭配使用。
检查 Firebase 配置文件/对象中列出的 API 密钥是否与应用的 API 密钥一致。您可以在 Google Cloud 控制台的 API 和服务 > 凭据面板中查看所有 API 密钥。
如果您发现它们不匹配,请获取新的 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 网址。您必须是项目的所有者,并且只需为项目完成一次这组任务。
403 错误:Requests to this API firebasevertexai.googleapis.com ... are blocked.
如果您收到一条 403 错误,其中显示 Requests to this API firebasevertexai.googleapis.com ... are blocked.,这通常意味着您应用中 Firebase 配置中的 API 密钥具有限制,导致其无法调用所需的 API。
如需解决此问题,您需要在 Google Cloud 控制台中更新 API 密钥的限制,以包含所需的 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.1-pro-preview was not found or your project does not have access to it. Please ensure you are using a valid model version.”