Agent Analytics quickstart
This feature is in Early Access. During this time, aspects of the functionality may still be developed, and this documentation may not always be up to date. If you have any questions, contact Amplitude Support.
Install the SDK, run one command, and your agent's traffic shows up in Amplitude about five minutes from now. You need a project with Agent Analytics enabled and its API key, and nothing else. Anonymous user and session IDs are fine.
This page is the fast path. To instrument production with full identity and privacy controls, go to Set up Agent Analytics and the SDK reference instead.Install the SDK
npm install @amplitude/ai @amplitude/analytics-node
Run the setup agent
Run this, paste the printed prompt into your coding assistant (Cursor, Claude Code, Windsurf, GitHub Copilot, or Codex), and approve the change it proposes.
npx amplitude-ai
The agent finds every LLM call site and the session lifecycle, instruments them, and prints a dry-run report of the events and field fill rates before anything ships.
Patch one line instead
No coding assistant handy? One call at startup monkey-patches supported provider clients (OpenAI, Anthropic, Gemini, and more), so the SDK tracks your existing LLM calls with no other code changes.
import { AmplitudeAI, patch } from "@amplitude/ai";
const ai = new AmplitudeAI({ apiKey: process.env.AMPLITUDE_AI_API_KEY! });
patch({ amplitudeAI: ai });
The patch captures basic [Agent] AI Response events only: enough to verify the pipeline works, not the end state.
Watch the events arrive
Run the doctor to validate your environment variables, dependencies, and the event-pipeline connection:
npx amplitude-ai doctor
[Agent] AI Response events appear with model, provider, latency, token, and cost fields populated. For the full verification checklist, go to Verify your data.Add IDs when you're ready
It's a ladder you climb over time, not a form you fill out on day one.
| Add | What it unlocks |
|---|---|
| Nothing (patch only) | Basic LLM traces and aggregate call counts |
| User ID | Per-user analytics, cohorts, retention |
| Session ID | Multi-turn analysis, session enrichment, quality scores |
| Agent ID | Per-agent cost, latency, and quality dashboards |
Was this helpful?