Adapters

@agentpayxyz/adapters is a single npm package with zero runtime dependencies. It ships adapters for the three most common agent frameworks. Pick what you use — you get payment intents, settlement verification, and AgentPassport trust queries as native tool/function calls.

npm install @agentpayxyz/adapters

Set your API key as an environment variable:

AGENTPAY_API_KEY=sk_live_...

OpenAI function callingopenai

Pass the AgentPay tools to any Chat Completions call. The adapter handles tool execution; your loop just processes the responses.

Register the tools

agent.ts
import OpenAI from 'openai';
import { openaiTools, executeOpenAITool } from '@agentpayxyz/adapters/openai';

const client = new OpenAI();
const agentpayKey = process.env.AGENTPAY_API_KEY!;

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Book the data cleaning job for $2.50' }],
  tools: openaiTools,           // createIntent, verifyPayment, getPassport
  tool_choice: 'auto',
});

for (const choice of response.choices) {
  const msg = choice.message;
  if (msg.tool_calls) {
    for (const call of msg.tool_calls) {
      const result = await executeOpenAITool(call, agentpayKey);
      console.log(result);
      // { intentId: 'intent_01J...', status: 'pending', depositAddress: '7vfC...' }
    }
  }
}

Available tools

FunctionDescriptionKey params
createIntentCreate a USDC payment intentamount, agentId, metadata?
verifyPaymentPoll until intent verified or expiredintentId, timeoutMs?
getPassportRead an agent's trust passportagentId

LangChainlangchain

Structured tools compatible with any LangChain agent executor. Works with LangGraph nodes too.

agent.ts
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
import { agentpayLangChainTools } from '@agentpayxyz/adapters/langchain';

const tools = agentpayLangChainTools(process.env.AGENTPAY_API_KEY!);

const llm = new ChatOpenAI({ model: 'gpt-4o', temperature: 0 });
const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });

const result = await executor.invoke({
  input: 'Create a payment intent for $5 to agent agt_01J...',
});
console.log(result.output);

LangGraph node

graph.ts
import { agentpayLangChainTools } from '@agentpayxyz/adapters/langchain';
import { ToolNode } from '@langchain/langgraph/prebuilt';

const tools = agentpayLangChainTools(process.env.AGENTPAY_API_KEY!);
const toolNode = new ToolNode(tools);

// Add toolNode to your StateGraph as a node

Vercel AI SDKai

Works with generateText, streamText, and the RSC streamUI helper.

app/api/chat/route.ts
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { agentpayVercelTools } from '@agentpayxyz/adapters/vercel';

const tools = agentpayVercelTools(process.env.AGENTPAY_API_KEY!);

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = streamText({
    model: openai('gpt-4o'),
    messages,
    tools,
    maxSteps: 5,
  });

  return result.toDataStreamResponse();
}
All adapters, one package

Every adapter in @agentpayxyz/adapters calls the same AgentPay API under the hood. Switch frameworks without changing your integration logic. Full API reference at api.agentpay.so.