Skip to Content

What does Rius record when my agent calls the Vercel AI SDK?

Rius records each Vercel AI SDK call as a trace with the input and output messages, the resolved model, tool definitions, and token usage, including cache reads and reasoning tokens. Cost is computed by Rius from the model and the tokens, so you never send it. An agent span wraps a tool-calling loop, with a span for each step, each model call, and each tool execution. The integration is TypeScript only.

How it works

The Vercel AI SDK produces the spans, and the Rius SDK turns them into the same shape for every ai version. What you see on a call:

  • Agent span. One invoke_agent span for each generateText, streamText, generateObject, or streamObject call. It wraps the steps of a tool-calling loop.
  • Model call span. A chat span for each model call, with its input and output messages, the resolved model, the finish reason, and token usage including cache reads and reasoning tokens.
  • Tool span. An execute_tool span for each tool execution, with the tool’s arguments and result. The request’s tool definitions are recorded on the model call.
  • Streaming. A streamed call carries time to first token.
  • Embeddings and reranking. Embedding calls get their own spans. A rerank call is a RERANKER span.
  • Cost inputs. The model and the token counts are what Rius prices. Cost is a list-price estimate in US dollars, not a billed amount.

On ai 7, the spans come from the official @ai-sdk/otel integration, which init() registers for you. On ai 5 and 6, OpenTelemetry is built in but emits nothing until a call opts in. Either way the call stores the same data.

Each model call is counted once in token and cost totals. The wrapper span, such as the agent span or an embed span, still shows the run’s total where the AI SDK reports one.

Your privacy controls apply to everything the integration produces. captureContent: false and a mask cover prompts, responses, tool definitions, the system prompt (gen_ai.system_instructions), and each tool call’s arguments and result (gen_ai.tool.call.arguments, gen_ai.tool.call.result).

Set it up

  1. On ai 7, install the telemetry package. It needs Node 22 or newer, the same floor as ai 7.

    npm install @ai-sdk/otel
  2. Initialize Rius before your calls. There is no telemetry code in your application on ai 7. For the full SDK setup, see the Vercel AI SDK integration page.

    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
  3. On ai 5 or 6, there is nothing to install. Turn telemetry on for each call. This works on any Node version the SDK supports, 18 or newer.

    const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: 'Summarize this ticket', experimental_telemetry: { isEnabled: true }, })
  4. Run one generateText call and open the trace in the console. The model call span shows the model, input and output token counts, and a cost, nested under an agent span. Wrap the call in observe to see it inside your agent’s run instead of as a standalone trace.

  5. If no spans appear on ai 7, check the process log. Rius warns at init() when it finds ai 7 without @ai-sdk/otel, because that combination produces no spans. When the integration attached, await client.ready lists vercel-ai. On ai 5 and 6 the usual cause is a call without experimental_telemetry: { isEnabled: true }, and client.ready does not list vercel-ai even when tracing works.

What you get

  • The prompt and response for every model call, the system prompt, and the tool definitions, subject to your privacy controls.
  • The resolved model and token usage, so each call has a cost estimate computed by Rius.
  • A readable tree of the run: agent span, steps, model calls, and tool executions with their arguments and results.
  • Time to first token on streamed calls.
  • Token and cost totals that count each model call once.

Known limits:

  • TypeScript only. The Python SDK has no Vercel AI SDK integration, because the library is JavaScript only.
  • Image, speech, and transcription calls on ai 5 and 6. These calls take no telemetry settings, so they are not traced. On ai 7 they are traced. A transcription span carries the provider’s token usage when the provider reports one. A speech span carries none when the provider returns only audio, as OpenAI’s speech endpoint does.
  • Spans sent without the Rius SDK. The once-only counting runs in the Rius SDK. @ai-sdk/otel spans sent to Rius without it are still counted twice. See Still counted twice for details.
  • Unknown models. A model that is not in the price catalog gets an empty cost, not zero.

When something else fits

If your agent runs in Python, the Vercel AI SDK integration does not apply, and the Integrations page lists the Python integrations and the manual generations you can use instead. If you need image, speech, or transcription calls traced and you are on ai 5 or 6, those calls are traced once you move to ai 7.

Still stuck? Get help

Last updated on