Skip to Content

I trace the Vercel AI SDK with Traceloop. How do I switch to Rius?

To switch to Rius, replace the Traceloop initialization with the Rius SDK’s init() call, and your Vercel AI SDK calls arrive as traces with models, tokens and cost. On ai 7, init() registers the AI SDK’s telemetry for you. On ai 5 and 6, you enable telemetry on each call. Run one tracing setup per process, so remove the Traceloop one when you add Rius.

How it works

The Vercel AI SDK integration is TypeScript only and reads the AI SDK’s own OpenTelemetry telemetry. You do not add a Rius-specific wrapper around each call.

  • ai 7: the AI SDK no longer emits spans itself. They come from @ai-sdk/otel, and init() registers it when the package is installed. This needs Node 22 or newer, the same floor as ai 7.
  • ai 5 and 6: telemetry is built in but off until a call opts in with experimental_telemetry set to isEnabled true. Nothing extra is installed, and Node 18 or newer works.
  • Cost: Rius computes it on the server from the model and the token counts. You never send a cost.
  • Counting: each model call is counted once in tokens and cost, and the wrapper span around it still shows the run’s total.

Running both setups in one process produces duplicate LLM spans, because each one instruments the same libraries. Remove the Traceloop initialization from any process where you add init().

If you would rather keep OpenLLMetry and change only where it exports, the Migrate from Traceloop guide covers that path. This article covers the full swap to the Rius SDK. The wider picture is in Migrate to Rius.

Set it up

  1. Install the Rius SDK. On ai 7, add the telemetry package too.

    npm install @glassflow-ai/rius @opentelemetry/api npm install @ai-sdk/otel
  2. Remove the Traceloop setup from the service you move first. Delete the traceloop.initialize call, the @traceloop/node-server-sdk import, and the TRACELOOP_* variables from your deployment.

  3. Initialize Rius where Traceloop was initialized. Await ready so the AI SDK integration is registered before your first call, and call shutdown() before a short script exits, because the TypeScript SDK does not flush spans on exit.

    import { init } from '@glassflow-ai/rius' import { openai } from '@ai-sdk/openai' import { generateText } from 'ai' const rius = init({ apiKey: 'ri_...', serviceName: 'my-agent' }) await rius.ready // the AI SDK integration is registered before the first call const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: 'Summarize this ticket', }) await rius.shutdown() // export queued spans before the process exits

    serviceName takes the place of Traceloop’s appName. It names the agent your traces are grouped under.

  4. On ai 5 or 6, opt each call in.

    const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: 'Summarize this ticket', experimental_telemetry: { isEnabled: true }, })
  5. Replace the Traceloop helpers around your calls. withWorkflow, withTask, withAgent and withTool become observe wrappers with the matching kind, and withConversation becomes withSession. Name each wrapped function, because an anonymous one traces as anonymous. To group traces by end user, use withUser. Traceloop’s association properties such as user_id are not read as Rius users.

  6. Verify. Run one generateText call and open the trace in the console. On ai 7, await rius.ready lists vercel-ai. On ai 5 and 6 it does not list it even when tracing works, so check the trace itself. If no spans appear on ai 5 or 6, the usual cause is a call without experimental_telemetry enabled.

To compare before you cut over, move one service first and leave the others reporting to Traceloop. For identical traces in both backends, keep OpenLLMetry for now and send through the Collector fan-out instead. Setup details for every library are on the Integrations page.

What you get

  • A readable run tree. An agent span (invoke_agent) wraps the steps of a tool-calling loop. Each step has a span, each model call has a chat span, and each tool execution has an execute_tool span.
  • Full call detail. Each call carries its input and output messages, the request’s tool definitions, the resolved model, and token usage including cache reads, cache writes when the AI SDK reports them, and reasoning tokens (@glassflow-ai/rius 1.2.0 or later).
  • Time to first token. Streamed calls carry it, from @glassflow-ai/rius 1.1.0.
  • Cost per call. It is a list-price estimate in US dollars, computed from the model and tokens.
  • The same data on ai 5, 6 and 7. A call stores the same fields whichever version made it, from @glassflow-ai/rius 1.2.0.
  • Privacy controls. captureContent: false and a mask apply to prompts, responses, tool definitions, the system prompt and tool call arguments and results.

Span names follow the GenAI conventions, so they differ from Traceloop’s names. Update any saved search that matches on a Traceloop span name. Your existing traces stay in Traceloop, and Rius starts from the first span you send it. Rius has no evals, datasets, prompt registry or guardrails, so keep those workflows in Traceloop if you use them.

When something else fits

  • If you want to keep OpenLLMetry and only change where it exports, follow the Traceloop guide’s re-pointing path instead of the full swap.
  • If your code uses Traceloop’s platform features such as prompts, guardrails or datasets, keep Traceloop for those and add Rius alongside it through a Collector.

Still stuck? Get help

Last updated on