---
title: Getting started with the TypeScript SDK
description: Install the Prefactor TypeScript SDK and choose the package that
  matches your integration.
editUrl: true
head: []
template: doc
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

The TypeScript SDK is split into a core runtime and integration packages. Start with the package that matches the app you are instrumenting.

## Links

- Source: [prefactordev/typescript-sdk](https://github.com/prefactordev/typescript-sdk)
- DeepWiki: [prefactordev/typescript-sdk on DeepWiki](https://deepwiki.com/prefactordev/typescript-sdk)

## Choose a package

| Package | Use it when | Reference |
| --- | --- | --- |
| `@prefactor/core` | You want the core runtime, manual spans, or your own wrapper layer. | [Core API](/sdks/typescript-sdk/api/core) |
| `@prefactor/langchain` | You are instrumenting LangChain applications. | [LangChain package](/sdks/typescript-sdk/api/packages/langchain) |
| `@prefactor/ai` | You are instrumenting apps built on the Vercel AI SDK. | [AI package](/sdks/typescript-sdk/api/packages/ai) |
| `@prefactor/claude` | You are instrumenting Claude-specific agent flows. | [Claude package](/sdks/typescript-sdk/api/packages/claude) |
| `@prefactor/openclaw-prefactor-plugin` | You are integrating Prefactor into OpenClaw plugin workflows. | [OpenClaw plugin](/sdks/typescript-sdk/api/packages/openclaw-prefactor-plugin) |

## Installation

Install the package you need:

```bash
npm install @prefactor/langchain
```

Or install a different package:

```bash
npm install @prefactor/core
npm install @prefactor/langchain
npm install @prefactor/ai
npm install @prefactor/claude
npm install @prefactor/openclaw-prefactor-plugin
```

## Quick start

The SDK exposes three entry points. `init` from an integration package (such as `@prefactor/langchain`) returns middleware directly and is the right choice for most applications. `init` from `@prefactor/core` with a `provider` argument returns a `PrefactorClient` with access to `getMiddleware()`, `getTracer()`, and `shutdown()`. `createCore` from `@prefactor/core` is for manual instrumentation without a provider. Use the integration package `init` unless you need programmatic client access or custom spans.

Most applications start with an integration package. This example uses the LangChain package:

```typescript
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 prefer the full options surface — providers, transports, and manual span control — use `init` from `@prefactor/core` directly. See the [API overview](/sdks/typescript-sdk/api/overview) for examples.

If you want manual instrumentation or your own wrapper layer, start with `@prefactor/core`:

```typescript
import { createCore } from '@prefactor/core';

const prefactor = createCore({
  transportType: 'http',
  httpConfig: {
    apiUrl: process.env.PREFACTOR_API_URL!,
    apiToken: process.env.PREFACTOR_API_TOKEN!,
  },
});
```

## Next steps

- [TypeScript SDK API overview](/sdks/typescript-sdk/api/overview)
- [Core API](/sdks/typescript-sdk/api/core)
- [LangChain package](/sdks/typescript-sdk/api/packages/langchain)
- [AI package](/sdks/typescript-sdk/api/packages/ai)
- [Claude package](/sdks/typescript-sdk/api/packages/claude)
- [OpenClaw plugin](/sdks/typescript-sdk/api/packages/openclaw-prefactor-plugin)
- [Schemas and result schemas](/sdks/concepts-schemas)
- [Configuration and environment variables](/sdks/configuration)