Skip to content
VibecodeZero

OpenCode "This API key has expired" error and the Console breach: what to do

Updated First published

On this page (4)
  1. Symptom
  2. Cause
  3. Prompt to paste
  4. How not to burn credits

Symptom

You use OpenCode and saw news of the breach, or you got an email from OpenCode about it. Or a Claude, Gemini or OpenAI API key suddenly stopped working, or you see AI charges you didn't make.

Cause

This page is for you if you use OpenCode and saved an AI provider’s key in OpenCode Console, or if you’re not sure. An API key is a password-like code that lets a program use an AI model and bill your account. Anthropic’s help page compares it to a credit card number: if someone else gets it and uses it, the charges land on your account.

The facts below come from posts on X by OpenCode and by staff at OpenCode, Anthropic, Google and OpenAI, plus official docs and help pages, all checked October 20, 2026. The facts about the “This API key has expired” error were checked October 26, 2026. OpenCode still described the incident as ongoing, so check OpenCode’s official channels, like its account on X and its website, for updates.

What happened?

  • OpenCode posted on October 17 that it had a security breach the night before, “related to a large scale distillation attack”, that impacted 1.4% of OpenCode Console users. It says it emailed all of them that morning, that it was “a subset of users who had external providers linked”, and that if you didn’t get an email, you weren’t impacted. It also said the incident is ongoing, so it can’t share more details yet, and that it’s working with Anthropic, OpenAI and Google to fix it.
  • Dax from OpenCode replied that this is the OpenCode Console, not OpenCode itself, and that the keys used with OpenCode itself never come to OpenCode.
  • Anthropic’s Lydia Hallie, from the Claude Code team, posted that Anthropic has been working with OpenCode and revoked the Claude API keys it believes were affected. Her advice: if you saved a key in OpenCode and want to be extra careful, create a new one.
  • Google’s Evan Otero, from the Gemini API team, posted that Google blocked exposed Gemini API keys stored in OpenCode and is working with impacted customers and OpenCode. He later clarified that it was OpenCode Console.
  • OpenAI’s Tibo posted that OpenAI worked with OpenCode to get its users who are also OpenAI API customers back in business, with any credits drawn in the attack refunded.

What isn’t known yet: OpenCode hasn’t said how the attackers got in or when the exposure ended. It called the incident ongoing. This page doesn’t guess.

Am I affected?

OpenCode has two different things with similar names:

  • The OpenCode app, the coding agent you run on your own computer. OpenCode’s providers docs say that when you add a provider’s API key with the /connect command, it’s stored on your computer, in ~/.local/share/opencode/auth.json. Dax from OpenCode says those keys never come to OpenCode. The app can also run local models, which don’t need a provider key at all.
  • OpenCode Console, an online service from OpenCode. Its docs say you sign in, add credits and get an API key, and that Console is completely optional. In a Console workspace, owners and admins can also connect their own providers. OpenCode says the affected users were the ones “who had external providers linked”.

So:

  1. You got an email from OpenCode about the breach. You were affected. Do the steps below now.
  2. You saved an Anthropic, OpenAI or Google key in OpenCode Console. Replace that key, even if you didn’t get an email. That’s the careful option Anthropic suggests.
  3. You only used the app on your computer, with keys added through /connect or with local models, and never saved a key in Console. OpenCode says those keys never reach it, so this breach isn’t about them.
  4. You’re not sure. Replace the key. It’s the careful option.

What to do now

Do this for every provider key you ever saved in OpenCode Console.

Claude (Anthropic). Anthropic’s API key best practices say to revoke a key you think is compromised right away:

  1. Sign in to the Claude Console and open the API keys page.
  2. Click the menu (the three horizontal dots) next to the key and select Delete API key.
  3. Create a new key for the tool that needs it.
  4. Review the Logs and Usage pages for activity you don’t recognize.

OpenAI. OpenAI’s Best Practices for API Key Safety say:

  1. If you believe your key leaked, rotate it immediately from the API Keys page.
  2. Update every app that uses it with the new key.
  3. Check the Usage page to see whether the usage matches your own work.
  4. For further investigation, contact OpenAI through help.openai.com.

Gemini (Google). Google’s Evan Otero says that if you used an API key with OpenCode:

  1. Create a new key in Google AI Studio, on the API Keys page.
  2. Delete the old one.
  3. Review your usage.
  4. If you see charges you didn’t make, contact Google Cloud Billing support from your account.

Then put the new key in every tool that used the old one. For the OpenCode app on your computer, that’s /connect again. For any other app, use its own settings. If the provider already revoked or blocked your old key, tools using it just stop working. That’s expected, not a new problem. They work again once they have the new key. If OpenCode itself is slow or failing and your key isn’t the problem, see OpenCode slow or failing on a free model?.

If OpenCode shows “This API key has expired”. The full message is “This API key has expired. Create a new API key in OpenCode Console and replace it in your client or secret store. Signing in again will not renew this key.” In logs it can appear as api_key_expired. It was reported on OpenCode’s GitHub from October 17, 2026, the same day OpenCode announced the Console breach. OpenCode hasn’t said whether the expired keys are linked to the breach. Its support bot on GitHub says the key stored in your client was marked as expired on the OpenCode Console/Zen side, which is why signing in again doesn’t renew it. The steps it gives:

  1. Sign in at opencode.ai, open OpenCode Console and create a new API key. The Console docs say to go to Account › Personal API keys → Add API key, choose the workspace, a key name and an optional expiration (Never, 1 day, 7 days, 30 days, or Custom from 1 to 365 days), then click Create and copy the key. The full key is shown only once.
  2. Run opencode auth logout and remove the old OpenCode Zen entry. Then run opencode auth login, choose OpenCode Zen and paste the new key. The VS Code extension uses the same saved credentials, so reload VS Code.
  3. Run opencode auth list to check what’s saved.
  4. Make sure the old key isn’t set somewhere that takes priority: an OPENCODE_API_KEY environment variable (in your shell profile or a .env file), an apiKey under provider.opencode.options in opencode.json (the global ~/.config/opencode/opencode.json or the one in your project), or an old entry in ~/.local/share/opencode/auth.json.
  5. Fully restart VS Code or the terminal.
  6. If a brand-new key still gets the same error, email help@anoma.ly with the exact error and roughly when you created the key. Never post a key publicly.

The Console docs say an expired key can’t be renewed, and that revoked and expired keys stop working right away. One user on OpenCode’s GitHub, an OpenCode Go subscriber, reported that signing in again with /connect → OpenCode in the browser brought access back, despite what the message says. That’s a user report, not an official fix. A new key is the reliable fix.

What if I see charges I didn’t make?

  • OpenAI. Tibo says OpenAI refunded credits drawn in the attack for OpenCode users who are OpenAI API customers. If something still looks wrong, contact help.openai.com.
  • Google. Contact Google Cloud Billing support from your account, as Evan Otero says.
  • Anthropic. The Anthropic post we checked doesn’t talk about refunds. Review the Logs and Usage pages so you know exactly what happened.
  • OpenCode. Dax from OpenCode says OpenCode already contacted everyone and refunds are underway. In another post, he asked affected people who were charged to email him with details so they can be reimbursed.

We can’t promise a refund, because each company decides. And never send a full key when you contact anyone.

How to protect yourself next time

  • One key per tool. Anthropic recommends separate keys for different purposes, so that if one leaks, you can disable just that one.
  • Set a hard spend limit. OpenAI says to set monthly spend limits with hard enforcement, because spend alerts alone don’t stop API traffic. It also says spending may go slightly past the limit, since enforcement isn’t instant. For step-by-step instructions for OpenAI, the Claude Console and OpenCode Console, see Set an API spending limit before you paste your key.
  • Be careful with auto-reload. Anthropic says to think carefully about auto-reload limits, because they also protect you from big unexpected usage from a leaked key. In OpenCode Console, auto-recharge runs on a rule you set: the balance that triggers a charge and the amount to add, according to the billing docs. Monthly budgets, set in Budget limits → Monthly workspace budget, plus member budgets, block new requests once they’re reached. The budgets docs say that without any budget, spend is unlimited. Both checked October 21, 2026.
  • Only give your key to tools you trust. Anthropic says that when you put your key into a third-party tool, you give that tool’s developer access to your account. If you don’t trust their reputation, don’t trust them with your key.
  • Keep keys out of your app’s code. OpenAI says never to put a key in code that runs in the browser or in a mobile app, and never to commit it to your repository. Anthropic says to add your .env files to .gitignore, so they’re never shared by accident. To check your app for this and other leaks, see Could my app be exposing personal data?.

For a different security notice, about a fake Claude Code extension in Cursor’s marketplace, see Cursor’s fake Claude Code extension (2.1.313): how to check if you’re affected.

Prompt to paste

Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.

Paste into the AI
I want to check where my AI API keys are stored, after the OpenCode Console breach.

Don't change, move or delete anything. Only look and report back.
1. Find where AI API keys are stored for this project and on this computer: environment variables, .env files, and OpenCode's auth.json file (~/.local/share/opencode/auth.json).
2. List each key by provider and by name, showing only its last 4 characters. Never print a full key.
3. Tell me if any .env file is missing from .gitignore, or if one was ever committed to git.
Explain what you found in plain English, then wait for me before changing anything.

How not to burn credits

  • Replace the key first, before you keep building. A leaked key can keep spending on your account until you delete it.
  • Never paste a full key into a chat, a form, an email or a support ticket. Anthropic says not to share it in support tickets, not even with Anthropic.
  • Set a hard spend limit at the provider before you put the new key back in your tools.
  • If a tool shows an error because your key was revoked, don't ask the AI to retry or "fix" it. Nothing in your code is broken. Create the new key yourself in the provider's dashboard and swap it in.

How Lovable counts credits, and what the free plan includes: Lovable credits explained.

Questions people ask

Why does OpenCode say "This API key has expired"?

OpenCode's support bot on GitHub says the error comes from the OpenCode Console/Zen side: the key stored in your client was marked as expired there. OpenCode Console's docs say an expired key can't be renewed and stops working right away. Create a new key in OpenCode Console (Account › Personal API keys › Add API key), then replace the old one in OpenCode with opencode auth login (choose OpenCode Zen) or /connect. The error was reported from October 17, 2026, the day OpenCode announced the Console breach, but OpenCode hasn't said whether the two are linked.

Will signing in again fix an expired OpenCode key?

The error message says it won't, and OpenCode Console's docs say an expired key can't be renewed, so create a new one. One user on OpenCode's GitHub, an OpenCode Go subscriber, reported that signing in again with /connect → OpenCode in the browser restored access. That's a user report, not an official fix. The reliable fix is a new key.

Was the OpenCode app hacked, or only OpenCode Console?

OpenCode Console. OpenCode says the breach affected 1.4% of OpenCode Console users who had external providers linked. Dax from OpenCode says it was the Console, not OpenCode itself, and that keys used with the app on your computer never come to OpenCode. Google's Evan Otero also clarified that it was OpenCode Console.

I didn't get an email from OpenCode. Am I safe?

OpenCode says it emailed every affected user on October 17 and that if you didn't get an email, you weren't affected. If you ever saved a key in OpenCode and want to be extra careful, Anthropic's Lydia Hallie suggests creating a new one. Dax from OpenCode said he wanted to make sure people didn't miss that email, so look for it before you decide.

My Claude or Gemini API key stopped working. Why?

Anthropic says it revoked Claude API keys it believed were affected, and Google says it blocked exposed Gemini API keys. A revoked or blocked key stops working for good. Create a new key at the provider, delete the old one if it's still listed, and put the new key in every tool that used the old one.

Will I get my money back?

We can't promise that, because each company decides. OpenAI's Tibo says OpenAI refunded credits drawn in the attack for OpenCode users who are OpenAI API customers. Dax from OpenCode says refunds are underway and asked affected people who were charged to contact him. Google says to contact Google Cloud Billing support from your account if you see charges you didn't make.

How do I stop a leaked key from running up a bill?

Delete the key at the provider as soon as you can, because that's what stops it. Then protect the new one. Set a monthly spend limit with hard enforcement, since OpenAI says spend alerts alone don't stop API traffic. Be careful with auto-reload, use a separate key for each tool, and only give your key to tools you trust.

I only pay a monthly plan. Can a leaked API key charge me?

An API key bills the API account it belongs to, not your monthly plan. Anthropic says paid Claude plans and the Claude Console are separate products, and the Claude API is billed separately. So a leaked key can only spend what that API account allows, which is why a hard spend limit matters. Signing in to a tool with your plan, like Claude Code with your Pro account, doesn't use an API key. But if an ANTHROPIC_API_KEY environment variable is set on your computer, Claude Code uses that key instead of your plan, and you pay API usage charges.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe