Skip to content

Make opencode prefer claude subscription over tokens #4291

Closed

Description

@igordertigor

Question

I have a claude pro subscription and an api key. I would like to have opencode use the subscription until it hits the usage limit and then switch to token usage. I thought that was the default, but that seems to not be the case. What am I missing? Unfortunately, the auth documentation seems to only cover the login flow. What am I missing?

Activity

  1. github-actions commented on Nov 13, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. conradkoh commented on Nov 13, 2025

    @conradkoh

    @igordertigor did you try using the /models command and choose the model anthropic/claude-sonnet-4.5? you can also try seeing whether the provider was added by using the opencode models command I think!

  3. igordertigor commented on Nov 13, 2025

    @igordertigor
    ContributorAuthor

    Thank you @conradkoh , the issue is that I have both, a claude pro subscription and an API key. So both are anthropic models. It seems that it prefers the API key over the subscription while the subscription and I would like to prefer the subscription and use the tokens as a fallback.

  4. rekram1-node commented on Nov 13, 2025

    @rekram1-node
    Contributor

    Hmm we dont do that fallback behavior for auth but we prolly should allow for that

    I think the ai sdk for anthropic prioritizes the env vars over the creds passed to it

  5. grenaad commented on Nov 14, 2025

    @grenaad

    @conradkoh I managed to work around this problem by using the OpenCode Zen provider. They have Bring Your Own Key, so I used my API key with them and then use my subscription with the Anthropic provider. You can just switch between them with /models.

    Right now I have two subscriptions: One for work and one for my own private use.
    I saw the docs on Zen that Subscription plans and a free tier are coming soon., then I can use this method again.

  6. rekram1-node commented on Nov 15, 2025

    @rekram1-node
    Contributor

    Oh that's not a bad solution, I should've suggested that

  7. igordertigor commented on Nov 20, 2025

    @igordertigor
    ContributorAuthor

    @grenaad , that's a decent workaround but only if you are free to pick the source of tokens. Once you have a bunch of anthropic tokens, going with a different provider isn't really a good option.

    I would also argue that it's still a workaround: Once my subscription reaches a limit, I need to manually switch the model rather than automatically falling back to pay as you go.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions