LangChainpylive · you pay per call

Freemium research agent, gated by x402

Chat for free to learn what it does; it charges only when it actually runs the research. The paywall sits inside the tool, not the route.

langchain-research-agent-py/
1 What you'll learn

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
2 How it works

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.

verifypermissions
tool bodythe research
settleburn credits
3 Under the hood
create_react_agentpayments-py[langsmith]@requires_paymentlanggraph devOpenAI gpt-4o-mini
# the token must sit here; the decorator reads it from the run
{
  "assistant_id": "research",
  "input": {"messages": [ ... ]},
  "config": {"configurable": {"payment_token": access_token}}
}
src/agent.pythe ReAct agent + the market_research tool, paid inner wrapped with @requires_payment
src/buyer.pyCLI buyer exercising the free path and the paid path back-to-back
langgraph.jsonwires the graph at graphs.research — no http.app, gating is in-graph
4 See it run
Freemium research agent, gated by x402

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.