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.

fix: honor litellm availability overrides

JerrettDavisc7922d6de665
diff --git a/headroom/proxy/cost.py b/headroom/proxy/cost.py
index d1bef3a1a..40e747d53 100644
--- a/headroom/proxy/cost.py
+++ b/headroom/proxy/cost.py
@@ -27,10 +27,10 @@ def _get_litellm_module() -> Any | None:
"""Import LiteLLM only when pricing data is actually requested."""
global litellm
- if litellm is not None:
- return litellm
if not LITELLM_AVAILABLE:
return None
+ if litellm is not None:
+ return litellm
try:
import litellm as imported_litellm
diff --git a/headroom/proxy/savings_tracker.py b/headroom/proxy/savings_tracker.py
index 9910d006b..6ffe263cc 100644
--- a/headroom/proxy/savings_tracker.py
+++ b/headroom/proxy/savings_tracker.py
@@ -37,10 +37,10 @@ def _get_litellm_module() -> Any | None:
"""Import LiteLLM only when cost metadata is requested."""
global litellm
- if litellm is not None:
- return litellm
if not LITELLM_AVAILABLE:
return None
+ if litellm is not None:
+ return litellm
try:
import litellm as imported_litellm