Skip to main content
Agnost AI includes a hosted OTLP collector at otel.agnost.ai. Any framework that supports OpenTelemetry tracing can send spans to it — no SDK required.
Your AI App  →  otel.agnost.ai  →  Agnost Dashboard

Quick Setup

Point your OTLP exporter at otel.agnost.ai and include your org ID in the headers:
OTEL_EXPORTER_OTLP_ENDPOINT=https://otel.agnost.ai
OTEL_EXPORTER_OTLP_HEADERS="X-Agnost-Org-ID=<your-org-id>"
Get your org ID from app.agnost.ai.

Supported Frameworks

Vercel AI SDK

The Vercel AI SDK emits spans with ai.* prefixed names. No extra configuration is needed beyond pointing the exporter to Agnost.
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';

// Set OTEL env vars before starting your app, then use AI SDK normally
const result = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Hello',
  experimental_telemetry: {
    isEnabled: true,
    metadata: {
      sessionId: 'conv-abc123',   // groups events into one session
      userId: 'user-42',          // per-user analytics
    },
  },
});

OpenAI SDK (Python)

Install the OpenAI SDK with OTel instrumentation:
pip install openai opentelemetry-instrumentation-openai
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import BatchSpanProcessor

provider = TracerProvider()
provider.add_span_processor(
    BatchSpanProcessor(
        OTLPSpanExporter(
            endpoint="https://otel.agnost.ai/v1/traces",
            headers={"X-Agnost-Org-ID": "<your-org-id>"},
        )
    )
)

OpenAIInstrumentor().instrument(tracer_provider=provider)
Spans follow the OTel GenAI semantic conventions (gen_ai.* attributes) and are automatically classified.

Anthropic SDK (Python)

pip install anthropic opentelemetry-instrumentation-anthropic
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor

AnthropicInstrumentor().instrument(tracer_provider=provider)

MCP Toolbox for Databases

export OTEL_EXPORTER_OTLP_HEADERS="X-Agnost-Org-ID=<your-org-id>"
./toolbox --tools-file tools.yaml --telemetry-otlp="otel.agnost.ai"
See the MCP Toolbox guide for full setup details.

Custom Tool Spans

Name any span with a tool. prefix and it is automatically classified as a tool call:
import { trace, SpanStatusCode } from '@opentelemetry/api';

const tracer = trace.getTracer('my-app');

const span = tracer.startSpan('tool.search_web');
span.setAttribute('agnost.session_id', 'conv-abc123');
span.setAttribute('ai.toolCall.args', query);
try {
  const result = await searchWeb(query);
  span.setAttribute('ai.toolCall.result', JSON.stringify(result));
  span.setStatus({ code: SpanStatusCode.OK });
} catch (err) {
  span.setStatus({ code: SpanStatusCode.ERROR });
  throw err;
} finally {
  span.end();
}

Session & User Tracking

The collector resolves a session ID and user ID from span attributes using the following priority chains.

Session ID

PriorityAttributeSource
1agnost.session_idExplicit override (always wins)
2ai.telemetry.metadata.sessionIdVercel AI SDK experimental_telemetry.metadata
3ai.telemetry.metadata.conversationIdVercel AI SDK custom metadata
4ai.telemetry.metadata.projectIdVercel AI SDK custom metadata
5mcp.session.idMCP server session
6projectId / conversationIdLegacy bare keys
(trace ID)Fallback — one trace = one session

User ID

PriorityAttributeSource
1agnost.user_idExplicit override
2ai.telemetry.metadata.userIdVercel AI SDK metadata
3enduser.idOTel semantic convention
4user.id / user_idCommon custom attributes
User ID is checked on span attributes first, then resource attributes.