From b94c0c7d045cd4d2473844c16e33823effa9d91d Mon Sep 17 00:00:00 2001 From: Otto G <5030059+ottodevs@users.noreply.github.com> Date: Sun, 29 Mar 2026 09:29:59 +0200 Subject: [PATCH] fix(sse): use x-api-key for opencode-go minimax messages requests (#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` --- open-sse/executors/opencode.ts | 6 +++++- tests/unit/opencode-executor.test.mjs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/open-sse/executors/opencode.ts b/open-sse/executors/opencode.ts index 51a0472852..99a591d7d0 100644 --- a/open-sse/executors/opencode.ts +++ b/open-sse/executors/opencode.ts @@ -45,7 +45,11 @@ export class OpencodeExecutor extends BaseExecutor { const key = credentials?.apiKey || credentials?.accessToken; if (key) { - headers["Authorization"] = `Bearer ${key}`; + if (this._requestFormat === "claude") { + headers["x-api-key"] = key; + } else { + headers["Authorization"] = `Bearer ${key}`; + } } if (this._requestFormat === "claude") { diff --git a/tests/unit/opencode-executor.test.mjs b/tests/unit/opencode-executor.test.mjs index 11710961f7..8859eb6404 100644 --- a/tests/unit/opencode-executor.test.mjs +++ b/tests/unit/opencode-executor.test.mjs @@ -158,7 +158,7 @@ describe("OpencodeExecutor", () => { ); assert.deepEqual(result.headers, { - Authorization: "Bearer claude-key", + "x-api-key": "claude-key", "Content-Type": "application/json", "anthropic-version": "2023-06-01", Accept: "text/event-stream",