Skip to main content

LangChain Integration

Coming Soon — LangChain integration is currently under development.

Overview

The MutagenT LangChain integration provides a callback handler that automatically traces all LLM calls in your LangChain applications.

Expected Installation

bun add @mutagent/langchain

Expected Usage

import { MutagentCallbackHandler } from '@mutagent/langchain';
import { ChatOpenAI } from '@langchain/openai';
import { ConversationChain } from 'langchain/chains';

// Create the callback handler
const handler = new MutagentCallbackHandler({
  apiKey: process.env.MUTAGENT_API_KEY,
});

// Use with any LangChain component
const llm = new ChatOpenAI({
  callbacks: [handler],
});

const chain = new ConversationChain({
  llm,
  callbacks: [handler],
});

// All calls are automatically traced
const response = await chain.invoke({
  input: 'What is the meaning of life?',
});

What Gets Tracked

  • LLM Calls: All ChatOpenAI, ChatAnthropic, etc. invocations
  • Chains: Chain execution with inputs/outputs
  • Agents: Agent steps and tool calls
  • Retrievers: RAG retrieval operations
  • Token Usage: Prompt and completion tokens
  • Latency: Request timing

Configuration Options

const handler = new MutagentCallbackHandler({
  apiKey: string,           // Required: MutagenT API key
  promptId?: string,        // Link traces to specific prompt
  sessionId?: string,       // Group related traces
  userId?: string,          // Associate with user
  metadata?: object,        // Custom metadata
});
[AI AGENT PLACEHOLDER: LANGCHAIN INTEGRATION WILL BE DOCUMENTED WHEN AVAILABLE]