Admin19 October 2026

How to lock down your API keys before an AI agent drains your account

After an agent swarm emptied accounts in hours, here's how to check and lock your API keys before it happens to you.

Someone connects an OpenAI, Anthropic or Google API key to a coding tool called OpenCode, the same way you might connect one to Claude Code, Cursor or any other AI tool. Overnight, hackers used keys leaked from OpenCode's Console to run AI agents around the clock, and burned through accounts for thousands of dollars, faster than any human could respond.

In this guide: how to check right now if your API key is exposed, three steps to lock it down, and a prompt that walks you through setting a spending cap on the provider's own dashboard.

Start with the basics

An API key is basically a credit card number for your OpenAI, Anthropic or Google account. Any tool you connect it to, a coding assistant, an automation, an internal app, gets to spend on your account as if it were you. If that third party tool gets breached and the key leaks, whoever holds it keeps spending until you cut it off. At OpenCode, that happened to 1.4% of users, and some woke up to bills in the thousands.

Step 1: list what currently holds your keys

Write a short list: which third party AI tools, coding, automation, CRM, are connected to your OpenAI, Anthropic or Google key right now. Each one stores your key on its own side, the way OpenCode's Console did. The shorter the list, the fewer doors you have to watch.

Step 2: cap spending per key, not just per account

OpenAI, Anthropic and Google Cloud all let you set a spending limit at the project or key level, not just for the whole account. That will not stop a breach, but it puts a ceiling on what anyone can steal if a key leaks. Set it now, not after something happens.

Step 3: if a key leaks, replace it with the provider, not just inside the tool

After the OpenCode breach, a user named Ziwen posted the warning that spread fastest: if you stored a key in OpenCode's Console, rotate it now, and revoke it on the provider's own dashboard, OpenAI, Anthropic or Google, not just inside the third party tool. Replace it only inside the app and the old key stays alive. OpenCode told affected users the same thing directly: revoke and replace the key through the provider's dashboard, update anything that used it, and check for unexpected usage.

Prompt to copyI use an API key from [OpenAI / Anthropic / Google] for [tool name]. Walk me through, step by step, where in their dashboard I set a spending limit on a single key rather than the whole account, and how I check whether that limit is already active.

Before you close the tab

Don't stop at revoking the key. Check each provider's usage log for the last two weeks for any spike in requests or cost you don't recognize, that is the sign a key was already used. Dax Raad, OpenCode's co-founder, posted on X that during the attack his team had to run defensive agents around the clock, because the attackers never stopped. That is a company's scale of response, not an individual's, but the basic check, a spending cap and a clean key, is worth it for anyone who connects a key to an AI tool.

Do this in the next ten minutes: open the dashboard for whichever provider you use, OpenAI, Anthropic or Google, check whether your key has a spending limit, and if it doesn't, set one.