or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

administration.mdassistants-threads.mdbatch-processing.mdbeta-realtime.mdchat-completions.mdconfiguration-management.mdcontainer-content.mdcore-client.mdembeddings.mdevaluation-testing.mdfeedback-collections.mdfile-management.mdfine-tuning.mdframework-integrations.mdindex.mdkey-management.mdmodels.mdmultimodal-apis.mdobservability-analytics.mdprompt-management.mdprovider-integration.mdtext-completions.mduploads.mdvector-stores.md

framework-integrations.mddocs/

0

# Framework Integrations

1

2

Pre-built integrations with popular AI frameworks including LangChain and LlamaIndex callback handlers.

3

4

## Capabilities

5

6

### LangChain Integration

7

8

```python { .api }

9

from portkey_ai.langchain import PortkeyLangchainCallbackHandler

10

11

class PortkeyLangchainCallbackHandler:

12

"""Callback handler for LangChain integration with Portkey observability"""

13

def __init__(

14

self,

15

api_key: Optional[str] = None,

16

base_url: Optional[str] = None,

17

**kwargs

18

): ...

19

```

20

21

### LlamaIndex Integration

22

23

```python { .api }

24

from portkey_ai.llamaindex import PortkeyLlamaCallbackHandler

25

26

class PortkeyLlamaCallbackHandler:

27

"""Callback handler for LlamaIndex integration with Portkey observability"""

28

def __init__(

29

self,

30

api_key: Optional[str] = None,

31

base_url: Optional[str] = None,

32

**kwargs

33

): ...

34

```

35

36

## Usage Examples

37

38

```python

39

# LangChain integration

40

from langchain.llms import OpenAI

41

from portkey_ai.langchain import PortkeyLangchainCallbackHandler

42

43

handler = PortkeyLangchainCallbackHandler(

44

api_key="PORTKEY_API_KEY"

45

)

46

47

llm = OpenAI(callbacks=[handler])

48

response = llm("What is AI?")

49

50

# LlamaIndex integration

51

from llama_index.core import SimpleDirectoryReader

52

from portkey_ai.llamaindex import PortkeyLlamaCallbackHandler

53

54

handler = PortkeyLlamaCallbackHandler(

55

api_key="PORTKEY_API_KEY"

56

)

57

58

# Use with LlamaIndex operations

59

```