I trace the Vercel AI SDK with Langfuse. How do I switch to Rius?
Rius traces the Vercel AI SDK through its own integration, so you replace the Langfuse setup with init() from @glassflow-ai/rius and keep your AI SDK calls as they are. On ai 7, init() registers the official @ai-sdk/otel telemetry for you. On ai 5 and 6, each call keeps telemetry switched on. Each model call then arrives as a span with messages, model, tokens and a server-side cost. You can run Rius next to Langfuse while you compare, then remove Langfuse.
How it works
The Vercel AI SDK integration is TypeScript only. It reads the OpenTelemetry spans that the AI SDK produces, and the Rius SDK turns them into traces.
- On
ai7: the AI SDK no longer emits spans itself. They come from@ai-sdk/otel, which needs Node 22 or newer. With@glassflow-ai/rius0.6.0 or newer,init()registers it, so your application needs no telemetry code. - On
ai5 and 6: OpenTelemetry is built in but emits nothing unless a call opts in. You keepexperimental_telemetrywithisEnabledset to true on each call. Nothing else is installed, and any Node version from 18 works. - Cost: you never send a cost value. Rius computes it from the model and token counts, as a list-price estimate in US dollars.
- No double counting: each model call counts once in token and cost totals. The wrapper span still shows the run’s total.
This is the same swap the Langfuse migration guide describes for any setup: a change in where traces go, not a rewrite of your AI SDK calls. All integrations are listed under Integrations.
Set it up
-
Create a Rius workspace and an API key that starts with
ri_. Keep your Langfuse setup running for now. To run both in one process, setRIUS_BRIDGE_FOREIGN_PROVIDER=trueso the spans of Langfuse’s tracer provider also reach Rius, or compare in separate services. -
Install the Rius SDK. On
ai7, also install the telemetry package:npm install @glassflow-ai/rius @opentelemetry/api npm install @ai-sdk/otel -
Call
init()once at startup and keep your AI SDK calls unchanged. Onai7 this is all the tracing code you need: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 integration is attached 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 -
On
ai5 and 6, skip@ai-sdk/oteland keep per-call telemetry on:const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: 'Summarize this ticket', experimental_telemetry: { isEnabled: true }, }) -
Carry over sessions and users. A Langfuse session maps to a Rius session, and a Langfuse user maps to a Rius user. In TypeScript you set them with
withSessionandwithUser. -
Verify one request. Run a single
generateTextcall and open the trace in the console. The model call span shows the resolved model, token counts and a cost, nested under an agent span. Onai7,await rius.readylistsvercel-aiwhen the integration attached. Onai5 and 6 it does not list it even when tracing works. A short script must awaitrius.shutdown(), because the TypeScript SDK does not flush spans on exit. -
Cut over. Compare trace counts, token totals and cost for a few days. Then remove the Langfuse exporter or SDK and revoke the Langfuse keys once nothing sends to them. The migration overview covers running both backends side by side.
What you get
After the switch, each AI SDK call shows up in Rius with this structure:
- An agent span (
invoke_agent) wraps the steps of a tool-calling loop. Each step has its own span, each model call achatspan, and each tool execution anexecute_toolspan with its arguments and result. - Every model call carries its input and output messages, the request’s tool definitions, the resolved model and token usage. Usage includes cache reads and, since
@glassflow-ai/rius1.2.0, reasoning tokens. - Streamed calls carry time to first token.
- Cost per call is computed by Rius, so you can see spend per model, per session and per user.
- Your privacy controls apply to this integration.
captureContent: falseand amaskcover prompts, responses, tool definitions, the system prompt and tool call arguments and results.
On ai 5 and 6, image, speech and transcription calls are not traced, because they take no telemetry settings. On ai 7 they are traced.
Three things do not carry over from Langfuse. Rius has no scores, evals, datasets or prompt management. It is a managed service only, with no self-hosting. Existing Langfuse traces stay in Langfuse, and Rius starts from the first span you send.
When something else fits
- If you rely on scores, evals, datasets or prompt management, keep your current tool for those and send traces to both while you decide.
- If you need a self-hosted deployment, Rius does not fit, because it is a managed service only.
- If you need your historical traces in the new tool, Rius cannot import them, so keep the old tool for that history.