Skip to content
xsAI

Record telemetry ​

Use the v0 telemetry extension to record text operation data.

This page describes the v0 API from v0.5.1. Use v0 package builds with these examples. Make sure that the service accepts the model ID and request protocol shown below.

sh
npm i @xsai-ext/telemetry@0.5.1

Usage ​

@xsai-ext/telemetry exports the core APIs from xsai.

In v0, telemetry supports generateText and streamText.

Replace the import as shown below.

diff
- import { generateText, streamText } from 'xsai'
+ import { generateText, streamText } from '@xsai-ext/telemetry'

Pass telemetry configuration to add attributes:

ts
const instructions = 'You\'re a helpful assistant.'

const { text } = await generateText({
  apiKey: env.OPENAI_API_KEY!,
  baseURL: 'https://api.openai.com/v1/',
  messages: [
    {
      content: instructions, 
      role: 'system'
    },
    {
      content: 'Why is the sky blue?',
      role: 'user'
    }
  ],
  model: 'gpt-4o',
  telemetry: { 
    attributes: { 
      'gen_ai.agent.description': instructions, 
      'gen_ai.agent.name': 'weather-assistant', 
    }, 
  }, 
})

xsAI Telemetry is based on GenAI Attributes.

Result ​

The extension records OpenTelemetry GenAI attributes for supported text operations.