Telemetry
xsAI Telemetry is experimental and may change in the future.
We may consider discontinuing Vercel AI SDK compatibility in the future and transitioning to full support for GenAI.
npm i @xsai-ext/telemetry
Usage
@xsai/telemetry
exports everything fromxsai
, so you can use it for overrides.Currently, telemetry only supports
generateText
andstreamText
.
Simply switch the import.
- import { generateText, streamText } from 'xsai'
+ import { generateText, streamText } from '@xsai-ext/telemetry'
You can also configure additional telemetry options:
import { generateText } from '@xsai-ext/telemetry'
import { env } from 'node:process'
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: {
metadata: {
agentId: 'weather-assistant',
instructions,
},
},
})