Skip to content

: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.

feat(llm-gateway): add ci product for e2e test runs (#68767)

Joshua Snyderc8311b5a9520
diff --git a/posthog/llm/gateway_client.py b/posthog/llm/gateway_client.py
index 29c3db553efe..8d73894b1a38 100644
--- a/posthog/llm/gateway_client.py
+++ b/posthog/llm/gateway_client.py
@@ -13,6 +13,7 @@ logger = structlog.get_logger(__name__)
Product = Literal[
"llm_gateway",
+ "ci",
"posthog_code",
"background_agents",
"slack_app",
diff --git a/services/llm-gateway/README.md b/services/llm-gateway/README.md
index 6a8b568ca4e5..b79fc85be07b 100644
--- a/services/llm-gateway/README.md
+++ b/services/llm-gateway/README.md
@@ -213,6 +213,7 @@ OAuth access is permitted only for products with an explicit `allowed_applicatio
| Product | Auth | Models | Notes |
| -------------------- | --------------- | -------------------------- | ------------------------------- |
| `llm_gateway` | API key only | All | Default when no product in path |
+| `ci` | API key only | All | CI / e2e test runs |
| `posthog_code` | OAuth only | Restricted set | Desktop coding agent |
| `background_agents` | OAuth only | Restricted set | Cloud background agents |
| `wizard` | API key + OAuth | All | Max AI assistant |
diff --git a/services/llm-gateway/src/llm_gateway/config.py b/services/llm-gateway/src/llm_gateway/config.py
index 02f9d120c5f1..24853e768333 100644
--- a/services/llm-gateway/src/llm_gateway/config.py
+++ b/services/llm-gateway/src/llm_gateway/config.py
@@ -26,6 +26,7 @@ DEFAULT_USER_COST_LIMIT = UserCostLimit(
DEFAULT_PRODUCT_COST_LIMITS: dict[str, "ProductCostLimit"] = {
"llm_gateway": ProductCostLimit(limit_usd=1000.0, window_seconds=86400),
+ "ci": ProductCostLimit(limit_usd=1000.0, window_seconds=2592000), # $1000 / 30 days
"wizard": ProductCostLimit(limit_usd=2000.0, window_seconds=86400),
"posthog_code": ProductCostLimit(limit_usd=5000.0, window_seconds=3600),
"background_agents": ProductCostLimit(limit_usd=1000.0, window_seconds=3600),
diff --git a/services/llm-gateway/src/llm_gateway/products/config.py b/services/llm-gateway/src/llm_gateway/products/config.py
index 38a4a8ce86d2..9c58326a899f 100644
--- a/services/llm-gateway/src/llm_gateway/products/config.py
+++ b/services/llm-gateway/src/llm_gateway/products/config.py
@@ -65,6 +65,14 @@ PRODUCTS: Final[dict[str, ProductConfig]] = {
allowed_models=None,
allow_api_keys=True,
),
+ # CI / end-to-end test runs (e.g. posthog/code agent e2e tests). Authenticates with a
+ # personal API key, allows all models, and keeps CI traffic attributed to its own
+ # ai_product rather than the catch-all llm_gateway bucket.
+ "ci": ProductConfig(
+ allowed_application_ids=None,
+ allowed_models=None,
+ allow_api_keys=True,
+ ),
"posthog_code": ProductConfig(
allowed_application_ids=frozenset({POSTHOG_CODE_US_APP_ID, POSTHOG_CODE_EU_APP_ID, POSTHOG_CODE_DEV_APP_ID}),
allowed_models=_POSTHOG_CODE_AGENT_MODELS | BEDROCK_MODELS,
diff --git a/services/llm-gateway/tests/test_product_config.py b/services/llm-gateway/tests/test_product_config.py
index 8a36d6d42d38..f4c4d8430e1a 100644
--- a/services/llm-gateway/tests/test_product_config.py
+++ b/services/llm-gateway/tests/test_product_config.py
@@ -43,6 +43,9 @@ class TestCheckProductAccess:
("llm_gateway", "personal_api_key", None, "claude-3-opus", True, None),
("llm_gateway", "oauth_access_token", "any-app-id", "gpt-4o", False, "not authorized"),
("llm_gateway", "personal_api_key", None, None, True, None),
+ # ci allows API keys with any model (used by e2e test runs); OAuth rejected (no app IDs)
+ ("ci", "personal_api_key", None, "claude-3-opus", True, None),
+ ("ci", "oauth_access_token", "any-app-id", "gpt-4o", False, "not authorized"),
# posthog_code requires OAuth with valid app ID
("posthog_code", "personal_api_key", None, None, False, "requires OAuth"),
("posthog_code", "oauth_access_token", "invalid-app-id", None, False, "not authorized"),