:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(llm-gateway): drop posthog_code free valve to $20 (#70947)
Adam Bowkerf5489f6c78b6
diff --git a/services/llm-gateway/src/llm_gateway/config.py b/services/llm-gateway/src/llm_gateway/config.pyindex 77ec22445f0f..5ae039012b1c 100644--- a/services/llm-gateway/src/llm_gateway/config.py+++ b/services/llm-gateway/src/llm_gateway/config.py@@ -63,9 +63,9 @@ DEFAULT_USER_COST_LIMITS: dict[str, "UserCostLimit"] = {}FREE_PLAN_COST_LIMIT = UserCostLimit(- burst_limit_usd=75.0,+ burst_limit_usd=20.0,burst_window_seconds=86400,- sustained_limit_usd=75.0,+ sustained_limit_usd=20.0,sustained_window_seconds=2592000,)diff --git a/services/llm-gateway/tests/test_cost_throttles.py b/services/llm-gateway/tests/test_cost_throttles.pyindex 00c076b18002..32dfdfa4b27d 100644--- a/services/llm-gateway/tests/test_cost_throttles.py+++ b/services/llm-gateway/tests/test_cost_throttles.py@@ -1279,24 +1279,24 @@ class TestRateLimitPoisoningPrevention:class TestPlanAwareThrottling:@pytest.mark.asyncio- async def test_free_user_gets_limit_of_75(self) -> None:+ async def test_free_user_gets_limit_of_20(self) -> None:from llm_gateway.rate_limiting.cost_throttles import UserCostBurstThrottlethrottle = UserCostBurstThrottle(redis=None)context = make_context(product="posthog_code", plan_key=None, seat_created_at="2026-01-01T00:00:00+00:00")- await throttle.record_cost(context, 75.0)+ await throttle.record_cost(context, 20.0)result = await throttle.allow_request(context)assert result.allowed is False@pytest.mark.asyncio- async def test_free_user_gets_sustained_limit_of_75(self) -> None:+ async def test_free_user_gets_sustained_limit_of_20(self) -> None:from llm_gateway.rate_limiting.cost_throttles import UserCostSustainedThrottlethrottle = UserCostSustainedThrottle(redis=None)context = make_context(product="posthog_code", plan_key=None, seat_created_at="2026-01-01T00:00:00+00:00")- await throttle.record_cost(context, 75.0)+ await throttle.record_cost(context, 20.0)result = await throttle.allow_request(context)assert result.allowed is False@@ -1318,7 +1318,7 @@ class TestPlanAwareThrottling:throttle = UserCostSustainedThrottle(redis=None)context = make_context(product="posthog_code", plan_key=None, seat_created_at="2025-01-01T00:00:00+00:00")- await throttle.record_cost(context, 49.0)+ await throttle.record_cost(context, 19.0)result = await throttle.allow_request(context)assert result.allowed is True@@ -1385,7 +1385,7 @@ class TestPlanAwareThrottling:@pytest.mark.parametrize(("seat_missing", "expected_allowed"),[- # Confirmed no seat (404) → free cap: $80 spent exceeds the $75 limit.+ # Confirmed no seat (404) → free cap: $80 spent exceeds the $20 limit.(True, False),# Plan resolution failed → default limits ($500/day): fail loose so an# outage never clamps paying users whose plan couldn't be resolved.@@ -1414,7 +1414,7 @@ class TestPlanAwareThrottling:("seat_missing", "code_usage_billed", "expected_allowed"),[# Seatless + org-billed Code usage: bills to the org - no per-user cap.- # $600 spent clears both the $75 free cap and the $500/day default.+ # $600 spent clears both the $20 free cap and the $500/day default.(True, True, True),# Seatless + not billed: the free cap holds (this pair pins that the# bypass never leaks to orgs that would get the usage for free).