How to charge for one capability while everything around it stays free.
- Wrap a LangChain @tool so it runs verify → work → settle on every paid call
- Let the LLM concierge answer "what can you do?" for free, and route only real work through payment
- Thread an x402 access token onto a run at config.configurable.payment_token
- Read the settlement receipt back and show the buyer credits burned and balance left
The @requires_payment decorator wraps the tool body with the canonical x402 lifecycle. The buyer's token rides on the run; the decorator finds it, verifies it, does the work, then settles credits — one round-trip.
No free question ever enters that path — the concierge LLM handles introspection itself, so only the paid tool touches the facilitator.
{
"assistant_id": "research",
"input": {"messages": [ ... ]},
"config": {"configurable": {"payment_token": access_token}}
}| src/agent.py | the ReAct agent + the market_research tool, paid inner wrapped with @requires_payment |
| src/buyer.py | CLI buyer exercising the free path and the paid path back-to-back |
| langgraph.json | wires the graph at graphs.research — no http.app, gating is in-graph |
Sandbox agent — real payment round-trips (402 → authorize → settle) with a per-session credit balance, no external service and no real money. Freemium: chatting is free; a research request runs the paid tool (5 credits) via the 402 → authorize → settle handshake. See the README to point this at a hosted LangGraph deployment with real card delegation.