Overview

Add payment capabilities to your LangChain applications using Paykit.

Installation

npm install @langchain/anthropic @langchain/core payman-paykit

Basic Setup

import { ChatAnthropic } from "@langchain/anthropic";
import { paykit } from 'payman-paykit';

// Initialize Paykit
const tools = paykit({
  apiSecret: process.env.PAYMAN_API_SECRET!,
  environment: process.env.PAYMAN_ENVIRONMENT as 'sandbox' | 'production'
});

// Setup LangChain model
const llm = new ChatAnthropic({
  model: "claude-3-sonnet-20240229",
  temperature: 0
});

async function callModel(userMessage: string) {
  const response = await llm.invoke([
    ["system", "You are a payment assistant that can help send money and manage transactions."],
    ["human", userMessage]
  ], {
    tools: tools
  });

  return response;
}

Environment Setup

ANTHROPIC_API_KEY=sk-ant-...
PAYMAN_API_SECRET=your_api_secret
PAYMAN_ENVIRONMENT=sandbox

Example Usage

const response = await callModel('Send $50 to John for consulting');

Next Steps