generateText, streamText, generateObject — for calling LLMs from TypeScript apps. Arize AX captures every AI SDK call by ingesting the SDK’s native OpenTelemetry spans through the @arizeai/openinference-vercel span processor.
Prerequisites
- Node.js 18+
- An Arize AX account (sign up)
- An
OPENAI_API_KEYfrom the OpenAI Platform - Vercel AI SDK 3.3 or higher
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Pick the tab for your runtime — both install the same@arizeai/openinference-vercel processor and differ only in the OpenTelemetry registration helper.
This guide targets AI SDK v6 and earlier (
ai@^6 with @ai-sdk/openai@^3). AI SDK v7 reworked how experimental_telemetry emits OpenTelemetry spans, so the wiring shown here does not produce spans on ai@7 — for v7, use the Vercel AI SDK v7 guide instead.Pin the processor to @arizeai/openinference-vercel@^2 as shown below. The latest major (@arizeai/openinference-vercel@3) targets AI SDK v7: it peer-depends on ai@^7 and @ai-sdk/otel, requires Node.js 22+, and ships ESM-only, so it does not work with this v6 setup.- Node.js
- Next.js
Both runtimes wire the same
OpenInferenceSimpleSpanProcessor from @arizeai/openinference-vercel — they differ only in how OpenTelemetry is registered, shown in the matching tab under Setup tracing. See Troubleshooting for the version-pinning rules.Configure credentials
Setup tracing
Pick the tab that matches your runtime. The processor’sspanFilter and reparentOrphanedSpans options control which spans reach Arize and how each trace is rooted — see Span filter.
- Node.js
- Next.js
Run Vercel AI SDK
This is a standalone Node script. In Next.js, you don’t import
provider or call forceFlush() — the root instrumentation.ts registers tracing automatically. Just add experimental_telemetry: { isEnabled: true } to the generateText/streamText calls inside your route handlers or server actions; that opt-in flag is the only app-code change needed.Expected output
Verify in Arize AX
- Open your Arize AX space and select project
vercel-ai-sdk-tracing-example. - You should see a new trace within ~30 seconds containing an
ai.generateTextparent span wrapping anai.generateText.doGenerateLLM child span (with prompt, response, and token usage attached). - If no traces appear, see Troubleshooting.
Check from the skill, CLI, or SDK
Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.- Arize skill (agent)
- AX CLI
- SDK
Install the Arize Skills plugin and let your coding agent check for you:Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.
Span filter
Other instrumentations registered alongside the AI SDK (@opentelemetry/instrumentation-http, @vercel/otel, Next.js’s built-in tracing) emit POST / GET spans for every fetch, and the AI SDK’s spans nest under those HTTP roots. Two options on the processor control which spans reach Arize and how they’re rooted:
spanFilter: isOpenInferenceSpankeeps only the AI spans and drops the rest — the raw HTTP/fetch spans those other instrumentations emit.reparentOrphanedSpans: truere-roots any AI span left orphaned when the filter drops its parent, so the highest-level AI SDK span (ai.generateText,ai.streamText, …) becomes a clean trace root instead of pointing at a parent that was never exported.
Troubleshooting
- No traces in Arize AX. Every AI SDK call needs
experimental_telemetry: { isEnabled: true }set on it — without that flag, the SDK never emits spans. Also confirmARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.ts. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. 401from OpenAI. VerifyOPENAI_API_KEYis set and has access togpt-5.5. Swapopenai("gpt-5.5")for a model your key can call.- Process exits before spans flush. Always
await provider.forceFlush()(orprovider.shutdown()) before the process exits, otherwise trailing spans are dropped. - Next.js / Vercel runtime. Use
@vercel/otel’sregisterOTel(...)instead ofNodeTracerProvider, and pin versions:@vercel/otel@1.xrequires@opentelemetry/*1.x(0.1.xfor unstable APIs);@vercel/otel@2.xrequires@opentelemetry/*2.x(0.2.x). Mismatches surface as silent missing traces. - AI SDK spans orphaned on the Traces tab. Happens when
isOpenInferenceSpandrops the HTTP root without re-rooting its children. SetreparentOrphanedSpans: trueon the processor as shown in Span filter, and confirm@arizeai/openinference-vercelis 2.8.0 or later on the v2 line (@arizeai/openinference-vercel@^2). The v3 major targets AI SDK v7 and will not emit spans for this v6 setup.