opencode: Add support for OpenCode Go#53651
Open
Vlaaaaaaad wants to merge 3 commits intozed-industries:mainfrom
Open
opencode: Add support for OpenCode Go#53651Vlaaaaaaad wants to merge 3 commits intozed-industries:mainfrom
Vlaaaaaaad wants to merge 3 commits intozed-industries:mainfrom
Conversation
… 7 models) Updated models with data from models.dev (OpenCode source data). New model: GLM 5.1 Deprecated models: Trinity Large Preview Free, and all MiMo V2 Free models Updated max token count: Claude Sonnet 4 and 4.5, GLM 5, MiniMax M2.5, Nemotron 3 Updated max output tokens: Claude OPus 4.6, GLM 5, MiniMax M2.5, Nemotron 3 Updated image support: Kimi K2.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: add support for OpenCode Go (flat-rate monthly subscription) along the already-implemented OpenCode Zed (pay-as-you-go billing).
Warning
This code was written by LLMs, under the supervision of a so-called developer that never wrote Rust profesionally and that spends more time in Pages&Keynote than in an IDE.
Self-Review Checklist:
Background
OpenCode offers a few different ways to access models:
/goappended to the path. There are 5-hour, weekly, and monthly usage limits and, additionally, users can toggle a switch in the OpenCode Console to use Zen models with their pay-as-you-go billing after the Go limits are hit.There's also a currently-paused OpenCode Black flat-rate subscription with way higher usage limits and with access to more models, with $100 and $200 monthly plans.
The whole thing is a bit messy, but it's great value and highly reliable LLM access!
#49589 added support for OpenCode Zen by implementing a new
opencodeprovider. OpenCode Go could be used by overriding the API URL, but that is a terrible user experience: some models have to be manually added, the model list always shows the 30-something OpenCode Zen models, and free models cannot be used at all.I was annoyed by the experience of using OpenCode Go with Zed and this past week I had to test a bunch of LLMs and providers and harnesses, so I took this on as a test case 🙂
Implementation
This PR makes the OpenCode provider more general (not just for Zen) and adds an
OpenCodeModelSubscriptionconcept which is then used to implement support for OpenCode Go. The free models are also broken out into their own subscription for a prettier model list.For a better user experience, the different subscriptions can be enabled or disabled, both in the settings file and in the UX:

The code was written by LLMs, but I do understand it and I did a bunch of "manual" iterations and "manual" tweaks. Still, my Rust experience is non-existent so I won't feel offended if y'all reject this PR! I did consider alternatives (adding a new
opencode-goprovider and renaming this toopencode-zen, for example, or adding support for custom API URLs in OpenCode custom models which would've been the smallest code change but a terrible user experience, and so on) but all alternatives would have been, in my opinion, a worse user experience.Tests I did:
Notes:
claude-haiku-4-5is nowzen/claude-haiku-4-5. Since this is a relatively new provider and the impact is small, I preffered that rather than adding complex migration/mapping logic."opencode/<model-id>"to"opencode/<subscription>/<model-id>"break anything for y'all at Zed?Release Notes: