Skip to content

API Key Expired #56560

Closed as not planned
Closed as not planned

Description

@VacantFuture

Description

I was eye ball deep in working a feature, stopped to run an errand and returned to this error.
litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":{"type":"authentication_error","code":"api_key_expired","message":"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."}}'. Received Model Group=qwen3.5-plus
Available Model Group Fallbacks=None

I have not needed a key before when using remote models on opencode via ZEN. However I followed the instructions and I created an api key. But there is no documentation on how to use the api key with opencode as a vs code plugin or via the cli. Only documentation about setting as auth bearer token in a curl command??

Opencode version 1.19.3 in VS code on Pop_os.

Plugins

No response

OpenCode version

1.19.3

Steps to reproduce

Go pick up your kid from a playdate and then come back to opencode and try to finish your work.

Screenshot and/or share link

No response

Operating System

Pop_os

Terminal

No response

Activity

  1. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    Contributor

    Thanks for the report, and sorry you came back to a dead session in the middle of your work.

    The error is coming from the OpenCode Console/Zen side: your API key there was marked as expired, and the message says signing in again won't renew it. To get going again:

    1. Create a new API key in the OpenCode Console.
    2. Run opencode auth login, choose OpenCode Zen and paste the new key. The VS Code extension uses the same stored credentials as the CLI, so it should pick up the new key, possibly after you reload VS Code.

    Account and key support (for example, why the key expired) isn't handled in GitHub issues. Please email help@anoma.ly with the details: roughly when it stopped working and the exact error. If you've already emailed, the team will get to it, especially now that we've seen it here. Please keep your API keys, email address and account details out of this public issue and put them only in the email.

    Closely related issues:

    The bot will close this issue in 1 day.

  2. VacantFuture commented on Oct 17, 2026

    @VacantFuture
    Author

    Nope. does not work, tried it twice still gettting ->litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":{"type":"authentication_error","code":"api_key_expired","message":"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."}}'. Received Model Group=qwen3.5-plus
    Available Model Group Fallbacks=None

  3. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    Contributor

    Sorry that didn't fix it. If a brand-new key still gets api_key_expired, either the old key is still being sent from somewhere, or the problem is on the Console side. A few things to check:

    1. Run opencode auth logout, choose OpenCode Zen, then opencode auth login again with the new key. Run opencode auth list afterwards to check what's stored.
    2. Make sure the old key isn't also set somewhere else that takes priority, for example an OPENCODE_API_KEY environment variable (in your shell profile or a .env file), or an apiKey under provider.opencode.options in your opencode.json (global ~/.config/opencode/opencode.json or the project one).
    3. Fully restart VS Code, or at least its integrated terminal, so no running opencode process keeps the old credentials.

    If it still fails after that, the new key itself is being rejected, and only the team can look into that from your account. #56556 reports the same thing: a newly created key still got this error. Please email help@anoma.ly, say that a newly created key also returns api_key_expired, and roughly when you created it. Keep the keys and your account details out of this issue.

  4. omani commented on Oct 17, 2026

    @omani

    opencode was hacked. they probably revoked all API keys just for safe measure. and @opencode-agent does not know anything about it. they even made it to the HN frontpage, congrats: https://news.ycombinator.com/item?id=50133401

  5. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    @VacantFuture, I'm closing this issue now because account and API key problems are handled by email, not on GitHub. If a new key still returns api_key_expired, please email help@anoma.ly. Say that a newly created key gets the same error and roughly when you created it, and the team can look into it from your account. Please keep keys and account details out of this public issue. Sorry about the interruption to your work.

  6. sousarobinho-art commented on Oct 20, 2026

    @sousarobinho-art

    Hey everyone! I managed to solve it.
    Go to https://opencode.ai/console/account
    Under "PERSONAL API KEY," click on "+ add api key."
    A new window will open; the only mandatory field is "KEY NAME."
    Enter a name of your choice, then click "CREATE."
    A new API key will be generated—copy it, go to your OpenCode instance, run the /connect command, and press Enter.
    When prompted, paste the new API key, hit Enter, and you're all set!

    Brazilian greetings to you all!

    ver. em português:

    ola! caras, consegui resolver.
    acessem https://opencode.ai/console/account
    em PERSONAL API KEY cliquem em : + add api key
    vai abrir uma nova janela e o unico campo obrigatorio é : KEY NAME
    coloquem o nome que acharem adequado e depois apertei em CREATE
    Vai ser gerado uma nova api key copiem e vai no seu opencode e execute o comando /connect apertem enter
    e quando solicitado colem a nova api key gerada. teclem Enter e sejam felizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions