Skip to main content
@whyops/vercel-ai-sdk is the companion integration for apps built on the Vercel AI SDK. It sits on top of @whyops/sdk and automatically traces generateText, streamText, embed, and embedMany.

SDK Packages

Start here if you are choosing between the language SDKs and companion integrations.

TypeScript SDK

Create and initialize the base WhyOps client first, then come back here to wrap Vercel AI SDK calls.

Runtime Events

Add manual runtime events only when your app needs coverage beyond what the wrapper captures automatically.

What this package captures

When you wrap a Vercel AI SDK call with WhyOps, it captures:
  • user_message
  • llm_response
  • llm_thinking when readable reasoning text is exposed
  • tool_call_request
  • tool_call_response
  • error
  • embedding_request
  • embedding_response
@whyops/vercel-ai-sdk does not replace @whyops/sdk. You still create the WhyOps client with @whyops/sdk, then register that client once and wrap your Vercel AI SDK calls with this package.

Install

This package supports ai >= 5.0.0.

1. Create and register the WhyOps client

Call registerWhyOps() once during startup. After that, you wrap each Vercel AI SDK call with withWhyOps(...).

2. Wrap generateText()

Optional whyopsCtx

Pass a reusable whyopsCtx object as the second argument only when you want request-scoped linkage such as your own user ID or a caller-supplied trace ID:
whyopsCtx is optional. If you do not pass it, the wrapper keeps generating a trace automatically and does not add externalUserId.

3. Capture multi-step tool calls

withWhyOps() captures tool loops automatically. On ai@5, it also normalizes maxSteps into stopWhen so multi-step execution continues correctly.

4. Wrap streamText()

5. Use the re-exported embedding helpers

If you want embedding traces, import embed() and embedMany() from @whyops/vercel-ai-sdk instead of directly from ai.

Provider notes

  • OpenAI-compatible providers that expose nonstandard reasoning fields such as reasoning_content are normalized before WhyOps captures the step.
  • If a provider reports reasoning token usage but does not expose readable reasoning text, WhyOps does not synthesize a fake llm_thinking event.
  • This package is designed for server-side TypeScript runtimes where you already use @whyops/sdk.

API surface

whyopsCtx currently supports externalUserId?: string and traceId?: string.

Next step

If you have not created the base client yet, go to TypeScript SDK Quickstart. If your Vercel AI SDK app also has queue workers, tool orchestration, or downstream API steps outside the wrapper, add TypeScript SDK Runtime Events on top.