Repository navigation
Conversation
2 tasks done
OpenCode Zen (pay-as-you-go) and OpenCode Go (subscription) are OpenAI-compatible gateways authenticated with an OpenCode Console API key. Operators could only reach them through the generic provider with hand-filled base URLs and no protocol hint. Add two KnowledgeQA-only presets, opencode_zen and opencode_go: - default base URLs https://opencode.ai/inference/openai/v1 and https://opencode.ai/inference/go/openai/v1, Bearer auth, key required; - catalogs built from the endpoint tables on opencode.ai/docs/zen and opencode.ai/docs/go: only models served under the OpenAI-compatible base, without Zen's free tier and deprecated ids. Metadata comes from models.dev (now mapped in sources.json); - GPT, Grok and Muse models are documented on /responses, so their overrides set api=openai-responses; everything else stays on Chat Completions, which is also the default for ids not in the catalog; - Chat Completions sends the output cap as max_tokens, the field the documented @ai-sdk/openai-compatible package sends and what these models already got through the generic provider; - both live on opencode.ai, so URL detection keys Go on its "/inference/go/" segment and leaves every other opencode.ai address to Zen. The trailing slash keeps Zen's /inference/google/ route from matching Go. Closes Tencent#4703
Ajax-1
force-pushed
the
feat/opencode-providers
branch
from
October 29, 2026 16:26
b953c8e to
8a2937c
Compare
This branch has not been deployed
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.
Description
Adds two built-in model provider presets, OpenCode Zen (
opencode_zen, pay-as-you-go) and OpenCode Go (opencode_go, subscription), as proposed in #4703. Until now, operators had to pick the generic provider and hand-fill the base URLs.Presets (
internal/models/providers/opencode.go)ModelTypes: KnowledgeQA only. Neither gateway documents an embedding, rerank, VLM or ASR endpoint.Authorization: Bearer <OpenCode Console API key>, required.https://opencode.ai/inference/openai/v1(Zen) andhttps://opencode.ai/inference/go/openai/v1(Go).opencode.svgicon.Protocol per model
OpenCode documents every model on exactly one route (Zen endpoints, Go endpoints). GPT, Grok and Muse models are served on
/responses, so their entries inoverrides.jsonset"api": "openai-responses". All other models stay on Chat Completions, which is also the fallback for ids not in the catalog. No new protocol code is needed.Catalog (
seed.json→models.generated.json)opencode/opencode-go), which are now mapped inscripts/model-catalog/sources.json.*-freeids), because the docs say "Free-tier chat models require OpenCode; use paid models or Go from other clients";beam-free.URL detection
Both presets live on
opencode.ai. Zen matchesopencode.ai. Go matches the longeropencode.ai/inference/go/, so the longest-pattern rule picks Go for its own path and Zen for everything else. The trailing slash matters: without it, Zen's/inference/google/v1betaroute would be detected as Go. A test pins this case.Design notes
/chat/completionsmodel with@ai-sdk/openai-compatible, which sendsmax_tokens. Both presets therefore setmax_tokens. This matches what these models already receive through the generic provider and what thedeepseek/nvidiapresets send, so switching a row from generic to a preset does not change the wire field./responsesmodels are unaffected (max_output_tokens).thinking_levelslike the ones OpenRouter/NVIDIA carry could follow once the gateway behaviour is confirmed.opencode_zen/opencode_go) to matchazure_openaiandhuggingface_tei. Happy to switch to the hyphenated ids suggested in the issue if you prefer.Docs: the built-in vendor table and count in
website-docs/03-features/06-models.md(30 → 32) now include both presets, with a short "OpenCode Zen / OpenCode Go" section. The count in06-development/03-extension-points.mdis updated too.Type of Change
Related Issue
Closes #4703
Testing
New tests:
internal/models/providers/opencode_test.gocovers:/chat/completionsand/responsesURLs, and Zen's/inference/google/route;gpt-/grok-/muse-on Responses, the rest on Chat Completions withmax_tokens. It also checks the exact row counts (Zen 39, Go 22) and that there are no free-tier, deprecated, Anthropic-only or Google-only ids. Removing a single Responses override (e.g.muse-wonder-1.0) or themax_tokenssetting makes it fail.internal/models/parity/opencode_test.gomakes real HTTP calls againsthttptestand asserts:…/openai/v1/chat/completionsand…/openai/v1/responses, plus the same under/inference/go/);Authorization: Bearerheader;max_tokenson Chat Completions andmax_output_tokenson Responses, with no other cap field sent;TestLegacyProviderDetectiongains the two default base URLs.expectedIDsand the vendor count inproviders_test.go, plusparity/testdata/catalog-baseline.json, which only gains entries for the 61 new models and leaves existing entries unchanged. The existingTestEveryChatModelRequestShapeandTestEveryCatalogEntryResolvescover all 61 new entries.Commands (Go 1.26.2, golangci-lint v2.12.2, as in CI):
I also ran the full
go test $(go list ./... | grep -v /docreader/)on this branch and on a cleanmaincheckout (22a331a). The same 9 packages (63 tests) fail on both, all of them environment-related:internal/agent/tools,internal/application/service,internal/application/service/file,internal/datasource,internal/datasource/connector/{notion,yuque},internal/handler,internal/sandboxandinternal/utils. The causes are a missing database, no Docker daemon and a 10-minute timeout inagent/tools. This change adds no new failures.Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)Screenshots / Recordings
No frontend change. The provider dropdown is built from
GET /api/v1/models/providers, so both presets show up there automatically.