Getting started with the TypeScript SDK
The TypeScript SDK is split into a core runtime and integration packages. Start with the package that matches the app you are instrumenting.
- Source: prefactordev/typescript-sdk
- DeepWiki: prefactordev/typescript-sdk on DeepWiki
Choose a package
Section titled “Choose a package”| Package | Use it when | Reference |
|---|---|---|
@prefactor/core | You want the core runtime, manual spans, or your own wrapper layer. | Core API |
@prefactor/langchain | You are instrumenting LangChain applications. | LangChain package |
@prefactor/ai | You are instrumenting apps built on the Vercel AI SDK. | AI package |
@prefactor/claude | You are instrumenting Claude-specific agent flows. | Claude package |
@prefactor/openclaw-prefactor-plugin | You are integrating Prefactor into OpenClaw plugin workflows. | OpenClaw plugin |
Installation
Section titled “Installation”Install the package you need:
npm install @prefactor/langchainOr install a different package:
npm install @prefactor/corenpm install @prefactor/langchainnpm install @prefactor/ainpm install @prefactor/claudenpm install @prefactor/openclaw-prefactor-pluginQuick start
Section titled “Quick start”Most applications start with an integration package. This example uses the LangChain package:
import { init as initLangChain } from '@prefactor/langchain';
const middleware = initLangChain({ transportType: 'http', httpConfig: { apiUrl: process.env.PREFACTOR_API_URL!, apiToken: process.env.PREFACTOR_API_TOKEN!, agentIdentifier: '1.0.0', },});If you want manual instrumentation or your own wrapper layer, start with @prefactor/core:
import { createCore } from '@prefactor/core';
const prefactor = createCore({ transportType: 'http', httpConfig: { apiUrl: process.env.PREFACTOR_API_URL!, apiToken: process.env.PREFACTOR_API_TOKEN!, },});