@vane.build/langchain
v0.1.1
Published
LangChain callback handler that attests every tool call and LLM call to Vane
Readme
@vane.build/langchain
LangChain callback handler that sends a signed, tamper-evident attestation record to Vane for every LLM call, tool invocation, and agent action. Node 18+.
Installation
npm install @vane.build/langchainPeer dependency: @langchain/core >=0.2.0
Usage
import { ChatOpenAI } from '@langchain/openai';
import { VaneCallbackHandler } from '@vane.build/langchain';
const vane = new VaneCallbackHandler({
baseUrl: 'https://api.vane.build',
apiKey: process.env.VANE_API_KEY!,
agentId: 'contract-reviewer',
});
const llm = new ChatOpenAI({ callbacks: [vane] });
await llm.invoke('Summarise this contract.');
// → one "llm-call" record written to the Vane chainAttach the same handler to a full agent executor:
import { createReactAgent } from '@langchain/langgraph/prebuilt';
import { TavilySearchResults } from '@langchain/community/tools/tavily_search';
import { VaneCallbackHandler } from '@vane.build/langchain';
const vane = new VaneCallbackHandler({
baseUrl: 'https://api.vane.build',
apiKey: process.env.VANE_API_KEY!,
agentId: 'research-agent',
});
const agent = createReactAgent({
llm: new ChatOpenAI({ callbacks: [vane] }),
tools: [new TavilySearchResults()],
});
await agent.invoke(
{ messages: [{ role: 'user', content: 'What is the current EU AI Act status?' }] },
{ callbacks: [vane] },
);
// → one "llm-call" + one "agent-action" + one "tool-call" record per turnConstructor options
new VaneCallbackHandler({
baseUrl: string; // Vane API base URL, e.g. https://api.vane.build
apiKey: string; // Bearer token (Vane API key)
agentId: string; // Appears on every attestation record
companyId?: string; // If omitted, the API key's company is used
})What gets attested
| Event | actionType | Key payload fields |
|---|---|---|
| LLM call complete | llm-call | model, input, output, tokenUsage, durationMs |
| Tool call complete | tool-call | tool, input, output, durationMs |
| Agent picks a tool | agent-action | tool, toolInput |
Attestation is fire-and-forget. A failure to reach the Vane API logs to console.error and never interrupts agent execution.
