feat: add OpenCode Zen as an API-key provider#1864
Merged
guillaumegay13 merged 7 commits intoJun 1, 2026
Conversation
Routes Claude models through Zen's native /v1/messages (x-api-key auth) and everything else through OpenAI-compatible /v1/chat/completions (Bearer auth). Models are discovered from the public /v1/models endpoint.
…ions Live testing showed OpenCode Zen treats /v1/chat/completions as a single OpenAI-compatible entrypoint that handles Claude, GPT, and the OpenAI-compatible long tail (Qwen, GLM, Kimi, MiniMax, …) — no per-family adapter is required. Drop the speculative opencode-zen-anthropic endpoint and the model-prefix redirect in favor of one Bearer-auth route. Gemini models on Zen still fail with GCP OVERLOADED_CREDENTIALS because the Zen gateway forwards our Authorization header to Vertex AI on top of its own credentials; that is a Zen-side bug with no client workaround and is documented in the endpoint comment.
…dpoint
Live testing confirms Zen's Gemini path requires the upstream-native
combo: `/v1/models/{id}:generateContent` with `x-goog-api-key` auth.
Routing Gemini through the unified /v1/chat/completions hits a Zen
gateway bug that forwards the client's Authorization header to Vertex
AI, triggering GCP OVERLOADED_CREDENTIALS.
All 41 OpenCode Zen models now route end-to-end: Claude, GPT, Qwen,
GLM, Kimi, MiniMax, Big Pickle, etc. via /v1/chat/completions and
Gemini via /v1/models/{id}:generateContent.
Once OpenCode Zen stops tunneling the client Authorization header through to Vertex AI, the dedicated Gemini route can be collapsed back into the unified /v1/chat/completions path.
Bundle ReportChanges will increase total bundle size by 1.19kB (0.1%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: manifest-frontend-esmAssets Changed:
Files in
Files in
Files in
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1864 +/- ##
=======================================
Coverage 99.48% 99.48%
=======================================
Files 189 189
Lines 18121 18132 +11
Branches 7177 7180 +3
=======================================
+ Hits 18028 18039 +11
Misses 91 91
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Codex review caught that `parseOpenAI` returned bare IDs from Zen's catalog (`gemini-3-flash`, `qwen3.6-plus`, `claude-opus-4-7`, …) but `getModelsForAgent` deduplicates by `id + authType`. A user with both OpenCode Zen and a directly-connected Google/Qwen/Anthropic provider would silently lose one provider's model. Mirrors the existing pattern from `parseCopilot` and the OpenCode Go catalog: every Zen-discovered model is now prefixed `opencode-zen/`. The proxy already strips vendor prefixes via `stripVendorPrefix` before forwarding upstream, so the bare model id reaches Zen unchanged.
Collaborator
Author
|
@brunobuddy tested locally, ready to be merged! |
…provider # Conflicts: # packages/backend/src/common/constants/providers.spec.ts # packages/backend/src/routing/proxy/__tests__/provider-endpoints.spec.ts # packages/backend/src/routing/proxy/provider-client.ts # packages/backend/src/routing/proxy/provider-endpoints.ts # packages/frontend/tests/services/providers.test.ts # packages/shared/src/provider-inference.ts
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.
✨ What changed
opencodezen)./v1/modelsendpoint (Bearer auth, OpenAI-compatible JSON)./v1/chat/completionswith Bearer auth./v1/models/{id}:generateContentwithx-goog-api-key(workaround, see below).💭 Why
OpenCode Zen aggregates 41 curated models behind a single key. Manifest needed first-class routing instead of users falling back to "custom provider".
👤 For users
Connect with an OpenCode Zen API key, get all 41 models discovered automatically, route any of them through Manifest's tier system.
📝 Notes — Gemini routing is a workaround
Zen documents a single-key, multi-protocol surface where Claude/GPT/etc. all work through the unified
/v1/chat/completions. Gemini does not. SendingAuthorization: Bearer <zen_key>to/v1/chat/completionswith a Gemini model gets a 401 from Vertex AI itself:OVERLOADED_CREDENTIALS — API key for authentication is used with other authentication credentials. That error proves Zen's gateway is forwarding the client's Authorization header to Vertex AI on top of its own GCP credentials.The workaround we ship: route Gemini to the dedicated
/v1/models/{id}:generateContentpath with Google's nativex-goog-api-keyheader. That keeps the Zen key out of theAuthorizationslot, so it doesn't get forwarded.Both code sites carry a
TODO(opencode-zen)so we can collapse Gemini back onto the unified route once Zen stops tunneling the header through. Tracking this with the OpenCode team — closely related to closed issue #8228.Tested end-to-end against a live Zen account: Claude Haiku 4.5, GPT 5.4 Nano, Qwen 3.6 Plus, GLM 5.1, and Gemini 3 Flash all return 200 + valid output through Manifest's
/v1/chat/completions.Summary by cubic
Adds OpenCode Zen as an API-key provider with automatic model discovery and first-class routing. Most models use the unified
/v1/chat/completions(Bearer); Gemini uses/v1/models/{id}:generateContent(x-goog-api-key) due to an upstream header-forwarding issue.New Features
opencode-zen(aliasopencodezen) in the shared provider registry and UI.https://opencode.ai/zen/v1/modelswith Bearer auth./v1/chat/completions; route Gemini via/v1/models/{id}:generateContentwithx-goog-api-key.Bug Fixes
opencode-zen/<id>to prevent collisions with directly connected providers; the proxy strips the prefix before forwarding.Written for commit ba8ed1c. Summary will update on new commits.