Skip to main content
AI Kit integrates with Langfuse to trace generate/stream calls. This guide covers dependency setup, processor initialisation, and agent-level configuration.

Dependencies

Environment variables

Initialise Langfuse

  • ensureLangfuseTelemetry dynamically loads @langfuse/otel, registers a NodeTracerProvider, and returns a reusable handle.
  • autoFlush defaults to "process": beforeExit, SIGINT, and SIGTERM trigger flush()/shutdown() automatically.
  • Initialise as early as possible (server entrypoint, framework plugin, …).

Next.js example

Enable telemetry on an agent

Adjust it dynamically:
  • telemetry merges with experimental_telemetry.
  • Overrides are ignored when the agent telemetry flag is off unless you explicitly set experimental_telemetry.isEnabled.

Instrument workflows

Workflows use the same OTEL stack. See Workflow telemetry for configuration details (traceName, metadata, userId, …).

Nitro / Nuxt example

Additional resources