Skip to main content

Integration Overview

Pass the Asymptote tracer into AI SDK telemetry so model calls and tool loops stay in the same trace.

Overview

AI SDK exposes OpenTelemetry hooks through experimental_telemetry. Asymptote Observe is OpenTelemetry-first, so you can trace generateText, streamText, tool loops, and custom orchestration by passing Observe.getTracer() to each AI SDK call you want captured. This page covers Node.js usage. For framework placement and serverless flushing, see Next.js and serverless.

What Asymptote Captures

  • AI SDK spans emitted when experimental_telemetry.isEnabled is true.
  • Model call spans for supported generate* and stream* operations.
  • Tool call spans emitted by AI SDK telemetry.
  • Provider and model metadata where AI SDK and provider adapters emit it.
  • Parent spans you add with Observe.observe() for route or workflow grouping.

Prerequisites

  • Node.js 20 or newer.
  • @asymptote/sdk installed.
  • ai and an AI SDK model provider package installed.
  • ASYMPTOTE_API_KEY set for Asymptote Managed hosted Observe, or OTEL_EXPORTER_OTLP_ENDPOINT set for customer-managed OTLP export. To get an Asymptote Managed API key, reach out for a demo.
Install the SDK and Vercel AI SDK
Set environment variables for Asymptote and your provider:
Set Asymptote Managed and OpenAI environment variables

Getting Started

Initialize Observe once at application startup, then pass the tracer to AI SDK calls.
Trace an AI SDK generateText call
The same pattern applies anywhere AI SDK accepts experimental_telemetry.

Reuse The Tracer

Use Observe.getTracer() anywhere AI SDK accepts an OpenTelemetry tracer. This lets generated spans share the same exporter, resource attributes, and Beacon compatibility path as the rest of your application.
Reuse the Observe tracer

Trace A Tool Loop

Pass the tracer into tool-calling AI SDK flows as well.
Trace an AI SDK tool loop

Group Calls With Custom Steps

Wrap orchestration code around AI SDK calls when you need spans for planning, policy checks, retrieval, or handoffs that are not covered by model telemetry.
Group AI SDK calls with a parent span
For serverless handlers, call Observe.flush() before returning if the invocation may terminate immediately after the model call.

Troubleshooting

  • Confirm ASYMPTOTE_API_KEY or OTEL_EXPORTER_OTLP_ENDPOINT is set in the runtime process.
  • Make sure every AI SDK call you want traced has experimental_telemetry.isEnabled=true.
  • Pass tracer: Observe.getTracer() on each traced AI SDK call.
  • In short-lived scripts or jobs, call Observe.flush() before exit.
  • In Next.js, initialize from instrumentation.ts in the Node.js runtime.

What’s Next

Next.js And Serverless

Place initialization correctly in Next.js and flush traces in short-lived runtimes.

Observe

Group AI SDK calls under custom parent spans.