For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.
Send OpenTelemetry traces to Agent Analytics
Amplitude's OTLP endpoint accepts OpenTelemetry GenAI spans and translates them into the same [Agent] events the AI SDK produces, so sessions, enrichment, and every chart work the same way. If your stack already emits GenAI spans, point your exporter at Amplitude. You don't need the Amplitude SDK or new instrumentation.
Use this path when you already run an OpenTelemetry exporter or Collector. If you instrument a Node or Python app with the AI SDK instead, use the SDK's in-process OTel exporters, which are a separate path. Before you start, decide your session ID and privacy mode.
Configure your exporter
Set these environment variables on your exporter or Collector:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.amplitude.com/otlp/v1/traces # US
# OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.eu.amplitude.com/otlp/v1/traces # EU
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <project API key>"
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf # or http/json
The OTLP HTTP endpoint is generally available in the US and EU. A valid project API key is enough. Amplitude doesn't require a per-project enablement request, and the receiver never returns 403 for a missing allowlist.
- Protocol: OTLP over HTTP only. Amplitude accepts
http/protobuf(the OpenTelemetry SDK and Collector default) andhttp/json, with optional gzip. Amplitude doesn't support OTLP/gRPC, so bridge gRPC traffic through a local Collector with an OTLP/HTTP exporter. - Authentication: Pass the project API key as a
Bearertoken or as anapi_keyquery parameter. - Supported instrumentation: OpenTelemetry GenAI semantic conventions, OpenInference (
llm.*), OpenLLMetry and Traceloop (traceloop.*), OpenLIT, and LiteLLM. Amplitude ignores non-GenAI spans, so you can point a mixed Collector at Amplitude.
Send Claude Platform traces
Claude already exports OpenTelemetry. Add Amplitude as a Claude destination. You don't need the Amplitude SDK for this path.
In the Claude console, set the destination base URL to the regional host. Claude appends /v1/traces, so the base URL doesn't include that path.
| Region | Console base URL | Advanced traces endpoint |
|---|---|---|
| US | https://api.amplitude.com/otlp | https://api.amplitude.com/otlp/v1/traces |
| EU | https://api.eu.amplitude.com/otlp | https://api.eu.amplitude.com/otlp/v1/traces |
Set the header Authorization: Bearer <project API key>.
- Full content sends transcripts. User and assistant text on a Managed Agents turn become
[Agent] User Messageand[Agent] AI Response. - Metadata only still sends model, tokens, latency, tool calls, and errors. A turn with no message text stays an
[Agent] Span. - Use one export path. If the Claude SDK and Claude Platform both export the same response, Amplitude stores both.
- The destination Test action sends
anthropic.test. Amplitude accepts that span and doesn't show it in Live Events.
A Claude session is anthropic.session.id. gen_ai.conversation.id stays the thread inside that session. Messages API spans have no Claude session id, so they use the session attribute order. For the span mapping, refer to Claude Platform spans.
Set session and user attributes
The session attribute is the one change worth making to your instrumentation. Amplitude maps everything else automatically.
An Amplitude agent session is a whole conversation, not one trace. Without a conversation attribute, every trace becomes its own single-turn session. Task completion and abandonment then read as noise, and because billing is per agent session, one conversation bills as several.
Set these attributes on your GenAI spans:
- Session:
gen_ai.conversation.id, set to your conversation, ticket, or run ID. Refer to Choose a session ID. - User:
enduser.id, set to the same user ID you use for product analytics. Never send a placeholder such asanonymous. Refer to Set user IDs. - Agent:
gen_ai.agent.id, or Amplitude falls back to the resourceservice.name. - Parent agent: the span attribute
amplitude.parent.agent.id. A parent span ID isn't a parent agent, and Amplitude doesn't read a parent agent from the resource.
Amplitude also reads other common attributes, such as session.id and Traceloop association properties. For the full resolution order, refer to Attribute resolution order.
To report cost, also set gen_ai.usage.cost. Amplitude doesn't calculate a cost when this attribute is absent.
Apply your privacy mode
Most OpenTelemetry GenAI instrumentation treats message content as opt-in.
- Content capture off: You get the
metadata_onlyshape: cost, tokens, latency, model, and sessions, with no transcripts. - Content capture on:
gen_ai.input.messages,gen_ai.output.messages, andgen_ai.system_instructionsbecome message text and[Agent] System Prompt. Amplitude stores that text as exported. Amplitude doesn't scrub it after receipt. Scrub those attributes, plus tool arguments and tool results, before export. Refer to Agent Analytics privacy modes.
Redaction that must happen before data leaves your network belongs in your application or a Collector processor. For what each mode sends, refer to Agent Analytics privacy modes.
Session close on an OTLP-only path
[Agent] Session End is optional and recommended. An OpenTelemetry export doesn't send it unless your pipeline adds that event. Amplitude closes the session after 30 minutes without a qualifying agent event by default, and 24 hours from the session start when no per-session override is set. Enrichment runs once after that first close. The OpenTelemetry translator doesn't read an idle-timeout attribute from a span. To change the window, send the HTTP [Agent] Context key idle_timeout_minutes, or send one [Agent] Session End with [Agent] Session Idle Timeout Minutes. Refer to How sessions close. Python Strands uses this same path. Refer to AWS Strands.
Keep delivery reliable
Delivery is at least once. Run a Collector with a persistent sending queue and keep retries enabled, because an in-memory queue loses buffered spans on restart. A 200 response can carry a partial_success body listing rejected events. For limits and response codes, refer to Delivery, limits, and responses.
Verify
Send one traced conversation, then confirm in Live Events that the events arrive with:
- A real
[Agent] Session ID, not a trace ID. - A populated
[Agent] Agent ID. - Your own user IDs, not
unknown.
Those three values come from the attributes in Set session and user attributes. For the full checklist, refer to Verify your Agent Analytics instrumentation.
Was this helpful?