What integration means
Integrating payments into LangGraph means two related things: letting a graph pay for what it calls (a paid API, a data source, another agent), and, when you want it, charging other callers for what the graph serves. The first is the common case; the second is the earn side, turning a graph into a paid service.
This page is the integration reference: the pieces, how they fit, and the one thing LangGraph lets you do that a flat agent does not. LangGraph is part of the LangChain ecosystem, so for the closely related overview see langchain-payment-integration, and for a sibling framework see crewai-payment-integration. The payment API product page is the broader reference. Here the focus is the shape of a LangGraph integration, including modelling payment as part of the graph.
Two runtimes, two paths
LangGraph ships in two runtimes, LangGraph.js in TypeScript and LangGraph in Python, and the payment packages are Node, so the pay side takes two paths. In LangGraph.js you are already in Node, so a tool calls createX402Client directly, in-process, with nothing extra to run. In Python LangGraph you call a small local Node proxy that holds the wallet, the same proxy used across the Python-framework integrations, because there is no Python payment package.
Both end up exposing the same wallet tool to the graph; only what sits under the tool differs. Knowing your runtime tells you which path to take, and the earn side (a gateway) and the graph-native patterns below are the same for both.
Pay inside a tool node
The simplest integration places a wallet tool in the graph's tool node. The tool wraps the x402 client (TS) or the proxy (Python), and the model calls it like any tool; the graph routes to the tool node, which runs it and settles the payment.
import { DynamicStructuredTool } from "@langchain/core/tools";
import { createClient } from "@blockchain0x/node";
import { createX402Client } from "@blockchain0x/x402/client";
import { z } from "zod";
const sdk = createClient({ apiKey: process.env.B0X_API_KEY! });
const fetchWithPay = createX402Client({ sdk });
export const walletTool = new DynamicStructuredTool({
name: "pay_and_fetch",
description: "Fetch a URL, paying in USDC if it requires payment. Returns the body.",
schema: z.object({ url: z.string() }),
func: async ({ url }) => {
const res = await fetchWithPay(url);
return res.ok ? await res.text() : `Failed: ${res.status}`;
},
});Put walletTool in your ToolNode and the graph can pay. To the graph it is an ordinary tool; the payment happens inside it, bounded by the wallet's spend limit. For many graphs this is all you need.
Payment as a graph node
Here is what LangGraph adds over a flat agent: because the graph is explicit, you can make payment its own node with conditional edges, rather than hiding it inside a tool call. This lets the graph reason about money as a first-class step, checking a budget before it pays and branching when the budget is gone.
Carry a running spend total or a remaining budget in the graph state. Before a paid call, route to a check node that reads the budget from state; a conditional edge sends the graph to the paying node when there is budget and to a fallback (ask a human, use a free source, stop) when there is not. After paying, update the spend total in state so the next check sees it. Concretely, a research graph given a one-dollar budget might pay for three sources, hit the cap on the fourth, and route to a "summarize what we have" node instead of paying again, all visible in the graph rather than buried in a tool. That visibility is what makes a runaway-spend bug obvious in LangGraph: the spending is a node you can see and test. The wallet's spend limit is still the hard backstop on chain, but modelling budget in the graph means the agent plans around cost deliberately instead of discovering the limit by hitting it. This explicit, inspectable money flow is the reason to reach for LangGraph specifically when payments matter to the control flow.
The earn side
To charge for what your graph serves, expose it over HTTP and front it with a small Node gateway running createX402Plugin. This is the same for both runtimes, since the gateway sits in front of whatever serves the graph.
import Fastify from "fastify";
import { createClient } from "@blockchain0x/node";
import { createX402Plugin } from "@blockchain0x/x402/server/fastify";
const sdk = createClient({ apiKey: process.env.B0X_API_KEY! });
const app = Fastify();
await app.register(createX402Plugin, {
sdk,
defaultNetwork: "testnet",
pricing: { "POST /graph/run": { amountUsdc: "0.10", payToAddress: process.env.B0X_PAYTO_ADDRESS!, paymentRequestId: "pr_graph" } },
});
app.post("/graph/run", async (req) => {
const r = await fetch("http://127.0.0.1:8000/run", { method: "POST", body: JSON.stringify(req.body) });
return await r.json();
});
await app.listen({ port: 8080 });An unpaid call gets a 402; a paid one runs the graph. Keep a free discovery route so callers can see what the graph does before paying.
Compatibility
The integration works across LangGraph's surfaces because it lives in a tool node (pay) or a gateway (earn), not in the framework internals.
| LangGraph surface | Works? | Notes |
|---|---|---|
ToolNode with a wallet tool |
Yes | The common pay path |
| Payment as a dedicated node | Yes | Conditional edges branch on budget in state |
| Budget in graph state | Yes | Read it at a node, update after paying |
| LangGraph.js vs Python | Both | TS calls the client directly; Python via a proxy |
| Earning from a graph | Yes | Front the endpoint with the Node gateway |
When this fits
The integration fits when a LangGraph app needs to pay for what it calls, when you want to charge for what it serves, or both. The graph-node pattern fits especially well when cost is part of the control flow, such as a graph that must stay within a budget across many steps, since LangGraph lets you make that logic explicit rather than implicit in a tool.
It fits less well when the graph never touches paid resources or when a single human-approved payment is the only money movement. For per-call machine payments where the flow itself should reason about spending, LangGraph's explicit graph is the framework that lets payment be a visible, controllable node.
Pricing
Integration is free; you build it from open packages. What you pay is the wallet platform fee per agent on the pricing page: Free is $0 per agent per month at a 5% transaction fee, Pro is $9 at 2%, Business is $29 at 1%. Per-agent pricing means each agent that transacts, paying or earning, is billed on its own wallet, so you pay for the agents that actually move money.
What to ship today
Put a pay_and_fetch wallet tool in your ToolNode (around createX402Client on LangGraph.js, around a proxy on Python) and make one paid call on Base Sepolia. If cost matters to the flow, add a budget to state and a check node with a conditional edge. To earn, front the graph with the Node gateway. For the LangChain-ecosystem overview see langchain-payment-integration. Pricing is on the pricing page.