Vercel AI SDK
Trace Vercel AI SDK calls with axonPushMiddleware. The middleware hooks into the SDK’s experimental middleware API to capture LLM start, end, and streaming token events.
Installation
Section titled “Installation”npm install @axonpush/sdk aiimport { AxonPush } from "@axonpush/sdk";import { axonPushMiddleware } from "@axonpush/sdk/integrations/vercel-ai";
const client = new AxonPush({ apiKey: process.env.AXONPUSH_API_KEY!, tenantId: process.env.AXONPUSH_TENANT_ID!,});
const middleware = axonPushMiddleware({ client, channelId: 1, agentId: "my-agent",});import { generateText } from "ai";import { openai } from "@ai-sdk/openai";
const { text } = await generateText({ model: openai("gpt-4o"), prompt: "Explain quantum computing.", experimental_middleware: middleware,});Events Traced
Section titled “Events Traced”| Event | When |
|---|---|
llm.start | A model call begins |
llm.end | A model call completes |
llm.token | A streaming token is received |