LangChain Integration
Kaplaix provides zero-code adapters for LangChain in both TypeScript and Python. The adapters use LangChain’s callback system to automatically capture tool calls as Kaplaix events.
TypeScript
Installation
npm install @kaplaix/adapter-langchain-ts @kaplaix/sdk-tsPeer dependencies: @langchain/core >= 0.3.0, @langchain/langgraph >= 0.2.0
Usage
import { KaplaixClient } from "@kaplaix/sdk-ts";
import { KaplaixHandler } from "@kaplaix/adapter-langchain-ts";
const client = new KaplaixClient({ apiKey: "al_live_..." });
const session = client.session({ agentId: "my-langchain-agent" });
// Create the callback handler
const handler = new KaplaixHandler(session);
// Pass it to your LangChain agent
const result = await agent.invoke(
{ input: "What is the weather?" },
{ callbacks: [handler] },
);
await session.end();
await client.shutdown();The handler automatically emits tool_api events for every tool invocation, capturing tool name, arguments hash, and response status.
Python
Installation
pip install kaplaix-langchain kaplaixDependencies: kaplaix >= 0.1.0, langchain-core >= 0.3
Usage
from kaplaix import KaplaixClient
from kaplaix_langchain import KaplaixHandler
client = KaplaixClient(api_key="al_live_...")
with client.session(agent_id="my-langchain-agent") as session:
handler = KaplaixHandler(session)
result = agent.invoke(
{"input": "What is the weather?"},
config={"callbacks": [handler]},
)What gets captured
The LangChain adapter captures:
| LangChain event | Kaplaix category | Payload fields |
|---|---|---|
| Tool start/end | tool_api | toolName, argumentsHash, responseStatus |
Other framework adapters
Kaplaix also provides adapters for:
- LangGraph (
@kaplaix/adapter-langgraph-ts) — automatic event capture for LangGraph.js agents - CrewAI (
kaplaix-crewai) — Python adapter for CrewAI agents
These follow the same pattern: install the adapter, create a handler from a session, and pass it to your framework’s callback system.
Last updated on