From a9e1b7ddfcf428d0958c920bf569a2d9ec642ab0 Mon Sep 17 00:00:00 2001 From: Marcos Date: Sat, 22 Aug 2026 13:12:46 +0000 Subject: [PATCH] fix(opencode): patch apiKey from PRAGENT_MODEL_API_KEY at install_config opencode's @ai-sdk/anthropic provider sends the config's apiKey as the x-api-key header. The committed opencode.json carries apiKey="ollama" (placeholder) so the repo can be public. When the headroom upstream switches to an auth-gated provider (e.g. MiniMax), the placeholder returns 'No credentials found'. install_config now also patches options.apiKey from PRAGENT_MODEL_API_KEY when set, mirroring the existing baseURL patching. Co-Authored-By: Claude --- pilot/opencode_review.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pilot/opencode_review.py b/pilot/opencode_review.py index c2524ab..48b9923 100644 --- a/pilot/opencode_review.py +++ b/pilot/opencode_review.py @@ -406,7 +406,8 @@ def install_config(src: str, dst: str) -> bool: if not os.path.isfile(src): return False base_url = os.environ.get("PRAGENT_MODEL_BASE_URL", "").strip() - if not base_url: + api_key = os.environ.get("PRAGENT_MODEL_API_KEY", "").strip() + if not base_url and not api_key: shutil.copy2(src, dst) return True try: @@ -414,7 +415,10 @@ def install_config(src: str, dst: str) -> bool: cfg = json.load(f) for prov in (cfg.get("provider") or {}).values(): if isinstance(prov, dict) and isinstance(prov.get("options"), dict): - prov["options"]["baseURL"] = base_url + if base_url: + prov["options"]["baseURL"] = base_url + if api_key: + prov["options"]["apiKey"] = api_key with open(dst, "w", encoding="utf-8") as f: json.dump(cfg, f, indent=2) except (OSError, ValueError, AttributeError):