Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

Add Anthropic url overrides via ANTHROPIC_TARGET_URL env var and --anthropic-api-url flag

dorphalsigb38ef584b8fb
diff --git a/headroom/cli/proxy.py b/headroom/cli/proxy.py
index 91c6cc1bb..06355b721 100644
--- a/headroom/cli/proxy.py
+++ b/headroom/cli/proxy.py
@@ -94,6 +94,11 @@ from .main import main
default="openai",
help="Provider for any-llm backend: openai, mistral, groq, ollama, etc. (default: openai)",
)
+ "--anthropic-api-url",
+ default=None,
+ help="Custom Anthropic API URL for passthrough endpoints (env: ANTHROPIC_TARGET_API_URL)",
+)
@click.option(
"--openai-api-url",
default=None,
@@ -149,6 +154,7 @@ def proxy(
no_learn: bool,
backend: str,
anyllm_provider: str,
+ anthropic_api_url: str | None,
openai_api_url: str | None,
gemini_api_url: str | None,
region: str,
@@ -181,6 +187,7 @@ def proxy(
raise SystemExit(1) from None
# Resolve API URL overrides: CLI flag > env var > None
+ effective_anthropic_api_url = anthropic_api_url or os.environ.get("ANTHROPIC_TARGET_API_URL")
effective_openai_api_url = openai_api_url or os.environ.get("OPENAI_TARGET_API_URL")
effective_gemini_api_url = gemini_api_url or os.environ.get("GEMINI_TARGET_API_URL")
@@ -200,6 +207,7 @@ def proxy(
config = ProxyConfig(
host=host,
port=port,
+ anthropic_api_url=effective_anthropic_api_url,
openai_api_url=effective_openai_api_url,
gemini_api_url=effective_gemini_api_url,
mode=effective_mode,
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py
index 2ba7b49e0..827d01e87 100644
--- a/headroom/proxy/server.py
+++ b/headroom/proxy/server.py
@@ -685,6 +685,7 @@ class ProxyConfig:
# Server
host: str = "127.0.0.1"
port: int = 8787
+ anthropic_api_url: str | None = None # Custom Anthropic API URL override
openai_api_url: str | None = None # Custom OpenAI API URL override
gemini_api_url: str | None = None # Custom Gemini API URL override
@@ -1688,6 +1689,14 @@ class HeadroomProxy:
def __init__(self, config: ProxyConfig):
self.config = config
+ # Override ANTHROPIC_API_URL with config if set
+ # Strip trailing /v1 or /v1/ to avoid double-path (e.g., .../v1/v1/models)
+ if config.anthropic_api_url:
+ url = config.anthropic_api_url.rstrip("/")
+ if url.endswith("/v1"):
+ url = url[:-3]
+ HeadroomProxy.ANTHROPIC_API_URL = url
+
# Override OPENAI_API_URL with config if set
# Strip trailing /v1 or /v1/ to avoid double-path (e.g., .../v1/v1/models)
if config.openai_api_url: