Skip to main content
The ABV TypeScript SDK offers two setup approaches:
  1. Tracing for ABV Observability using OpenTelemetry
  2. Client for other ABV features like prompt management, evaluation, or accessing the ABV API

Tracing Setup

Installation

Install the relevant packages for a full tracing setup:
npm install @abvdev/tracing @abvdev/otel @opentelemetry/sdk-node
  • @abvdev/tracing: Core tracing functions (startObservation, startActiveObservation, etc.)
  • @abvdev/otel: The ABVSpanProcessor to export traces to ABV.
  • @opentelemetry/sdk-node: The OpenTelemetry SDK for Node.js.
Learn more about the packages here.

Register your credentials

Add your ABV credentials to your environment variables. Make sure that you have a .env file in your project root and a package like dotenv to load the variables.
ABV_API_KEY = "sk-abv-..."
ABV_BASE_URL = "https://app.abv.dev" # US region
# ABV_BASE_URL = "https://eu.app.abv.dev" # EU region

Initialize OpenTelemetry

The ABV TypeScript SDK’s tracing is built on top of OpenTelemetry, so you need to set up the OpenTelemetry SDK. The ABVSpanProcessor is the key component that sends traces to ABV.
instrumentation.ts
import { NodeSDK } from "@opentelemetry/sdk-node";
import { ABVSpanProcessor } from "@abvdev/otel";

const sdk = new NodeSDK({
  spanProcessors: [new ABVSpanProcessor()],
});

sdk.start();
The ABVSpanProcessor is the key component that sends traces to ABV.Modify instrumentation.ts file to use dotenv package to load the variables.Additional parameters are provided to get trace visible in the UI immediately.
npm install dotenv
instrumentation.ts
import dotenv from "dotenv";
dotenv.config();

import { NodeSDK } from "@opentelemetry/sdk-node";
import { ABVSpanProcessor } from "@abvdev/otel";

const sdk = new NodeSDK({
  spanProcessors: [
    new ABVSpanProcessor({
      apiKey: process.env.ABV_API_KEY,
      baseUrl: process.env.ABV_BASE_URL,
      exportMode: "immediate",
      flushAt: 1,
      flushInterval: 1,
      additionalHeaders: {
        "Content-Type": "application/json",
        "Accept": "application/json"
      }
    })
  ],
});

sdk.start();
Import the instrumentation.ts file at the top of your application.
index.ts
import "./instrumentation"; // Must be the first import
For more options to configure the ABVSpanProcessor such as masking, filtering, and more, see the advanced usage.You can learn more about setting up OpenTelemetry in your JS environment here.
If you are using Next.js, please use the OpenTelemetry setup via the NodeSDK described above rather than via registerOTel from @vercel/otel. This is because the @vercel/otel package does not yet support the OpenTelemetry JS SDK v2 on which the @abvdev/tracing and @abvdev/otel packages are based.See here for a full example for the Vercel AI SDK with NextJS on Vercel.

Client Setup

Installation

npm install @abvdev/client

Register your credentials

Add your ABV credentials to your environment variables. Make sure that you have a .env file in your project root and a package like dotenv to load the variables.
ABV_API_KEY = "sk-abv-..."
ABV_BASE_URL = "https://app.abv.dev" # US region
# ABV_BASE_URL = "https://eu.app.abv.dev" # EU region

Initialize the client

Initialize the ABVClient to interact with ABV. The client will automatically use the environment variables you set above.
client.ts
import { ABVClient } from "@abvdev/client";

const abv = new ABVClient();

Learn more

Cookbook: Instrumentation Advanced Usage