More Menu
Reading ListGanti TemaSearch
Reading List

Queue · 0 items

Your reading list is empty. Save articles to read them later.

Start Reading

How an AI Coding Agent Ran Up an Unexpected GCP Bill Overnight

Iwan Efendi6 min
Google Cloud Billing dashboard showing Vertex AI charges alongside Google Developer Program credits.

An AI coding agent ran up an unexpected Google Cloud bill overnight. Here is why, how GCP credits really work, and the courtesy credit Google approved.

I was thrilled when my monthly Google Developer Program benefit arrived: a fresh allotment of Google Cloud credits (~IDR 181,835 / $12 USD) active on my billing account until April 2027. Naturally, I wanted to put these credits to good use. I set up an API key on Google Cloud's Vertex AI Platform to test out Gemini models directly inside OpenCode, my daily terminal coding assistant. Everything felt smooth and responsive. But when I checked my Google Cloud Billing dashboard the next morning, my stomach dropped. A raw usage spike of IDR 301,839 ($20 USD) had occurred overnight. Even with Google's automatic discounts shaving off half the cost, I was staring at an unexpected net charge of IDR 150,924 ($10 USD). Worse yet, my developer credits sat untouched at a 100% balance. Here is the full post-mortem of how an autonomous debugging loop quietly burned through millions of tokens, the critical billing account pitfall that caught me off guard, and the exact steps I took to mitigate future leaks and secure a one-time courtesy waiver from Google Cloud Support.

The Culprit: Context Window Loops on Heavy Models

If you use AI coding assistants like OpenCode, Aider, or Cline, you already know their power: they do not just answer questions; they read files, inspect error traces, run shell commands, and edit code autonomously. However, that autonomous loop has a hidden financial cost when debugging tricky errors. During my evening session, OpenCode was attempting to resolve a multi-file dependency error. To give it maximum reasoning power, I had selected Gemini 4 Argon—a flagship heavy-reasoning model available on Vertex AI. Here is a simplified, illustrative example (not my exact measurements) of how the context grows on every turn of an agentic debugging session:
TurnWhat gets sent to the modelApprox. input tokens
1System prompt + 2 files~25,000
2Turn 1 history + error stack trace + tool output~45,000
3Turns 1–2 history + 3 more files read~110,000
4Cumulative context + compiler failures~220,000
5Full project snapshot re-evaluated~310,000+
Because agentic coding tools resend the cumulative conversation history and every inspected file on every single turn, a debugging session that takes 15–20 iterations easily transmits tens of millions of cumulative tokens. When paired with a flagship-tier model like Gemini 4 Argon, raw charges accumulated to IDR 40,800 on a single model run, culminating in a daily raw spend of IDR 301,839.
Model Tiering Matters in Agentic Coding
Flagship models (Gemini 4 Argon, Claude Opus) are designed for architectural reviews and deep reasoning. Running them inside autonomous agentic loops where context windows expand uncontrollably will drain developer credits in a matter of hours.
Figure 1: The sudden cost spike in Google Cloud Billing driven by Gemini 4 Argon during autonomous error-fixing loops.

The Billing Trap: The Two-Account Mix-Up

High token consumption was only half the problem. I had assumed my Google Developer Program promotional credits would absorb the usage. When I opened Google Cloud Console's Billing Account Management, the real root cause became crystal clear:
  1. Firebase One (Primary Account): Contained my active Developer Program credit batch of IDR 181,835 with rolling validity through April 7, 2027.
  2. Firebase Two (Secondary Account): An older billing account with IDR 0 in credits, linked directly to my personal debit card.
When I initialized my new developer project (SnipGeek) on Google Cloud Console, it had automatically defaulted to Firebase Two. Google Cloud tracks billing strictly at the project-to-billing-account link level. Because promotional credits attached to Firebase One cannot retroactively cross over to cover usage on Firebase Two, every token generated by OpenCode was billed directly to my secondary account. Figure 2: Billing account management showing the cost disparity between my primary credited account (Firebase One) and my secondary account (Firebase Two).

Architectural Clarity: AI Studio Prepay vs Vertex AI Postpay

During troubleshooting, another confusing puzzle arose in Google AI Studio (aistudio.google.com). The dashboard flashed a persistent warning:
"A credit balance above $0 is required to resume service. Eligible GCP credits will automatically apply to usage first."
This led me to believe my credits were broken. In reality, Gemini can be reached through two different Google products, and the warning only applies to one of them:
Google AI StudioVertex AI (Google Cloud)
Endpointgenerativelanguage.googleapis.comaiplatform.googleapis.com
Key prefix I sawAIzaSy...AQ.
Billing checkRequires a balance above $0Uses your Cloud Billing account
Used by OpenCodeNoYes (google-vertex)
Because OpenCode talks to the Vertex AI backend through the google-vertex provider, the AI Studio warning was a red herring. My developer credits worked fine in Google Cloud; the project was simply attached to the wrong billing account. Once I moved it, Vertex AI usage on Firebase One was fully offset by the credits. Figure 3: The confusing Cloud Prepay warning in Google AI Studio, which applies only to direct Gemini API endpoints, not Vertex AI.

4 Steps to Fix It and Prevent a Repeat

Here is what I changed, plus one safeguard I recommend:
1
Open Google Cloud Console - My Projects Billing. Locate your project (SnipGeek), click the three vertical dots (⋮), select Change billing, and switch it to your primary billing account (Firebase One).
2

Confirm Zero Active Projects on Secondary Accounts

Inspect the old billing account (Firebase Two) and make sure it has no active projects attached. With no projects linked, no new charges can accrue on it.
3

Lock OpenCode to Cost-Effective Flash Models

Switch your default coding model from flagship tiers to lightweight ones:
  • google-vertex/gemini-3.8-flash: a fast, capable daily driver that costs far less than flagship models.
  • google-vertex/gemini-4-hydrogen: the lightest option, good for quick refactors.
4
In Cloud Console, open Billing > Budgets & alerts for Firebase One and create a budget of around IDR 150,000 with email alerts at 50%, 80%, and 100%. This catches a runaway session before the credits run out and your card is charged.

Requesting a One-Time Courtesy Waiver from Google Support

Because this was an honest first-time configuration mistake by a verified Google Developer Program member, I decided to contact Google Cloud Billing Support to request a courtesy adjustment. Navigating to a human agent can be tricky through automated support bots. Here is the exact path that worked:
  1. Open the Google Cloud Support Console while viewing the affected project.
  2. Under the left navigation, select Billing support (or click Cases > Create Case).
  3. Click Get billing support to launch the Billing Assistant widget.
  4. When the AI bot provides a generic policy explanation, explicitly prompt:
    "Yes, please connect me to a support rep to assist me with this."
  5. In the 140-character details box, summarize the issue cleanly:
    "One-time courtesy waiver request for accidental IDR 150K charges on Firebase Two due to setup mistake. Google Dev Program member."

The Result: A 75% Courtesy Adjustment Approved

I was connected to a live support representative named Emman. After reviewing the steps I had already taken (re-linking the project, confirming the old account had no projects, and switching to cheaper models), Emman documented the case and submitted an official request for a one-time courtesy goodwill adjustment. Within two days of our chat, the internal billing team completed their review and approved a one-time courtesy credit of IDR 113,193 (about 75% of the invoice), leaving a remaining balance of IDR 46,887 (~$2.90 USD) on the secondary account. It was not the full waiver I asked for, but Emman said the request had been advocated for as strongly as possible, and I was happy to take it:
Case Number: 77705774
Net Invoice (After Google's Discounts): IDR 150,924.00
Approved Courtesy Adjustment: -IDR 113,193.00 (~75%)
Remaining Balance: IDR 46,887.00 (~$2.90 USD)
Status: Approved (final outcome of the review)

Figure 4: Navigating to Google Cloud Billing Support and receiving live chat confirmation from Emman (Case 77705774).

What Helped My Case
Emman's first follow-up question was what I had already done to stop further charges. Arriving with a clear root cause and concrete fixes made the request much easier to advocate for. Approval is never guaranteed, though: I got about 75%, not the full amount.

Key Takeaways

  1. Autonomous coding agents burn tokens exponentially: Always start a new chat session after resolving a bug to prevent historical error traces from inflating subsequent prompt costs.
  2. Default to Flash models: Keep gemini-3.8-flash or gemini-4-hydrogen as your daily driver. Reserve Argon or Opus for deliberate, high-leverage architectural prompts.
  3. Double-check project billing associations: Never assume a new GCP project inherits the billing account of your developer perks. Always verify the link in Billing > Projects.
  4. Be polite and structured when disputing charges: If you experience an accidental charge, document your mitigation steps immediately and reach out to support. Google Cloud's billing team is remarkably understanding when approached professionally.
Topics

Topics in this article

Explore related topics and continue reading similar content.

Share this article

Discussion

Preparing the comments area...