HomeDocsAdapters › LangChain

LangChain Adapter

agent402-langchain

DynamicStructuredTool instances for LangChain agents and LangGraph nodes. Compatible with createReactAgent, createToolCallingAgent, and custom chains.

Install

npm install agent402-langchain

Quick start

import { agent402Tools } from "agent402-langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

const { tools } = await agent402Tools();

const agent = createReactAgent({
  llm: new ChatOpenAI({ model: "gpt-4o" }),
  tools,
});

const result = await agent.invoke({
  messages: [{ role: "user", content: "Hash 'hello world' with SHA-256" }],
});
console.log(result);

Configuration

OptionTypeDescription
categories string[] Filter tools by category.
slugs string[] Load only specific tools by slug.
baseUrl string Point to a self-hosted Agent402 instance.
agentKey string Private key for wallet-only (paid) tools.
// Filter tools by category.
agent402Tools({ categories: ["search", "gov"] })

// Load only specific tools by slug.
agent402Tools({ slugs: ["search", "answer"] })

// Point to a self-hosted Agent402 instance.
agent402Tools({ baseUrl: "https://my-agent402.example.com" })

// Private key for wallet-only (paid) tools.
agent402Tools({ agentKey: process.env.AGENT_KEY })

Works with

LangChain JS LangGraph createReactAgent createToolCallingAgent Any LangChain-compatible LLM