Skip to main content

Overview

Moda integrates with the Vercel AI SDK via its built-in telemetry support. The AI SDK’s experimental_telemetry option emits telemetry data that Moda parses automatically, giving you conversation tracking, token usage, and analytics across all AI SDK providers.

Installation

Install additional provider packages as needed:

Quick Start

Streaming

streamText works the same way. Telemetry is captured after the stream completes:

Structured Output

generateObject responses are captured as JSON in the assistant message:

Tool Use

Tool calls made by the model are captured as structured content blocks:

Conversation Threading

When you set Moda.conversationId or Moda.userId before calling an AI SDK function, those values are automatically included in the telemetry metadata:
The getVercelAITelemetry() helper automatically includes moda.conversation_id and moda.user_id in the telemetry metadata when they are set.

Prompt Attribution

Render managed prompts before creating the telemetry config. Moda.getVercelAITelemetry() includes prompt metadata in experimental_telemetry.metadata.
Moda stores moda.prompt_key, moda.prompt_id, moda.prompt_version, and moda.prompt_version_id with the conversation logs, so the dashboard and future evals can compare behavior by prompt version.

Options Reference

Supported Providers

Any provider supported by the Vercel AI SDK works with Moda. The model and provider are automatically captured.

Troubleshooting

Data not appearing in Moda?
  • Ensure Moda.init() is called with await before your first AI SDK call
  • Call await Moda.flush() before your program exits
  • Verify your API key is correct
  • Enable debug mode: Moda.init('key', { debug: true })
Conversation IDs not grouping?
  • Make sure Moda.conversationId is set before calling Moda.getVercelAITelemetry()
  • The telemetry config is created at call time, so set the conversation ID first
Using with other Moda instrumentations?
  • If you also use Moda’s native OpenAI/Anthropic instrumentation, both will capture data. The AI SDK telemetry captures the high-level AI SDK call, while native instrumentation captures the underlying provider API call. This is safe but may result in duplicate entries. To avoid this, you can disable native instrumentation for providers used through the AI SDK.
For full SDK documentation, see the Node.js SDK guide.