G-gen の武井です。当記事では Cloud Billing の新機能である Spend cap budgets を用いて、意図しない課金を防ぐ方法を解説します。

はじめに
Spend cap budgets とは
Spend cap budgets とは、上限額に到達した際に対象サービスの利用を自動的に一時停止する機能です。2026年4月の Google Cloud Next '26 で発表され、2026年7月27日にパブリックプレビューになりました。
従来の予算とアラート機能は上限額に到達した際に指定の宛先に通知するもので、支出そのものを止める仕組みは含まれていませんでした。Spend cap budgets は、この「止める」処理を予算とアラートの拡張機能として提供します。
動作の流れは以下のとおりです。
- 目標金額の 50%・80% に到達した時点でアラートメールが送信される
- 100% に到達すると対象サービスへの新規リクエストがブロックされる
- 上限は自動解除されず、ユーザーが手動で解除するまで停止が継続する
ただし、最も重要な制約として、後述のように、当機能は Google Cloud パートナーから発行された請求先アカウントでは使用できません。当機能が使用できるのは、Google との直接契約を結んでいる場合のみです。
パートナーの請求先アカウントでの使用について
Spend cap budgets が使用できるのは Google Cloud と直接、契約を結んでいる場合に限定されます。G-gen 社のような Google Cloud パートナー(リセラー)の請求先アカウントでは、当機能が使用できないことが明記されています。
Spend cap budgets are limited to first-party Google Cloud customers. Reseller accounts are out of scope.
ただし、当記事の検証を行った2026年7月下旬時点で、当社が販売パートナーとして保有する請求先アカウント配下のサブアカウントで実施したところ、予算の作成、各閾値でのアラートメールの受信、上限額到達時のサービス停止まで、いずれも正常に動作しました。
ただし、ドキュメントに明記されている以上、今後の仕様変更によって予告なく利用できなくなる可能性があります。そのため、パートナーから発行された請求先アカウントを使用している場合、当機能の本番環境での使用は推奨されません。
対象サービス
2026年7月現在、Spend cap budgets の対象サービスは以下のとおりです。これら以外のサービスでは、従来通り予算とアラート機能によるアラート通知のみが提供されます。
- Gemini API
- Gemini Enterprise Agent Platform(旧称 Vertex AI)
- Cloud Run
- Cloud Run functions
参考 : Services that are eligible for spend cap budgets
制約
Spend cap budgets には以下の制約があります。
| 分類 | 制約内容 |
|---|---|
| スコープ | 単一プロジェクト、かつ単一の対象サービスにのみ設定可能 |
| 期間 | 毎月 1 日開始の「月別」に固定。変更不可 |
| 契約形態 | Google Cloud 直接契約の顧客のみ。リセラー経由の請求先アカウントは対象外 |
| 上限額 | 割引やクレジットを含まない総額ベースで計算 |
| 適用範囲 | 従量課金、確約利用割引(CUD)、プロビジョンドスループット(PT) ※ サブスクリプションベースの費用は停止対象外 |
| 反映遅延 | 判定処理の遅延に伴う上限超過分は通常どおり課金される |
| 既存予算 | 「アラートのみ」の予算からは変換不可。削除したうえで新規作成が必要 |
注意が必要なのは、上限到達時のサービス停止が即時反映ではない点です。そのため、設定の際は想定する上限額に対し、やや低い金額を設定することが推奨されています。
必要な権限
Spend cap budgets の作成および管理には、以下のいずれかの権限が必要です。
- 請求先アカウントに対する Billing Account Administrator(
roles/billing.admin) - 対象プロジェクトに対する Project Owner(
roles/owner) - 請求先アカウントに対する Billing Account Costs Manager(
roles/billing.costsManager)と、対象プロジェクトに対する Project Editor(roles/editor)の組み合わせ
参考 : Permissions required to manage spend cap budgets
設定方法
予算の作成
対象のプロジェクトから課金 > リンクされた請求先アカウント > 予算とアラート と進み、Create budget を選択します。ウィザードは 4 つのステップで構成されています。

1. 定義
利用額上限の適用(一部のサービスで利用可能)にチェックを入れて名前を入力します。

2. 範囲
次に、対象プロジェクトと対象サービスを選択します。対象サービスについては前述の通りです。なお、期間は月別に自動設定されており、変更できません。

3. 金額
次に上限額を入力します。今回は動作確認のため¥100としていますが、実際の設定においては、即時反映ではないことを考慮した上限額を設定してください。

4. 操作
操作については変更ができません。また、現時点では従来の予算とアラートのように通知先チャネルの選択もできません。最後に設定内容に問題がなければ保存します。

今回の例では Cloud Run と Gemini Enterprise Agent Platform に対し、それぞれ上限額を¥100とした Spend cap budgets を2つ設定しました。

動作確認
確認内容
対象のサービスの利用額が 50% / 80% / 100% に到達したときの挙動を確認します。
Cloud Run
50% 到達時
課金管理者およびプロジェクトオーナーに対し、上限額の50%に到達した旨の通知がありました。

80 % 到達時
上記同様、課金管理者およびプロジェクトオーナーに対し、上限額の80%に到達した旨の通知がありました。

100 % 到達時
100% に到達した際の通知は 50% や 80% 到達時とは異なり、サービスの一時停止を知らせる旨(Service paused)の通知がありました。

通知受領前の Cloud Run の状態は以下の通りでした。

通知受領後の画面では、利用額上限に達したため、サービスが一時停止された旨の警告が表示されています。

この状態で新たに Cloud Run をデプロイしようとしても、API が一時的に停止しているためエラーとなりました。
# Cloud Run サービスのデプロイ yutakei@cloudshell:~ (yutakei)$ gcloud run deploy spend-cap-test2 \ --image=us-docker.pkg.dev/cloudrun/container/hello \ --region=us-central1 \ --cpu=4 \ --memory=2Gi \ --min-instances=2 \ --max-instances=2 \ --no-cpu-throttling \ --no-allow-unauthenticated Deploying container to Cloud Run service [spend-cap-test2] in project [yutakei] region [us-central1] Deploying new service... Creating Revision...failed Deployment failed
# エラーログ ERROR: (gcloud.run.deploy) The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short. The health check timeout can be extended. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=yutakei&resource=cloud_run_revision/service_name/spend-cap-test2/revision_name/spend-cap-test2-00001-gnl&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22spend-cap-test2%22%0Aresource.labels.revision_name%3D%22spend-cap-test2-00001-gnl%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
一時停止解除
該当の Spend cap budgets はステータスが適用済みとなっています。適用済みの場合、指定されたサービスは手動で上限を解除するまで一時停止されます。

解除には利用額上限を解除をクリックします。

なお、解除時には以下の留意事項が表示されます。
- 解除すると、対象プロジェクトの当該サービスのみが再開する
- 同一の請求月内に解除した場合、目標金額を引き上げない限り、その月の残り期間は再度発動しない
- 翌月にはリセットされ、再び上限額の到達で発動する
- 完全に再開するまでに1時間程度かかる場合がある

解除すると解除の旨を伝えるメール通知とともに再開されます。画面からも設定した上限額を多少超過したところで停止されていたことがわかります。

再検証のため(同一月内で再度発動するようにするため)、上限額を¥200に引き上げて確認します。

完全に再開するまでに 1 時間程度かかる場合があるとありましたが、手元の環境では再開後まもなく、先程は失敗した Cloud Run サービスのデプロイに成功しました。
# Cloud Run サービスのデプロイ(リトライ) yutakei@cloudshell:~ (yutakei)$ gcloud run deploy spend-cap-test2 \ --image=us-docker.pkg.dev/cloudrun/container/hello \ --region=us-central1 \ --cpu=4 \ --memory=2Gi \ --min-instances=2 \ --max-instances=2 \ --no-cpu-throttling \ --no-allow-unauthenticated Deploying container to Cloud Run service [spend-cap-test2] in project [yutakei] region [us-central1] Deploying... Setting IAM Policy...done Creating Revision...done Routing traffic...done Done. Service [spend-cap-test2] revision [spend-cap-test2-00002-ckj] has been deployed and is serving 100 percent of traffic. Service URL: https://spend-cap-test2-933617552181.us-central1.run.app Proxy locally with: gcloud run services proxy spend-cap-test2 --region us-central1 --project yutakei
その後は、50%および80%到達時、そして100%到達時の一時停止を知らせる旨のメール通知を再度受信しました。サービスについては再度一時停止状態となりました。

# Cloud Run サービスのデプロイ yutakei@cloudshell:~ (yutakei)$ gcloud run deploy spend-cap-test3 \ --image=us-docker.pkg.dev/cloudrun/container/hello \ --region=us-central1 \ --cpu=4 \ --memory=2Gi \ --min-instances=2 \ --max-instances=2 \ --no-cpu-throttling \ --no-allow-unauthenticated Deploying container to Cloud Run service [spend-cap-test3] in project [yutakei] region [us-central1] Deploying new service... Creating Revision...failed Deployment failed
# エラーログ ERROR: (gcloud.run.deploy) The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short. The health check timeout can be extended. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=yutakei&resource=cloud_run_revision/service_name/spend-cap-test3/revision_name/spend-cap-test3-00001-mlx&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22spend-cap-test3%22%0Aresource.labels.revision_name%3D%22spend-cap-test3-00001-mlx%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
Gemini Enterprise Agent Platform
こちらの動作確認では、Gemini で生成した以下の画像生成スクリプトを実行して上限到達時の挙動を確認しました。
for i in $(seq 1 40); do TS=$(date '+%Y-%m-%d %H:%M:%S') CODE=$(curl -s -o /tmp/resp.json -w '%{http_code}' -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "$ENDPOINT" \ -d '{ "contents": [{"role": "user", "parts": [{"text": "A photorealistic Japanese garden in autumn"}]}], "generationConfig": {"responseModalities": ["TEXT", "IMAGE"]} }') if [ "$CODE" = "200" ]; then TOK=$(jq -r '.usageMetadata.candidatesTokenCount // 0' /tmp/resp.json) echo "${TS} ${i}枚目 HTTP 200 出力 ${TOK} tokens" | tee -a "$LOG" else echo "${TS} ${i}枚目 HTTP ${CODE}" | tee -a "$LOG" echo "--- エラー応答 ---" | tee -a "$LOG" cat /tmp/resp.json | tee -a "$LOG" echo | tee -a "$LOG" break fi sleep 10 done
比較的すぐに100%に到達したためか、50%と80%到達時のメール通知がなく、100%到達時のメールのみを受信しました。

また、スクリプトについても100%到達後しばらくしてエラー終了しました。
2026-07-29 18:30:29 28枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:30:46 29枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:31:05 30枚目 HTTP 200 出力 1290 tokens 2026-07-29 18:31:23 31枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:31:41 32枚目 HTTP 200 出力 1302 tokens 2026-07-29 18:31:59 33枚目 HTTP 200 出力 1295 tokens 2026-07-29 18:32:17 34枚目 HTTP 200 出力 1295 tokens 2026-07-29 18:32:34 35枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:32:53 36枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:33:11 37枚目 HTTP 200 出力 1304 tokens 2026-07-29 18:33:29 38枚目 HTTP 200 出力 1301 tokens 2026-07-29 18:33:48 39枚目 HTTP 200 出力 1303 tokens 2026-07-29 18:34:07 40枚目 HTTP 403 --- エラー応答 --- { "error": { "code": 403, "message": "Spend cap breached for project: projects/123456789 for service: aiplatform.googleapis.com. Correlation id: -94604043111382696", "status": "PERMISSION_DENIED" } }
上限に到達した状態では、Cloud Run 同様 API コールがエラーになりました。
2026-07-29 22:55:33 1枚目 HTTP 403 --- エラー応答 --- { "error": { "code": 403, "message": "Spend cap breached for project: projects/123456789 for service: aiplatform.googleapis.com. Correlation id: 5729569255055718255", "status": "PERMISSION_DENIED" } }
