> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agnost.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# VoltAgent

> Capture traces from VoltAgent agents over OTLP

## Choose a setup method

| Method              | Use it when                                                                    |
| ------------------- | ------------------------------------------------------------------------------ |
| **Agnost AI skill** | You want your coding agent to inspect the app, make the change, and verify it. |
| **Agnost AI SDK**   | You want explicit control over the interaction boundaries and fields.          |
| **OpenTelemetry**   | The framework already emits useful spans or you operate an OTel pipeline.      |

Start with one method for a call path. Combining SDK tracking with framework
OpenTelemetry on the same call can create duplicate interactions.

## Recommended: Agnost AI skill

<Note>
  **Recommended.** Choose this path when you want your coding agent to inspect the
  project, select a supported transport, make the smallest instrumentation change,
  send a test event, and verify that it reached Agnost AI.
</Note>

Install the skill once in your coding-agent environment:

```bash theme={null}
npx skills add AgnostAI/skills --skill agnost-ai
```

Run the framework-specific prompt below from the application root. Review the
resulting diff before deploying it.

```text theme={null}
Use the agnost-ai skill to add Agnost AI analytics to this VoltAgent application.
Org ID: your-org-id
Instrument the real agent.generateText() path and verify one fresh interaction.
```

## Manual setup: Agnost AI SDK

```bash theme={null}
npm install agnostai
```

```typescript theme={null}
import * as agnost from 'agnostai';

agnost.init('your-org-id');
const interaction = agnost.begin({ userId: 'u-42', agentName: 'voltagent-support', input: prompt });
try {
  const result = await agent.generateText(prompt);
  interaction.end(result.text);
} catch (error) {
  interaction.end(String(error), false);
  throw error;
} finally {
  await agnost.shutdown();
}
```

## Manual setup: OpenTelemetry

VoltAgent ships its own observability layer. Plug an OTLP exporter into `VoltAgentObservability`, then pass `userId` / `conversationId` per call.

### 1. Install

**Already have `@voltagent/core` and `@opentelemetry/exporter-trace-otlp-proto`?** Skip.

**No setup yet?**

```bash theme={null}
npm install @voltagent/core @opentelemetry/exporter-trace-otlp-proto @opentelemetry/sdk-trace-node
```

### 2. Wire the OTel exporter pointing at Agnost AI

**Already have `VoltAgentObservability`?** Append a span processor for Agnost AI to the existing `spanProcessors` array:

```typescript theme={null}
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';

const agnostProcessor = new BatchSpanProcessor(
  new OTLPTraceExporter({
    url: 'https://otel.agnost.ai/v1/traces',
    headers: { 'X-Agnost-Org-ID': process.env.AGNOST_ORG_ID! },
  }),
);

// Inside your existing VoltAgentObservability:
spanProcessors: [
  // ...your existing processors,
  agnostProcessor,
]
```

**No Observability yet?** Full setup:

```typescript theme={null}
import { VoltAgent, VoltAgentObservability } from '@voltagent/core';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';

const exporter = new OTLPTraceExporter({
  url: 'https://otel.agnost.ai/v1/traces',
  headers: { 'X-Agnost-Org-ID': process.env.AGNOST_ORG_ID! },
});

const observability = new VoltAgentObservability({
  spanProcessors: [new BatchSpanProcessor(exporter)],
});

new VoltAgent({ agents: { agent }, observability });
```

### 3. Pass userId / conversationId per call

```typescript theme={null}
await agent.generateText('Hello', {
  userId: 'user-42',
  conversationId: 'conv-abc123',
});
```

VoltAgent maps `userId` → `user.id` and `conversationId` → `conversation.id` on every span: both read directly by Agnost AI for user / session grouping.

### What appears in Agnost AI

* **Conversations** grouped by `conversationId`.
* **User-level analytics** grouped by `userId`.
* **Events** for every exported span.

### Verify

Run one `agent.generateText` call, then open **Events** and confirm the span arrived.

### Troubleshooting

* Confirm your `BatchSpanProcessor` is attached to `VoltAgentObservability`.
* Confirm `X-Agnost-Org-ID` is set on the exporter.
* Confirm `userId` and `conversationId` are passed per call.

### References

* [Enable OpenTelemetry export](https://voltagent.dev/docs/observability/mlflow/)
* [Add custom metadata](https://voltagent.dev/observability-docs/setup/#add-metadata-to-traces)

## Next steps

* [Conversations](/using-conversations): review the complete VoltAgent interaction.
* [Events](/using-events): inspect agent, model, and tool activity.
* [Intents](/using-intents): organize production conversations by what users wanted.
