Installation
Make sure the AI SDK is installed:
Make sure the Voker TypeScript SDK is installed:
Voker does not currently support Audio, Video, or Image modalities.
Generate Text
Import the full ai namespace, pass it to wrapAiSdk(), and destructure the functions you want to track.
import { generateText } from 'ai';
import * as ai from 'ai';
import { wrapAiSdk } from '@voker/voker/ai/provider-aisdk';
const { generateText } = wrapAiSdk(ai);
await generateText({
vokerAgent: 'customer-support-agent', // required
vokerSession: 'user-session-1', // required
model: 'anthropic/claude-sonnet-4.5',
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
Stream Text
The AI SDK does not automatically record streamed steps. After streaming completes, send the generated steps using the base event creation API.
import * as ai from 'ai';
import { VokerClient } from '@voker/voker';
const { streamText } = ai;
const vokerClient = new VokerClient();
const s = streamText({
/* Existing streamText call */
});
s.steps.then((steps) => {
steps.forEach((step) => {
vokerClient.events.create({
vokerAgent: 'AGENT_NAME',
vokerSession: 'SESSION_ID',
eventName: 'llm',
properties: {
api: 'aisdk',
inputs: {
model: step.model,
request: step.request,
},
output: {
usage: step.usage,
response: step.response,
},
},
});
});
});
Next steps