
Key Takeaways
Long-running agents can hit impediments mid-task: lacking access to an API, running out of AI service tokens, or missing an AI tool or service they need. Today the whole workflow stalls when a human needs to sign up, add a payment card, and paste in an API key.
Nevermined solves this by giving operators the ability to delegate a credit card to an agent, which comes with limits like how much the agent can spend and where it can spend it. This allows the agent to buy what it needs mid-task and keep running. No human in the loop, and it can’t spend past the caps you set. Agents can run autonomously as a result. This includes when an agent needs to top up on tokens.
API providers selling to agents can trace every payment on LangSmith and do not need new rails to autonomously sell to AI agents. Adding in the payment step with Nevermined and tracing with LangSmith means no additional payment infrastructure needed on your end to get going.
Overview
An agent is autonomous until it hits something it cannot buy. In this cookbook, we show how Nevermined empowers an agent built on LangChain, mid-task, to acquire web search credits, and then - after exhausting those credits - top up with more. The agent then needs data from a provider it was never wired to, discovers it, and buys access. Nevermined’s agentic payment infrastructure allows this all to be done with a credit card that only needs to be delegated and authorized once. The spend for the credit card is inside limits the agent cannot exceed, and every payment the service provider selling to the agent receives is traced on LangSmith.
This cookbook shows that with LangChain and Nevermined today you can let your agents buy what they need to keep working without a human in the loop, as opposed to stalling when a human is needed for payment. This is bound by a spending policy you set for your agent. The cookbook closes by showing how merchants selling services to agents can set up their own API to be purchased and provisioned autonomously to agents with every payment traced in LangSmith.
Why now
The agentic economy is alive and starting to scale. AI providers and labs, like Open AI and Anthropic, are moving away from traditional subscription based pricing to usage-based pricing. The cost of the service will be extensibly linked to consumption, and not the cost of the seat. The response on the buy side (ex: agents buying services) is consuming only what’s required, when required. The result is both pay-as-you-go as a more significant form of engagement, and microtransactions being front and center when payment for agent tools and services are needed.
- Market momentum is underway. Gartner projects machine customers will control up to $30 trillion in purchases by 2030, and agents will intermediate $15 trillion in B2B spend by 2028; McKinsey puts agent-mediated commerce at $3 to $5 trillion by 2030. Most of it is small, often sub-cent transactions (as of July 2026, the average agent payment is about $0.31) an agent makes to get past an impediment and keep working.
- Pricing that fits agents is taking over. Services are being repriced per unit of work, not just per seat: Intercom's Fin at $0.99 per resolution, Salesforce Agentforce at $2 per conversation, document processing around $0.10 per page. A flat fee model does not track that work, so heavy use breaks it: GitHub Copilot's $10 per month plan reportedly loses about $20 per user per month on the heaviest users.
- The commerce layer is the gap. AI agents are being engaged across many use cases, yet when it comes time to spend, the flow is still entirely human driven. Payment controls, both buy and sell side (ex: teams selling services to agents), remain manual. For example, on the buy side, a human still signs up for a service, manages the card and API keys themselves, and tops up the balance the agent spends. It is the same gap in front of every metered service an agent reaches for.
- The payment rails these agents use are converging. Despite still being early, many new solutions and protocols are emerging: x402, plus agent-payment support that Stripe, Visa Intelligent Commerce, Mastercard Agent Pay, PayPal, and Google's AP2 all shipped inside a single twelve-month window, converging to support agent self-serve payment flows.
- LangChain has already identified the importance of measuring agent spend. Having insight into coding-agent bills that run up unpredictably as the agent works is critical to measuring ROI, as well as making agentic spend predictable or optimized within a budget constraint. The next step is to action the spend an agent is authorized with by enabling payments.
Nevermined’s goal since inception has been to give every AI agent the ability to pay and be paid. This includes autonomously paying for agentic services. Being the market leader in the Agentic Commerce category, Nevermined will continue to leverage all new tooling and settlement mechanics agents can use across both existing and new rails.
Building an agent on a research deadline
The following is the recipe for enabling a research agent to do its job autonomously. In this case, a team spins up an agent in Fleet to pull together research across numerous information sources. In addition, the agent needs access to third party data and tools that it does not already have access to. With Nevermined, agent builders do not need to write additional code to ingest more tooling. Instead you can simply delegate a card once and set the limits. The scenario has four beats.
- Buy in. After the free tier credits for the Exa API are used the agent gets an alert to buy more, giving the ability to delegate a credit card that is used to buy a $7 block of additional Exa credits and then it continues researching.
- Burn through it. The agent fans out across sources. That $7 block is consumed at standard Exa rates, doing hundreds of requests or the equivalent of thousands of content pages, and a deep sweep drains it fast. This illustrates how fast agents can work when uninterrupted and shows the value of consumption based pricing. Nevermined notes, "an AI agent that processes 50,000 requests in an hour destroys the unit economics of any fixed-price plan."
- Top up. The credit balance hits zero and Exa returns 402 with NO_MORE_CREDITS. It still needs to use the API, so the agent tops ups and buys another $7 using the existing delegation and keeps going. This is the quantitative case: autonomous top-up.
- Purchase a net-new service. The research needs verified company data, the officers, registrations, and standing behind an entity, that general web search cannot return. That is a specialized source Exa does not provide directly. The agent discovers Baselayer, a provider that accepts agent payments the same way Exa does, buys access against the same delegation, and folds the result in. This is the qualitative case: it bought a capability it was never wired for.
This is not hypothetical. Exa and Baselayer accept autonomous agent payments in production today.
Letting agents buy what they need
When an agent can pay for what it hits, it stops stalling. You delegate a card once and set the limits, and the agent buys the credits and services it needs mid-task, always inside your caps. Agents can fully self-provision core APIs at instantiation and continue procurement of net-new services on the fly, as needs and requirements evolve. Here is how it looks in LangSmith Fleet:

During runtime, the agent needs to buy access to search. In this case Exa’s websearch API, so a delegation pop-up appears. You enter a credit card once, and it is saved for future purchases. The agent never sees the card number; it pays through x402.

The limits live in a spend policy you set once: a total budget, a time window that auto-stops, a per-purchase cap, and a transaction count. Nevermined enforces them server-side, before any money moves, so a large or unusual buy can pause for a human. This mitigates runaway spend; in Nevermined's words, "handing an agent a raw unbounded payment method makes the answer to 'how much can it spend?' equal to 'everything.' A delegation makes the answer exact: a cap, a clock, and an off switch." Most importantly, this is only needed once and then repeat and/or future purchases within the mandate do not require a human in the loop, allowing the agent to work uninterrupted.

Teams interested in embedding Nevermined credit card delegation can find details along with code samples here: https://nevermined.ai/docs/integrations/organization-widgets. The widget can be tested here: https://widgets.nevermined.dev/.
The instructions to add this to LangSmith Fleet via Nevermined MCP are as follows:

Now it runs. The agent buys Exa’s API, burns through the credits, and tops up on the same delegation, with no human in the loop. Then it discovers it needs Baselayer for verified company data and buys that too, against the same delegation.

Selling to agents autonomously
The same rails run in reverse: turn your own API or tool into something agents can buy and pay for on their own, per call, and see every payment in LangSmith. You can wire this up today. The process is remarkably simple, and includes connecting your existing PSP and configuring payment terms, whilst a lightweight payments SDK protects access to the API, MCP, tool, and/or agent being monetized. For discoverability, setting up/amending your llms.txt and creating a respective .md can be easily done. More and more, llms.txt is functioning as the shop window for agents where the respective .md is what they actually buy. The instructions for monetizing and protecting your API endpoint can be done as a decorator, or middleware on a route:
from payments_py.x402.langchain
import requires_payment
@requires_payment(payments=payments, plan_id=RESEARCH_PLAN_ID, credits=5) # 5 credits per call
@tool
def market_research(topic: str) -> str:
"""Premium lookup. Requires payment."""
return run_market_research(topic)Deep agents and subagents
The same decorator works unchanged on LangChain's Deep Agents harness. A deep agent delegates work through its built-in task tool, and the buyer's payment authorization travels with it so a paid tool can sit inside a subagent, one delegation hop from where the card was authorized, with no extra code:

That matters because delegation is the whole premise of the harness. If payment context didn't survive the hop, every paid capability would have to sit on the top-level agent. It survives so monetization is identical whether you're on create_react_agent or create_deep_agent.
It also makes your spending policy do more work. A deep agent decides for itself how many subagents a request warrants, so one user request can trigger several purchases. That is exactly what the cap, the clock, and the off switch are for: the delegation bounds the whole fan-out, not just one call.
All the details you need to get setup on LangChain can be found here: https://nevermined.ai/docs/integrate/add-to-your-agent/langchain and https://nevermined.ai/docs/integrate/add-to-your-agent/deep-agents. Setting up an API that agents can purchase autonomously and get paid is exactly what Exa and Baselayer did.
All the details you need to get setup on LangChain can be found here: https://nevermined.ai/docs/integrate/add-to-your-agent/langchain. Setting up an API that agents can purchase autonomously and get paid is exactly what Exa and Baselayer did.
Next, once you have your LangChain endpoint setup via Nevermined, you can see live traces. Simply set LANGSMITH_TRACING=true and each buy becomes its own subtree, because Nevermined emits the payment lifecycle, the verify and then the settle, into the trace. The same trace that shows the agent's reasoning shows when it spent, how much, and on what, which is the difference Nevermined draws "between knowing an agent is authorized and knowing how much the agent used."

Tracking traces allows for above-threshold buys to slot into a LangSmith annotation queue for human review. Additionally, the output can be graded by an LLM-as-judge, for example using LangChain's own trace judge and efficient-verifier work, to tie spend to quality.
Where this fits in LangChain
Card delegation can live wherever your team already manages access and spend. In LangChain, it may slot into billing or settings, entered once for an org and reused across its agents. In an integrations section, an integration your agents use can be not just connected but bought on the fly the moment an agent needs it. This includes a paywalled MCP server. It could also be added as a skill file to carry the delegation into any agent. And the tracing already runs on LangSmith today.
Recap and what’s next
The self-serve motion that grew SaaS - sign up, pay, expand - has no equivalent for agents yet. Credit card delegation gives every metered API, MCP, and/or tool a self-serve consumption path equivalent at the agent level: the agent provisions what it needs, inside a budget, and the provider's consumption grows without a human gating every dollar.
This cookbook illustrates clear ways agents can already buy and/or sell within LangChain. First, wire in card delegation so agents can buy what they need inside limits and run without stalling for a human. Second, after protecting your endpoint and setting it up to be monetized on LangChain, you can use LangSmith to trace the spend.
The websearch API example shown in this cookbook is just one of many tools that agents need and can not start acquiring autonomously. Going forward, every metered category an agent leans on, from inference to storage and sandboxes, ephemeral compute environments to enrichment services, voice, and identity, can become something the agent buys and a provider sells the same way - autonomously in real time and with safeguards to ensure spend is always within an operator’s mandates. This is how the agentic economy, which is already underway, continues to grow and evolve on LangChain with Nevermined.









.png)
