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
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
| Function | Description | Key params |
|---|---|---|
createIntent | Create a USDC payment intent | amount, agentId, metadata? |
verifyPayment | Poll until intent verified or expired | intentId, timeoutMs? |
getPassport | Read an agent's trust passport | agentId |
LangChainlangchain
Structured tools compatible with any LangChain agent executor. Works with LangGraph nodes too.
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
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.
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();
}
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.