You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make opencode prefer claude subscription over tokens #4291
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?
@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!
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.
@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.
@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.
Activity
github-actions commentedon Nov 13, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
conradkoh commentedon Nov 13, 2025
@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 theopencode modelscommand I think!igordertigor commentedon Nov 13, 2025
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.
rekram1-node commentedon Nov 13, 2025
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
grenaad commentedon Nov 14, 2025
@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.rekram1-node commentedon Nov 15, 2025
Oh that's not a bad solution, I should've suggested that
igordertigor commentedon Nov 20, 2025
@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.