Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

The claude CLI's base loses a trailing /v1 for a direct key, as it always did for a router (#88)

github-actions[bot]9d3812cc694f
diff --git a/runner/server.py b/runner/server.py
index 119ac683..241fdb3a 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -1156,7 +1156,11 @@ def _build_claude(provider: str, auth: Auth, model: str, prompt: str, max_turns:
if auth.api_key:
env["ANTHROPIC_API_KEY"] = auth.api_key
if auth.base_url:
- env["ANTHROPIC_BASE_URL"] = auth.base_url
+ # The CLI appends /v1/messages itself, so a base that carries the "/v1" the broker and
+ # the catalog use (https://api.anthropic.com/v1) doubled it and the CLI answered "you
+ # may not have access to it" (2026-09-06, measured on the self-hosted instance). The
+ # router branch below has always stripped it; a direct key gets the same rule.
+ env["ANTHROPIC_BASE_URL"] = auth.base_url.rstrip("/").removesuffix("/v1")
elif p == "bedrock":
env["CLAUDE_CODE_USE_BEDROCK"] = "1"
if auth.aws_region:
diff --git a/runner/tests/test_claude_base_url.py b/runner/tests/test_claude_base_url.py
new file mode 100644
index 00000000..54d29b06
--- /dev/null
+++ b/runner/tests/test_claude_base_url.py
@@ -0,0 +1,26 @@
+"""The claude CLI appends /v1/messages itself: any base handed to it loses a trailing /v1."""
+import pathlib
+import sys
+
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
+import server # noqa: E402
+
+
+def _base(tmp_path, url):
+ env = {"HOME": str(tmp_path)}
+ server._build_claude("anthropic", server.Auth(provider="anthropic", api_key="k", base_url=url), "claude-haiku-4.5", "hi", 1, str(tmp_path), env)
+ return env["ANTHROPIC_BASE_URL"]
+
+
+def test_a_direct_anthropic_base_with_v1_is_stripped(tmp_path):
+ assert _base(tmp_path, "https://api.anthropic.com/v1") == "https://api.anthropic.com"
+
+
+def test_a_bare_direct_anthropic_base_is_kept(tmp_path):
+ assert _base(tmp_path, "https://api.anthropic.com") == "https://api.anthropic.com"
+
+
+def test_a_router_base_is_stripped_as_before(tmp_path):
+ env = {"HOME": str(tmp_path)}
+ server._build_claude("tokenrouter", server.Auth(provider="tokenrouter", api_key="k", base_url="https://api.tokenrouter.com/v1"), "claude-haiku-4.5", "hi", 1, str(tmp_path), env)
+ assert env["ANTHROPIC_BASE_URL"] == "https://api.tokenrouter.com"