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(billing): route customer archetype classification through the ai-gateway (#123400)

Jonathan Mieloo806117509c45
diff --git a/ee/billing/dags/customer_archetype.py b/ee/billing/dags/customer_archetype.py
index 820165aa6829..ccc12b752269 100644
--- a/ee/billing/dags/customer_archetype.py
+++ b/ee/billing/dags/customer_archetype.py
@@ -28,7 +28,7 @@ from posthog.hogql.query import execute_hogql_query
from posthog.clickhouse.query_tagging import Feature, Product, tag_queries
from posthog.dags.common import JobOwners
-from posthog.llm.gateway_client import get_llm_client
+from posthog.llm.gateway_client import build_openai_client
from posthog.models import Team
from ee.billing.dags.customer_archetype_prompt import SYSTEM_PROMPT
@@ -584,7 +584,9 @@ def classify_and_push_accounts_batch(
# Classify LLM batches with global concurrency control. The semaphore is shared
# across all accounts batches running in parallel so the total in-flight LLM
# requests stays bounded regardless of executor parallelism.
- client = get_llm_client("customer_archetype_classification")
+ client = build_openai_client(
+ product="customer_archetype_classification", ai_product="customer_archetype_classification"
+ )
semaphore = _get_llm_semaphore(config.llm_max_concurrent_requests)
new_classifications: list[AccountClassification] = []
failed_batches: list[dict[str, Any]] = []