: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
import litellm
from litellm.integrations.custom_logger import CustomLogger
from llm_gateway.callbacks.posthog import PostHogCallback
from llm_gateway.callbacks.prometheus import PrometheusCallback
from llm_gateway.callbacks.rate_limiting import RateLimitCallback
from llm_gateway.config import get_settings
def init_callbacks() -> None:
settings = get_settings()
callbacks: list[CustomLogger] = []
if settings.posthog_project_token:
callbacks.append(
PostHogCallback(
api_key=settings.posthog_project_token,
host=settings.posthog_host,
# Reuses the plan-resolver URL — same per-region value.
region_url=settings.posthog_api_base_url,
secondary_api_key=settings.posthog_secondary_project_token,
secondary_host=settings.posthog_secondary_host,
ai_lane_capture=settings.posthog_ai_lane_capture,
)
)
callbacks.append(RateLimitCallback())
callbacks.append(PrometheusCallback())
litellm.callbacks = callbacks