Repository navigation
Conversation
…n header) opencode.ai /v1 (OpenAI and Anthropic paths) requires a stable x-opencode-session header per request and a self-reported User-Agent; without it the endpoint returns 400 MissingSessionID. Native paths also require x-api-key even when the key is not sk-ant- prefixed. - add _oc_session_id() stable per-model session id - BaseSession: inject extra_headers when api_base contains opencode.ai, override default UA with GenericAgent/1.0 - _openai_stream()/ClaudeSession.raw_ask(): merge extra_headers - NativeClaudeSession: send x-api-key for opencode.ai api_base
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.
Summary
Adds first-class support for opencode.ai Zen/Go endpoints to
llmcore.py.opencode's gateway requires every request to carry a stable
x-opencode-sessionheader and a self-reported User-Agent; without them the OpenAI-compatible paths return400 MissingSessionID. Its Anthropic/v1/messagespath also only acceptsx-api-keyauthentication — a non-sk-ant-key currently falls through toAuthorization: Bearerand gets401 Missing API key.Changes
_oc_session_id()+_OC_SIDS— stable per-model session id (reused across requests in-process;configcan override viasession_id/extra_headers).BaseSession.__init__— whenapi_basecontainsopencode.ai, auto-injectextra_headers['x-opencode-session']and replace the default Claude CLI UA withGenericAgent/1.0._openai_stream()— mergeextra_headersso OpenAI / chat_completions / responses paths send the session header.ClaudeSession.raw_ask()— mergeextra_headersfor the Anthropic/v1/messagespath.NativeClaudeSession.raw_ask()— also sendx-api-keywhenapi_basecontainsopencode.ai(covers non-sk-ant-keys).Verification (2026-10-12, local)
kimi-k3,grok-4.7via/v1/responses) — ✅ reachable with this patch; upstream llmcore.py alone fails with400 MissingSessionID.minimax-m3via/v1/messages,api_key_headernon-standard) — ✅ 1.6s first token; upstream alone fails with401 Missing API key.git diff HEAD -- llmcore.py(14 insertions / 1 deletion, 5 hunks), applied on currentmain(6e0c54f).Notes
mykey.pyconfigs need noextra_headers/session_idfields — the patch injects them automatically whenapi_basecontainsopencode.ai.