Skip to main content
OpenBat supports four integration methods. Choose the one that fits your stack.
Never expose your API key in client-side code. Always use environment variables and keep your key on the server.

Installation

The Vercel AI SDK integration wraps your existing chat handler to automatically capture conversations.
npm install @openbat/vercel-ai
app/api/chat/route.ts
import { openBat } from '@openbat/vercel-ai';

const analytics = openBat({
  apiKey: process.env.OPENBAT_API_KEY,
});

export const POST = analytics.wrapHandler(async (req) => {
  // your existing AI SDK chat handler
});
This method automatically captures all messages, user metadata, and session context without changes to your existing code.

Metadata fields

You can send custom metadata with each conversation. Common fields include:
FieldTypeDescription
userIdstringYour internal user identifier
emailstringUser’s email address
organizationstringUser’s organization name
planstringUser’s subscription plan
mrrnumberMonthly recurring revenue
industrystringUser’s industry
OpenBat automatically discovers metadata fields sent from the SDK. You can track or deny discovered fields from the Analysis Config > Metadata tab.

Session context

The SDK automatically captures session context when running in a browser environment:
  • Browser and device type
  • Operating system
  • Page URL and referrer
  • Language
  • Country (via IP geolocation)
This data appears in the conversation detail sidebar under Session info.

Next steps

SDK reference

Full SDK documentation and advanced usage.

Manage metadata

Track and filter by custom metadata fields.

View conversations

Browse and filter your analyzed conversations.