Skip to Content

How do I see the prompts and responses for calls to the Vercel AI SDK?

Rius shows the prompts and responses of every Vercel AI SDK call on the span for that model call, under the Input / Output tab of the trace. On ai 7, init() registers the tracing for you. On ai 5 and 6, you turn telemetry on for each call. Wrap the call in your own observe span only if you want it inside your agent’s run instead of as a standalone trace.

How it works

The Vercel AI SDK integration is TypeScript only. It reads the AI SDK’s own OpenTelemetry telemetry, so you add no tracing code around the call itself. Each call produces a small tree of spans:

  • An agent span (invoke_agent) wraps the steps of a tool-calling loop.
  • A chat span covers each model call. It carries the input and output messages, the request’s tool definitions, the resolved model, and token usage, including cache reads and reasoning tokens.
  • An execute_tool span covers each tool execution, with the tool’s arguments and result.
  • Streamed calls also carry time to first token.

The prompt and the response live on the chat span. Tool arguments and results live on the execute_tool spans. The AI SDK already creates those spans, so your tool functions need no extra wrapper.

Cost is computed by Rius from the model and the tokens, so you never send it. Each model call is counted once in token and cost totals, and the agent span still shows the run’s total.

What needs your own span is the context around the call. Without one, a single generateText call arrives as a standalone trace. Wrapping it in observe puts it inside your agent’s run, next to your other steps.

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 and wait for ready before the first call. init() registers the AI SDK integration, and ready makes sure it is in place. The wrapper below also adds your own span around the call. Name the function, because an anonymous one traces as anonymous. The full setup is on the Vercel AI SDK page.

    import { init, observe } 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 summarize = observe(async function summarize(ticket: string) { const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: ticket, }) return text }) await summarize('Summarize this ticket') await rius.shutdown() // export queued spans before the process exits
  3. On ai 5 and 6, nothing else is installed, but each call must opt in. Set isEnabled to true inside experimental_telemetry on every call, or that call emits no spans.

    const { text } = await generateText({ model: openai('gpt-4o-mini'), prompt: 'Summarize this ticket', experimental_telemetry: { isEnabled: true }, })
  4. Open Traces in the console and select the trace. In the waterfall, select the chat span for the model call, then open its Input / Output tab to read the prompt and the completion. The Model section of the same span shows the provider, resolved model, tokens and cost. For the full tour of the trace page, see Exploring traces.

  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. When the integration attached, await client.ready lists vercel-ai. On ai 5 and 6, client.ready does not list it even when tracing works, so look for a call missing isEnabled.

What you get

  • The prompt and the completion for each model call on its chat span, under Input / Output.
  • On an agent loop, Since previous llm call on that tab shows what each step added to the prompt, with each message marked added, removed or changed.
  • Tool arguments and results on each execute_tool span.
  • Token counts, cache reads, reasoning tokens and a cost estimate on the same span. Costs are list-price estimates in US dollars.
  • Your own observe span as the parent, so the call sits inside the run it belongs to.
  • Content that follows your privacy controls. captureContent: false and a mask apply to prompts, responses, tool definitions, the system prompt and tool call arguments and results. When content is stripped, the Input / Output tab says so, and timings, tokens and cost still show.

The AI SDK’s image, speech and transcription calls take no telemetry settings on ai 5 and 6, so they are not traced there. On ai 7 they are traced. A call that reports no token usage shows a blank cost rather than $0.

For the same view across the rest of your agents, see Monitor AI agents in production.

When something else fits

  • If your model calls go through another library, such as OpenAI, Anthropic or LangChain, use that library’s page in Integrations. Python code has no Vercel AI SDK integration, so trace those calls with manual generations.
  • If you do not want prompts and responses to leave your process, set captureContent to false and read structure, tokens and cost only.

Still stuck? Get help

Last updated on