# segi · Error monitoring · LLM integration guide This file is written for AI coding agents. It gives the smallest set of steps that get the segi error SDK wired into a project. Each section is independent — pick the one that matches the user's stack. ## TL;DR 1. User creates a project at https://segi.extn.ai and copies a key like `segi_pk_live_…`. 2. Install the SDK for the stack (`@extn/segi-js`, `@extn/segi-nextjs`, or `@extn/segi-nestjs`). 3. Call `Segi.init({ projectKey, endpoint: "https://segiapi.extn.ai" })` (or the framework-specific wrapper). For NestJS also register the global exception filter. 4. Verify: throw a test error, see it group into an Issue in the dashboard. ## Ingest endpoint - `POST https://segiapi.extn.ai/api/ingest/events` - Header: `X-Segi-Project-Key: segi_pk_live_…` (or `?pk=` for sendBeacon paths) - Origin allow-list lives on each project key — set it for browser keys. - Per-project rate limit (default 600/min) plus a plan-level monthly cap (Free 1,000 / Team 10,000 / Enterprise 10M soft). - Over-cap response: `429 { error: "quota_exceeded", metric, limit, used, resetsAt, upgradeUrl }`. The SDK does not retry these. - Success response: `202 { ok: true, accepted: true }`. ## Browser (npm) ```ts import Segi from "@extn/segi-js"; Segi.init({ projectKey: "segi_pk_live_...", endpoint: "https://segiapi.extn.ai", environment: "production", // optional release: "v2.14.3", // optional }); // Auto-captures window.onerror + unhandledrejection. // Manual: Segi.captureException(new Error("boom")); Segi.captureMessage("checkout finished", { level: "info" }); Segi.setUser({ id: "u_123", email: "alice@example.com" }); Segi.addBreadcrumb({ type: "click", message: "cart-add" }); ``` ## Plain HTML / CDN (no bundler) ```html ``` Note: the CDN bundle does NOT include the session-recording submodule. Use npm if recording is needed. ## Next.js Client side (`app/segi-init.tsx`, marked `"use client"`): ```ts "use client"; import { initSegiClient } from "@extn/segi-nextjs/client"; initSegiClient({ publicKey: process.env.NEXT_PUBLIC_SEGI_KEY!, environment: process.env.NEXT_PUBLIC_VERCEL_ENV ?? "development", release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA, }); export default function SegiInit() { return null; } ``` Mount once in root `layout.tsx`: ```tsx import SegiInit from "./segi-init"; // inside
: