Guide

OpenCode Breach: What to Do If Your API Key Leaked, and How to Stop the Next Bill

OpenCode's breach may have exposed saved API keys. See if you're affected, revoke keys at OpenAI, Anthropic and Google, dispute charges, and cap the next bill.

· 15 min read

On Oct 17, 2026, OpenCode said it “had a security breach last night related to a large scale distillation attack that impacted 1.4% of OpenCode Console users” (post). The keys at risk are OpenAI, Anthropic and Google keys that users had saved in Console, and The Hacker News reports they “may have been exposed” (The Hacker News). Some users say they’ve been charged for usage they didn’t run. One post: “people reported $400 and $1,700 in fraud charges” (post). Another summed up the lesson: “an API key is a credit card with no limit” (post).

This guide covers what to do now: check whether you’re affected, revoke the key at each provider, look for usage you didn’t run, and report it. Then it covers how to make sure the next leaked key can’t run up a large bill.

Last verified: Oct 24, 2026. This is a developing story. Facts about the breach may change.

Scope: This guide covers responding to a leaked provider key and limiting what the next one can cost. For finding keys already exposed in repos, configs and agent history, and keeping keys out of the model’s reach, see our AI agent security guide. For setting budgets, per-agent caps and handling budget errors in depth, see our AI agent cost guide.

What happened at OpenCode

What OpenCode and the providers have said

  • What was hit. OpenCode Console is OpenCode’s optional hosted service. A workspace saves its own OpenAI, Anthropic or Google key there, and Console uses that key to call the provider. The intruder reached “a legacy system” on the night of Oct 16 (The Hacker News).
  • Who is affected. OpenCode emailed affected users on the morning of Oct 17. “If you did not get an email you were not impacted, it was a subset of users who had external providers linked” (post).
  • Who isn’t. Keys used only in the local OpenCode app aren’t part of this. OpenCode’s Dax Raad: “this is the OpenCode Console, not OpenCode itself, those keys never come to us” (post).
  • Anthropic said it has “revoked Claude API keys we believe were affected” and suggested creating a new key if you saved one in OpenCode (post, Lydia Hallie, Claude Code team).
  • Google said “We’ve blocked exposed API keys” and told users to “create a new key in AI Studio, delete the old one, and review your usage” (post, Evan Otero, Google DeepMind). He later clarified that this was OpenCode Console (post).
  • OpenAI said it worked with OpenCode to get affected OpenAI API customers “back in business and any credits refunded which would have been drawn in the attack” (post, Tibo, OpenAI). OpenAI hasn’t said publicly whether the exposed keys were revoked. An affected user posted a later OpenCode email on Hacker News saying OpenCode “worked with OpenAI to revoke all of them” (Hacker News). Either way, create a new key.

What’s reported but not confirmed

The charges are users’ own reports. OpenCode says the keys “may have been exposed,” and it “has not said that any key was copied or used” (The Hacker News). As one post put it, OpenCode “hasn’t confirmed any were used” (post). OpenCode hasn’t said how the system was reached, how many keys it held, or how many people 1.4% represents (The Hacker News).

Why deleting the key in the tool doesn’t help

A provider key is a bearer credential. Anyone holding a copy can make billable requests until the provider revokes it. As The Hacker News puts it, “Deleting the key from Console does not revoke it, and a Console budget cannot cap that use either, because Console only sees requests that pass through its own gateway.” One builder’s version: “Not delete. Revoke, at the provider” (post).

That point applies to any tool you paste a key into, not just OpenCode. Budgets inside the tool only see traffic that goes through the tool.

Part 1: Respond to the leak

Step 1: Check whether you’re affected

  1. Look for the email. OpenCode’s notice went out on the morning of Oct 17 with the subject “Action Required: Potential provider key breach” (The Hacker News). A follow-up email reportedly lists each affected key by workspace, provider and last four characters, and gives the earliest possible exposure as Oct 17, 00:30 UTC (ctxsec, citing a screenshot shared by an affected user).
  2. List every key you ever saved in Console. Note the provider and the last four characters of each. If you’re not sure whether you saved a key there, treat it as exposed.
  3. Watch for fake follow-ups. Breaches attract phishing. OpenAI’s advice holds here: “Be cautious with emails that ask for credentials” (OpenAI Help Center). Never paste a key into a form or an email reply. OpenCode’s Dax Raad shared one attempt it received: a real PlanetScale OAuth sign-in “set to send credentials to an attacker” (post). Don’t approve an OAuth prompt you reached from a link someone sent you.

Provider auto-detection won’t necessarily catch this kind of leak. OpenAI disables keys it finds “on the public internet, or leaked inside an app in an app store” (OpenAI), and Anthropic deactivates Claude keys that GitHub finds in public repositories (Anthropic). A key taken from a vendor’s database isn’t public. Anthropic and Google did act in this case, but don’t count on a notice next time.

Step 2: Revoke the key at the provider

Do this even if usage looks normal. Each provider’s documented steps:

OpenAI

  • OpenAI’s guidance: “If you believe your key has been leaked, rotate your key immediately from the API Keys page” (Best Practices for API Key Safety).
  • For an exposed key: “Delete the affected key through the API key dashboard,” review your API usage “and keep the details,” then contact OpenAI Support (Keeping your OpenAI account secure).
  • If you think someone also got into your account, change your password and log out of all sessions. On Platform, that’s Your Profile > Security > Log out of all devices (same article).

Anthropic

  • Anthropic recommends “revoking the key immediately”: sign in to the Claude Console, go to the API keys page, click the three-dot menu next to the key, and select Delete API key (Claude Help Center). The API keys page is at platform.claude.com/settings/keys (Get your Claude API key).
  • Disable or Delete? In the Console, “Disable is reversible… whereas Delete is permanent” (Claude docs: Authentication). For a key you know was exposed, delete it. Disable is useful if you want to pause a key while you investigate.
  • Create the replacement with Create key on the same page.

Google (Gemini API)

Google’s leak checklist (Using Gemini API keys):

  1. Create a replacement key in Google AI Studio or the Cloud console.
  2. Deploy your code with the new key.
  3. Disable or delete the compromised key in the Cloud console.
  4. Check billing logs and API usage in the Google Cloud console.

In the Cloud console, Google’s rotation flow is: Credentials page, click the key’s name, Rotate key, enter a name and confirm restrictions, Create, update your apps, then Delete the previous key (Respond to compromised Google Cloud credentials).

Google orders these steps to avoid downtime. If you can see a key being abused right now, cutting it off matters more than a short outage.

Other providers

If you saved other provider keys in the same tool, rotate those too, using that provider’s own docs.

Step 3: Update everything that used the old key

Replace the key everywhere it was set: environment variables, CI secrets, .env files, agent and MCP configs, and any other hosted tool. Then confirm requests succeed with the new key.

While you’re at it, check for copies. One builder scanned their Mac after the breach and found “1 API token, 7 copies. Claude Code’s auto-backups cloned it for me” (post). The security guide’s exposure scan covers where to look.

Step 4: Check for usage you didn’t run

Review usage and billing at each provider “going back at least to October 16” (The Hacker News). Look for spikes, models you don’t use, and traffic at hours you weren’t working.

  • OpenAI: usage is on the Usage page. OpenAI says to “Review your usage to see if it aligns with your team’s work” (OpenAI). If you use separate keys per project, you can track usage by key.
  • Anthropic: check the Console’s Logs page (platform.claude.com/logs) and Usage page (platform.claude.com/usage), which Anthropic recommends reviewing regularly (Anthropic). If you use workspaces, usage and cost can be tracked per workspace (Claude docs: Workspaces).
  • Google: in AI Studio, go to Dashboard > Usage. For costs, open your Cloud Billing account’s Reports page, group by SKU and filter Services to Gemini API (Gemini API billing).

Billing data lags. Google says cost details are “typically” available within a day “but can sometimes take more than 24 hours” (Resolve Cloud Billing issues). OpenAI says usage processed after credits run out can show up as a negative balance (OpenAI prepaid billing). Check again a day or two later.

Save what you find: dates, amounts, models, request IDs, and each key’s last four characters. You’ll need it in the next step.

Step 5: Report the fraud and ask for a refund

Never send the key itself. Anthropic says not to include your API key in “support tickets, even between you and Anthropic” (Anthropic).

OpenAI

  • Report it through the Fraudulent Activity webform and choose “Report unauthorized activity involving my account” (OpenAI).
  • For refunds, contact Support. “Unauthorized charges must be validated before a refund is issued,” and the security steps must be done first (OpenAI). Prepaid credits already used “may qualify only for confirmed unauthorized use” (OpenAI prepaid billing).
  • Bank dispute or OpenAI refund, not both at once. OpenAI says it “cannot issue a separate refund while a dispute is active or after funds have already been returned through that dispute.” It also recommends contacting your bank right away if a charge is unauthorized. If you open a dispute, tell Support its status.
  • For the OpenCode breach, OpenAI says it is refunding credits drawn in the attack (post). Check your billing page for a credit before you file.

Anthropic

Anthropic’s documented step is to contact its Support team “If you continue to see any suspicious API activity or have other concerns” (Claude Help Center). We didn’t find a published refund policy for leaked-key usage, so include your usage evidence and ask. For the OpenCode breach specifically, Dax Raad said on Oct 20 that Anthropic is “working through” restoring drained credits that week, and that OpenCode would “send from our side” if Anthropic didn’t finish (post). Anthropic hasn’t commented publicly on refunds.

Google

  • Google’s Evan Otero told affected users: “If you see charges you didn’t make, contact Google Cloud Billing support from your account” (post).
  • Google’s billing docs say to secure the account, stop resources you don’t recognize, and contact Cloud Billing Customer Care “to report the compromise and discuss potential billing adjustments.” Google “reviews such cases on an individual basis,” and usage up to the point the resources were actually stopped is still billed (Resolve Cloud Billing issues).
  • Outside India’s UPI AutoPay, Google’s docs say to contact your bank to dispute an unauthorized charge, which the bank treats as a chargeback. Google reviews it and sends its decision to your bank (same page).
  • Prepaid Gemini API credits are non-refundable, except after switching to a Postpay account (Gemini API billing).

OpenCode

OpenCode’s Dax Raad has replied to users who reported charges, asking them to email him “and we’ll get you refunded” (post). If you were charged and didn’t hear from OpenCode, reply to their breach email or reach out through OpenCode’s official channels.

Part 2: Stop the next leak from becoming a bill

The lesson from this breach is that limits inside a tool don’t protect a key once it’s been copied out of that tool. Put the limits where the copied key still hits them: at the provider, on a key that does one job.

Step 6: Put a hard cap at the provider

An alert tells you about a problem. A hard cap stops the spending. Set the cap at the provider, because that’s the one place a copied key can’t avoid.

  • OpenAI: go to Project settings > Limits, then under Spend select Edit spend limit, enter a monthly limit, and turn on Enforce a hard limit. Without that toggle, a limit is only an alert: “Sends a notification; API traffic continues.” Enforcement isn’t instant, so “recorded spend can slightly exceed the configured amount” (OpenAI spend limits). OpenAI’s key-safety guide recommends hard enforcement specifically “to help limit unexpected costs from a leaked key.”
  • Anthropic: on the Workspaces page (platform.claude.com/settings/workspaces), select a workspace and click Spend limits to cap monthly spend and set alerts. You can’t set limits on the Default Workspace, so put each tool in its own workspace (Claude docs: Workspaces). If your account auto-reloads credits, Anthropic says to “Carefully consider auto-reload limits,” because they also guard against “unexpected high usage that could result from leaked keys” (Anthropic).
  • Google: in AI Studio, open the Spend page and go to Monthly spend cap > Edit spend cap to cap a project. Google calls this experimental and warns of overages during “around a 10 minute latency period,” including from “agent sessions” (Gemini API billing). On Prepay, all keys stop when the balance hits $0. If you use auto-reload, set a Monthly auto-charge limit under Manage auto-reload.

A small prepaid balance isn’t a hard cap. OpenAI says “Do not rely on the prepaid balance as an instantaneous spending cutoff,” and that a recharge limit “is not an API usage limit” (OpenAI prepaid billing). Use it alongside a hard limit, not instead of one.

For how caps behave, why a budget error shouldn’t be retried, and how to leave headroom, see the cost guide’s hard cap step and budget error step.

Step 7: Give every tool, agent and project its own key

One builder put the fix in three lines: “One key per tool. Spend cap at the provider. Revoke, don’t delete” (post). Separate keys mean that when one leaks, you revoke it without breaking everything else, and you can see exactly what it spent.

  • OpenAI: use “separate API keys for each feature, team, product, or project” (OpenAI). Project keys can have an expiration date (OpenAI). A project hard limit then caps each project.
  • Anthropic: keys can be scoped to a single workspace, and you choose an expiration when you create one: 3 hours, 1 day, 7 days, 30 days, a custom duration, or Never (Claude docs: Authentication). Anthropic also recommends separate keys for different purposes so you can “quickly disable just that use case.”
  • Google: every key belongs to a project, and keys “inherit the tier limits and billing status of the project” (Gemini API billing). One project per tool gives each tool its own spend cap. Restrict each key to the Gemini API (Using Gemini API keys).

If you run many agents, start from a list of every agent and the key it uses. Our multi-agent guide covers building that list, and the cost guide covers measuring spend per agent.

Step 8: Put a gateway in front, but keep the provider cap

A gateway gives each agent its own virtual key with its own budget. As one builder put it, “A small proxy with a virtual key per agent shows you exactly that” (post). LiteLLM, Helicone and OpenRouter all support per-key or per-agent budgets. The cost guide has the setup.

A gateway also becomes the place your real provider keys live. That’s what OpenCode Console was: a hosted layer that held provider keys and called the providers for you. A gateway budget doesn’t apply to a key copied out of the gateway. So:

  • Self-host the gateway if you can, or pick one you trust with your keys.
  • Give the gateway its own provider key, used nowhere else.
  • Keep the provider-side hard cap from Step 6 on that key.

Step 9: Keep keys off hosted consoles and out of local backups

Hosted tools. Anthropic warns that when you upload a key to a third-party tool, “you are giving the developer of that tool access to your Claude Console account. If you don’t trust their reputation, don’t trust them with your API key” (Anthropic). OpenAI says to “Use caution with third-party libraries, frameworks, and tools that request access to your API key” (OpenAI). If a hosted tool really needs a key, give it a dedicated key with an expiry, its own project or workspace, and a hard cap.

Local isn’t automatically safe. After the breach, one builder wrote: “I moved all my keys to local only” (post). That keeps them out of a vendor’s database, but local copies multiply. OpenCode’s own apps store local keys in a SQLite database on your machine (The Hacker News), and coding agents can keep keys in session history and backups. The security guide covers keeping keys out of the model’s reach and keeping secrets out of logs.

Short-lived credentials where you can. OpenAI supports workload identity federation “instead of storing a long-lived OpenAI API key” (OpenAI). Anthropic offers Workload Identity Federation for production workloads, with “no sk-ant-api... string to mint, distribute, or rotate” (Claude docs: Authentication). Google’s new AI Studio keys are authorization keys bound to a service account, with “fast-acting leaked key enforcement” (Using Gemini API keys).

If an agent can also spend money outside the model API, such as on purchases or cloud resources, use the card limits in the guardrails guide.

Checklist

CheckDone when
Affected?You’ve checked for OpenCode’s email and listed every key you ever saved in a hosted tool
RevokedEach exposed key is deleted at the provider, not just in the tool
ReplacedNew keys are deployed everywhere, and old copies are found and removed
Usage reviewedUsage and billing checked from Oct 16 on, and again a day later for delayed data
ReportedFraud reported to each provider with evidence (never the key); bank dispute decided
Provider capsOpenAI hard limit on, Anthropic workspace spend limit set, Google project spend cap set
One key per jobEach tool, agent and project has its own key, with an expiry where supported
GatewayPer-agent virtual-key budgets, plus a provider cap on the gateway’s own key
Hosted toolsOnly dedicated, capped, expiring keys go into hosted consoles
Local copiesAgent history and backups scanned; short-lived credentials used where available

FAQ

Was I affected by the OpenCode breach? OpenCode says it emailed every affected user on the morning of Oct 17 and that anyone who didn’t get an email wasn’t affected. Only OpenCode Console users who had linked an outside provider key were in scope. Keys used only in the local OpenCode app weren’t part of it. If you’re unsure whether you saved a key in Console, rotate it.

Is deleting my key from OpenCode Console enough? No. A provider key works for anyone who holds a copy until the provider revokes it. Delete the key at OpenAI, Anthropic or Google, create a new one, and update your apps.

How do I revoke a leaked Anthropic API key? In the Claude Console, open the API keys page, click the three-dot menu next to the key, and select Delete API key. Delete is permanent. Disable is reversible and is meant for keys you may want back. Then create a new key and check your usage.

Will I get a refund for charges from a leaked API key? It depends on the provider and isn’t guaranteed. OpenAI reviews unauthorized charges and says it is refunding credits drawn in the OpenCode attack. Google reviews compromise cases individually through Cloud Billing support. For Anthropic, contact Support with your usage evidence. Collect dates, amounts and key identifiers before you file, and never send the key itself.

Does a spend limit stop a stolen API key? Only if it’s set at the provider and enforced. A budget inside a tool or gateway only sees traffic that goes through that tool. Turn on OpenAI’s hard limit, set an Anthropic workspace spend limit, or set a Google project spend cap. Expect a small overshoot, because enforcement isn’t instant.


Get the next guide in your inbox

We’re tracking leaked keys, surprise bills, and the tools that claim to prevent them, for people building AI agents and Grok Bot setups. Subscribe to the newsletter for practical guides and directory picks.