Repository navigation
fix(sse): use x-api-key for opencode-go minimax messages requests - #733
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the OpencodeExecutor to use the x-api-key header instead of Authorization when the request format is set to "claude", while also ensuring the anthropic-version header is included. The unit tests have been updated to reflect these changes. A review comment suggests restructuring the header assignment logic to improve readability and better separate authentication concerns from format-specific settings.
| if (this._requestFormat === "claude") { | ||
| if (key) { | ||
| headers["x-api-key"] = key; | ||
| } | ||
| headers["anthropic-version"] = "2023-06-01"; | ||
| } else if (key) { | ||
| headers["Authorization"] = `Bearer ${key}`; | ||
| } |
There was a problem hiding this comment.
While this logic is correct, it could be slightly restructured for better readability and separation of concerns. You could handle setting authentication headers based on the key's presence first, and then handle other format-specific headers. This avoids nesting the key check within the format check and makes the logic for setting auth headers more self-contained.
if (key) {
if (this._requestFormat === "claude") {
headers["x-api-key"] = key;
} else {
headers["Authorization"] = `Bearer ${key}`;
}
}
if (this._requestFormat === "claude") {
headers["anthropic-version"] = "2023-06-01";
}OpenCode Go mixes request protocols by model family: - `glm-5` and `kimi-k2.5` use OpenAI-style `/chat/completions` - `minimax-m2.5` and `minimax-m2.7` use Anthropic-style `/messages` OmniRoute already routed MiniMax Go models to `/messages`, but the executor still sent `Authorization: Bearer ...`, which caused upstream `401 Missing API key` errors. This changes `OpencodeExecutor` to send: - `x-api-key` + `anthropic-version` for Claude-targeted OpenCode Go requests - `Authorization: Bearer ...` for the remaining OpenCode Go request formats Also updates unit coverage to assert the correct header behavior for MiniMax Go models. Validated with: - direct curl repro against OpenCode Go endpoints - `node --import tsx/esm --test tests/unit/opencode-executor.test.mjs` - `npm run typecheck:core` - `npm run build`
2b4f82f to
d411992
Compare
Code Review SummaryStatus: No New Issues Found | Recommendation: Merge Overview
AnalysisThe PR correctly implements the auth header fix for OpenCode Go MiniMax models:
Existing CommentThere is one existing inline comment suggesting a code style reorganization (medium priority). This is a valid stylistic suggestion but does not affect functionality - the current implementation is correct. Files Reviewed (2 files)
|
|
Thanks @ottodevs for this great contribution! 🎉 The fix is now merged and will be part of the next release. We appreciate your effort! |
…egosouzapw#733) OpenCode Go mixes request protocols by model family: - `glm-5` and `kimi-k2.5` use OpenAI-style `/chat/completions` - `minimax-m2.5` and `minimax-m2.7` use Anthropic-style `/messages` OmniRoute already routed MiniMax Go models to `/messages`, but the executor still sent `Authorization: Bearer ...`, which caused upstream `401 Missing API key` errors. This changes `OpencodeExecutor` to send: - `x-api-key` + `anthropic-version` for Claude-targeted OpenCode Go requests - `Authorization: Bearer ...` for the remaining OpenCode Go request formats Also updates unit coverage to assert the correct header behavior for MiniMax Go models. Validated with: - direct curl repro against OpenCode Go endpoints - `node --import tsx/esm --test tests/unit/opencode-executor.test.mjs` - `npm run typecheck:core` - `npm run build`
…egosouzapw#733) OpenCode Go mixes request protocols by model family: - `glm-5` and `kimi-k2.5` use OpenAI-style `/chat/completions` - `minimax-m2.5` and `minimax-m2.7` use Anthropic-style `/messages` OmniRoute already routed MiniMax Go models to `/messages`, but the executor still sent `Authorization: Bearer ...`, which caused upstream `401 Missing API key` errors. This changes `OpencodeExecutor` to send: - `x-api-key` + `anthropic-version` for Claude-targeted OpenCode Go requests - `Authorization: Bearer ...` for the remaining OpenCode Go request formats Also updates unit coverage to assert the correct header behavior for MiniMax Go models. Validated with: - direct curl repro against OpenCode Go endpoints - `node --import tsx/esm --test tests/unit/opencode-executor.test.mjs` - `npm run typecheck:core` - `npm run build`
Summary
Fix OpenCode Go MiniMax auth for Anthropic-style
/messagesrequests.Root cause
OpenCode Go mixes protocol families by model:
glm-5andkimi-k2.5use OpenAI-style/chat/completionsminimax-m2.5andminimax-m2.7use Anthropic-style/messagesOmniRoute already routed the MiniMax Go models to
/messages, butOpencodeExecutorstill sentAuthorization: Bearer ..., which caused upstream401 Missing API keyerrors.For OpenCode Go MiniMax
/messages, upstream expects:x-api-key: <key>anthropic-version: 2023-06-01Changes
open-sse/executors/opencode.tsx-api-keyfor Claude-targeted OpenCode Go requestsAuthorization: Bearer ...for the remaining OpenCode Go request formatstests/unit/opencode-executor.test.mjsValidation
Validated with:
curlrepro against OpenCode Go endpointsnode --import tsx/esm --test tests/unit/opencode-executor.test.mjsnpm run typecheck:corenpm run buildNotes
This fix is intentionally narrow:
glm-5andkimi-k2.5