【Firebase】Requests to this API firebasevertexai.googlea...are blocked.

に公開

エラー内容

公式ドキュメントの通りに初期設定を終え、いざ実行!と思ったがエラー。

Requests to this API firebasevertexai.googleapis.com method google.firebase.vertexai.v1beta.GenerativeService.GenerateContent are blocked.

よくある質問にも記載があるが...

https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?authuser=0&hl=ja&api=dev#error-requests-to-service-blocked

アプリで使用されている API キーに、キーの「API の制限」許可リストに必要な API がすべて含まれていることを確認します。Firebase AI Logic の場合、API キーの許可リストに少なくとも Firebase AI Logic API が含まれている必要があります。

すべての API キーは、Google Cloud コンソールの [API とサービス] > [認証情報] パネルで確認できます。

解決方法

Google Cloud Console の 認証情報から、APIキーの制限を編集する。

https://console.cloud.google.com/apis/credentials

今回は「Gemini Developer API key (auto created by Firebase)」をクリック。

必要なAPIにチェック。

エラー!

エラーが消えない...。

Requests to this API firebasevertexai.googleapis.com method google.firebase.vertexai.v1beta.GenerativeService.GenerateContent are blocked.

原因

アプリで使用されている "全ての" API キーに権限が必要。つまり「Gemini Developer API key (auto created by Firebase)」以外のキーにも、AI関連の制限許可が必要だった。

まとめ

言われてみれば当然のことですが、少しつまりました...。

Fivot Tech Blog

Discussion