SDKs
JS/TS SDK
TypeScript SDK - Setup
10 min
the abv typescript sdk offers two setup approaches typescript sdk setup /#tracing setup for observability & tracing docid\ l z5ltur bd4f7v9mqkrc using opentelemetry typescript sdk setup /#client setup for other abv features like prompt management, evaluation, or accessing the abv api tracing setup 1\) 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 typescript sdk overview docid\ j4sdnlmdmnfmk99ootgn7 2\) 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 3\) 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 for more options to configure the abvspanprocessor such as masking, filtering, and more, see typescript sdk advanced configuration docid\ luroohdawr0r3fi8oet5j you can learn more about setting up opentelemetry in your js environment here https //opentelemetry io/docs/languages/js/getting started/nodejs/ 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 https //github com/vercel/otel/issues/154 on which the @abvdev/tracing and @abvdev/otel packages are based typescript sdk instrumentation docid\ mncioxz2ar176rewhcuzp client setup 1\) installation npm install @abvdev/client 2\) 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 3\) 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(); alternative configure via constructor you can also pass configuration options directly to the constructor client ts import { abvclient } from "@abvdev/client"; const abv = new abvclient({ publickey "your public key", apikey "your api key", baseurl "https //app abv dev", // us region // baseurl "https //eu app abv dev", // eu region }); learn more cookbook abv js/ts sdk docid\ oz7ihyirza93rkj0uo7sx typescript sdk advanced configuration docid\ luroohdawr0r3fi8oet5j