Asia/Shanghai
March 12, 2026

Can't Freeload Anymore? The Compliant Way to Use OpenCode + Gemini

不能白嫖了?聊聊 OpenCode + Gemini 的合规姿势

Mingjian Shao
Can't Freeload Anymore? The Compliant Way to Use OpenCode + Gemini
There is no such thing as a free lunch. That old saying hits hard if you spent your time figuring out how to milk Google One AI Pro for everything it was worth. Those early days when the "Claw craze" (OpenClaw) was everywhere are officially history. Using Antigravity authentication like it was your home security system and hammering Opus power through reverse proxy pools now feels like a straight path to a Google ban.Google finally wised up. They realized people weren't using Gemini to write code with OpenCode, but just to blast through free usage limits.It was wild at the start of 2026. Everyone thought Google's compute was endless, that you could just find a new "way" to get an infinite refill. The ban wave was faster than anyone expected.
Gemini CLI ToS violation error
When I first saw that ToS violation error, I still hoped it was just a fluke. Two weeks later, Google quietly lifted the ban. But I was foolish. I thought I had found a new trick and reconfigured Antigravity. A few days later, I was back on the blacklist. This time, I didn't get lucky; it was a permanent suspension warning.
Account Suspended notice
Google appeal form
Google made it clear. The problem was using third-party tools like OpenClaw, Claude Code, or OpenCode to directly access product login credentials. Their solution was straightforward: use Vertex AI or an AI Studio API Key.
计费熔断补充说明:我只做了 GCP 的熔断机制,但忽略了 AI Studio。结果单独生成了 2 个 $15 的账单,引以为戒!后来发现 AI Studio 可以在控制台直接设置消费上限(spend cap),而且它似乎只用了 $10 的 Google Developer Program premium benefit - CREDIT_TYPE_MONTHLY,那个 $300 的 Free Trial 根本没用上。
Looking at those accounts that totally died because of the Claw craze, I felt tired. Mass abuse just makes everyone else pay the price. After the storm settled and my accounts were restored in the Antigravity dashboard, I decided to play by the rules.
Antigravity Tools dashboard
Before I even figured out how to "legitimize" my setup, Gemini basically told me what to do. I poked around in AI Studio and asked how to use it reliably. It gave me an architecture without hesitation: AI Studio for experiments, Vertex AI (Service Account JSON) for production, and One API for aggregation.
Gemini's own dual-platform recommendation
I have to admit, AI is sometimes smarter than people. It threw the proper path right in my face, so why was I still chasing hacks?Switching to Vertex AI was painful. It was not just a simple API swap. I had to completely re-architect my GCP setup.This is the biggest trap for newcomers. Never create a GCP project under an Organization! Those projects managed by an Org have rigid API permissions and limited billing. I dumped my old project dulcet-fortress-489803-n2 and spun up a clean personal project gemini-project-489918 specifically for these AI tasks.I ditched the built-in vertex provider because it always pulls in a bunch of garbage models. I switched to a custom npm provider, reading ~/.config/gcloud/ai-master-key.json via googleAuthOptions.keyFile. This SA (vertex-express@gemini-project-489918.iam.gserviceaccount.com) is enterprise-grade, stable, and controlled.GCP billing keeps me awake at night. If a code loop runs wild and burns through all the compute, my credit card is doomed. I wrote an automatic kill switch mechanism.
Important note: The billing, quota, and limitation mechanisms for Vertex AI and AI Studio are incredibly complex. I haven't fully figured them out either. Each platform has independent quotas and billing methods, requiring separate protection measures.
The architecture is simple: set a $50 budget. If it hits 80%, it sends a signal to Pub/Sub. If it hits 100%, it triggers a Cloud Function. That function aggressively calls cloudbilling.updateBillingInfo(billingAccountName="") to forcibly kill billing.There are many traps here:
  • Budget alerts have latency; they are not real-time.
  • IAM permissions must be granted at the billing account level — project level is useless.
  • Gen2 Cloud Functions use CloudEvents format, which is totally incompatible with Gen1.
I landed on this setup:
  • Vertex AI (SA JSON): The main battlefield. Extremely stable, supports high-end stuff like customtools.
  • AI Studio (API Key): My backup. High limits and simple.
My fallback chain is: Vertex → AI Studio 1 → AI Studio 2 → local Qwen. All of this is managed through One API running on Unraid.
One API deployment guide
This is not abuse. This is optimized resource scheduling.In opencode.json, I killed all environment variables that automatically trigger the built-in Google provider (I nuked GOOGLE_APPLICATION_CREDENTIALS). I set up three providers: vertex (SA JSON), google (AI Studio 1), and google2 (AI Studio 2).Vertex's allow-list finally works, and it is clean — containing only the four models I need.With the foundation compliant, Gemini CLI v0.33 feels different. It is impressive now. It shares the same ~/.config/opencode/opencode.json with OpenCode, and both the skill directory and semantic memory are linked.Especially since I swapped to a machine with an M3 Max and 128GB of RAM, running the Gemini 3.1 preview, the time-to-first-token and multi-tasking speed make Claude Code look a little dated.
Gemini CLI v0.33 success
From constantly thinking about how to freeload, to building my own infrastructure, the Claw craze forced everyone to grow up. Honestly, playing by the proper rules is much more satisfying than those shady hacks from before.After all, tools are just tools. Going through the trouble of building your own infrastructure is the true moat for an engineer.
天下没有免费的午餐,这句话对于那些整天研究怎么把 Google One AI Pro 薅秃了的玩家来说,简直是当头一棒。去年那种满地都是"龙虾风"(OpenClaw)的日子彻底翻篇了。曾经那一套把 Antigravity 认证当成自家门禁、通过反向代理池无限制白嫖 Opus 算力的玩法,现在看起来就像是在 Google 的底线蹦迪。Google 终于回过神来了:你们拿我的 Gemini 跑 OpenCode 不是为了写代码,而是单纯为了把我的免费额度刷爆。那是 2026 年初的疯狂。大家觉得 Google 的算力取之不尽,只要换个"姿势"就能无限续杯。结果呢?封号潮来得比谁都快。
ToS violation error
我第一次看到这个"ToS violation"错误时,心里还抱着侥幸。过了两周,Google 居然悄悄解封了。但我当时鬼迷心窍,以为自己找到了新路子,重新配置了 Antigravity,结果没几天,再次被扔进黑名单。这次就没那么好运了,直接给了个永久封禁的警告。
Account Suspended
Google appeal form
Google 明确指出,问题出在通过第三方软件(比如 OpenClaw, Claude Code, OpenCode)直接访问产品登录凭据。他们给出的解决方案很直接:用 Vertex AI 或者 AI Studio API Key。
计费熔断补充说明:我只做了 GCP 的熔断机制,但忽略了 AI Studio。结果单独生成了 2 个 $15 的账单,引以为戒!后来发现 AI Studio 可以在控制台直接设置消费上限(spend cap),而且它似乎只用了 $10 的 Google Developer Program premium benefit - CREDIT_TYPE_MONTHLY,那个 $300 的 Free Trial 根本没用上。
看着那堆因为"龙虾风"而彻底暴毙的账号,我感到一阵心累。Mass abuse(滥用)最终只会让普通用户一起买单。在这一波封号风波平息后,我看着 Antigravity 仪表板里恢复的账号,决定换一种玩法。
Antigravity dashboard
其实在我想通怎么"正规化"之前,Gemini 自己就已经建议我该怎么玩了。我当时在 AI Studio 试探着问它,怎么才能稳定使用,结果它毫不避讳地给我列了一套架构:AI Studio 做实验,Vertex AI(Service Account JSON)做生产,One API 做聚合。
Gemini recommendation
不得不说,这 AI 有时候比人聪明。它直接把"正规姿势"扔在了我脸上,那我还折腾什么 hacks?转向 Vertex AI 是一场血泪史。这不是简单地换个接口,而是要把整个 GCP 的架构翻过来重新搭。这绝对是新手最容易踩的坑。千万别在 Organization 下面创建 GCP 项目!那些被 Org 纳管的项目,API 权限死板得要命,计费也各种受限。我果断放弃了老项目 dulcet-fortress-489803-n2,重新起了一个干净的个人项目 gemini-project-489918,用来专门跑我的这些 AI 任务。放弃内置的 vertex provider,因为它总会带出一堆垃圾模型。我改用了 custom npm provider,直接通过 googleAuthOptions.keyFile 读取 ~/.config/gcloud/ai-master-key.json。这个 SA(Service Account vertex-express@gemini-project-489918.iam.gserviceaccount.com)是真正企业级的,稳定、可控。GCP 的计费是那种让人晚上睡不着觉的东西。万一哪天代码死循环把算力跑满,信用卡就得崩。所以我写了一套"自动熔断"机制。
重要提醒:Vertex AI、AI Studio 的计算、额度、限制机制太复杂了,我也没特别搞明白。每个平台都有独立的配额和计费方式,需要分别配置防护措施。
架构很简单:设定一个 50 美元的预算,超过 80% 给 Pub/Sub 发信号,超过 100% 直接触发 Cloud Function。这个 Function 会暴力调用 cloudbilling.updateBillingInfo(billingAccountName=""),强行把计费关了。这里面坑非常多:
  • 预算提醒有延迟,不是实时的。
  • IAM 权限必须在 billing account 层级给,项目层级没用。
  • gen2 的 Cloud Function 使用的是 CloudEvents 格式,和以前的 gen1 完全不兼容。
我最终落地的是这套方案:
  • Vertex AI (SA JSON):主战场,极其稳定,支持 customtools 这种高级玩意。
  • AI Studio (API Key):作为备份,高额度且简单。
fallback 链条是这样的:Vertex -> AI Studio 1 -> AI Studio 2 -> 本地 Qwen。所有这些都跑在 Unraid 上的 One API 里面统一调度。
One API deployment
这不叫滥用,这叫资源调度优化。opencode.json 里,我删掉了所有会自动触发内置 Google provider 的环境变量(什么 GOOGLE_APPLICATION_CREDENTIALS 通通杀掉)。我配置了三个 Provider:vertex (SA JSON), google (AI Studio 1), google2 (AI Studio 2)。Vertex 的白名单终于能用了,列表干干净净,只剩下那四个我要用的模型。把底层合规了以后,再看 Gemini CLI v0.33,感觉就不一样了。它现在的表现极其惊艳。和 OpenCode 共享同一套 ~/.config/opencode/opencode.json,技能目录和语义内存也都打通了。特别是当我换上 M3 Max 128GB 的机器,跑 Gemini 3.1 预览版,那种首字延迟和多任务并行的速度,Claude Code 在这方面已经有点不够看了。
Gemini CLI v0.33
从整天想着怎么白嫖,到现在的基础设施建设,这一波"龙虾风"逼着大家成长了。说实话,现在的这套"正规姿势",玩起来比当年那些躲躲闪闪的 hacks 要爽得多。毕竟,工具终归是工具,折腾基础设施的这段经历,才是属于工程师的真正护城河。
Share this post:
Enjoy this post? Subscribe via RSS: English | 中文