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

The Python SDK is split into small packages. Start with the package that matches how you want to integrate Prefactor.

## Links

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

## Choose a package

| Package | Use it when | Reference |
| --- | --- | --- |
| `prefactor-core` | Core client for agent instances, spans, schema registration, and wrapper authors. | [Reference](/sdks/python-sdk/api/core) |
| `prefactor-http` | Low-level async client for direct access to the Prefactor API. | [Reference](/sdks/python-sdk/api/http) |
| `prefactor-langchain` | LangChain integration package with middleware and LangChain-specific span types. | [Reference](/sdks/python-sdk/api/langchain) |
| `prefactor-livekit` | LiveKit integration package for tracing session and voice-agent events. | [Reference](/sdks/python-sdk/api/livekit) |

## Installation

Install the package you need:

```bash
pip install prefactor-langchain
```

Or install a different package:

```bash
pip install prefactor-core
pip install prefactor-http
pip install prefactor-livekit
```

## Quick start

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

```python
import os
from prefactor_langchain import PrefactorMiddleware

middleware = PrefactorMiddleware.from_config(
    api_url="https://app.prefactorai.com",
    api_token=os.environ["PREFACTOR_API_TOKEN"],  # never hardcode tokens
    agent_id="my-agent",
    agent_name="My Agent",
)
```

If you want to build your own wrapper or instrument code directly, start with `prefactor-core`:

```python
import os
from prefactor_core import PrefactorCoreClient, PrefactorCoreConfig
from prefactor_http import HttpClientConfig

config = PrefactorCoreConfig(
    http_config=HttpClientConfig(
        api_url="https://app.prefactorai.com",
        api_token=os.environ["PREFACTOR_API_TOKEN"],
    )
)

client = PrefactorCoreClient(config)
await client.initialize()
```

## Next steps

- [Python SDK API overview](/sdks/python-sdk/api/overview)
- [Prefactor Core](/sdks/python-sdk/api/core)
- [Prefactor HTTP Client](/sdks/python-sdk/api/http)
- [Prefactor LangChain](/sdks/python-sdk/api/langchain)
- [Prefactor LiveKit](/sdks/python-sdk/api/livekit)
- [Schemas and result schemas](/sdks/concepts-schemas)
- [Configuration and environment variables](/sdks/configuration)