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(proxy): label plain OpenAI chat traffic openai, not custom (#3912)

Tejas Chopra7df8bd87b547
diff --git a/headroom/proxy/handlers/openai.py b/headroom/proxy/handlers/openai.py
index 06fc8150b..5b98bc102 100644
--- a/headroom/proxy/handlers/openai.py
+++ b/headroom/proxy/handlers/openai.py
@@ -3646,7 +3646,7 @@ class OpenAIHandlerMixin:
# other custom base is the shared "custom" bucket. Never derive the
# label from the request-controlled hostname — see the review on #3759.
openai_chat_outcome_provider = custom_chat_provider or (
- CUSTOM_BASE_PROVIDER if upstream_base_url else "openai"
+ CUSTOM_BASE_PROVIDER if custom_upstream_base_url else "openai"
)
# Memory: Get user ID when memory is enabled. Reads `request.headers`
diff --git a/tests/test_proxy_openai_cache_stability.py b/tests/test_proxy_openai_cache_stability.py
index 3985c9247..0e536faa2 100644
--- a/tests/test_proxy_openai_cache_stability.py
+++ b/tests/test_proxy_openai_cache_stability.py
@@ -20,6 +20,7 @@ from opentelemetry.sdk.metrics.export import InMemoryMetricReader
from headroom.backends.base import BackendResponse
from headroom.observability import HeadroomOtelMetrics, reset_otel_metrics, set_otel_metrics
+from headroom.proxy.handlers.openai import _openai_rate_limit_key
from headroom.proxy.server import ProxyConfig, create_app
from tests.test_observability_metrics import _collect_metrics
@@ -1297,7 +1298,7 @@ def test_openai_chat_custom_base_flood_cannot_grow_the_provider_set(
"""Headroom's own limiter, refusing only ``limited_auth``."""
async def check_request(self, key: str = "default") -> tuple[bool, float]:
- return key != limited_auth, 1.0
+ return key != _openai_rate_limit_key({"authorization": limited_auth}), 1.0
async def check_tokens(self, key: str, tokens: int) -> tuple[bool, float]:
return True, 0.0