: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
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
if [ -f "$REPO_ROOT/.env" ]; then
set -o allexport
source "$REPO_ROOT/.env"
set +o allexport
fi
provision_api_key() {
local max_attempts=10
local wait_sec=3
for i in $(seq 1 $max_attempts); do
if python "$REPO_ROOT/manage.py" setup_local_api_key --add-scopes llm_gateway:read 2>&1; then
return 0
fi
echo "[llm-gateway] Waiting for migrations before provisioning API key (attempt $i/$max_attempts)..."
sleep $wait_sec
done
echo "[llm-gateway] Warning: Could not auto-provision API key. Run manually:"
echo " python manage.py setup_local_api_key --add-scopes llm_gateway:read"
}
provision_api_key &
cd "$REPO_ROOT/services/llm-gateway"
unset VIRTUAL_ENV
export UV_PROJECT_ENVIRONMENT="$PWD/.venv"
uv sync --quiet
exec .venv/bin/uvicorn llm_gateway.main:app \
--host 0.0.0.0 \
--port "${LLM_GATEWAY_PORT:-3308}" \
--reload