Nevermined 通过允许操作员将信用卡委托给代理来解决这个问题,这种委托带有诸如代理可以支出多少以及可以在哪里使用的限制。这允许代理在执行任务过程中购买所需物品并继续运行。无需人工干预,并且不能超出您设置的上限。因此,代理可以自主运行。这包括当代理需要补充代币时。
向代理销售的 API 提供商可以在 LangSmith 上追踪每一笔付款,不需要新的路径即可自主向 AI 代理销售。将 Nevermined 的付款步骤与 LangSmith 的追踪结合起来意味着您无需额外的支付基础设施即可开始操作。
一个代理是自主的,直到它遇到无法购买的东西。在本教程中,我们展示了 Nevermined 如何使基于 LangChain 构建的代理在任务执行过程中获取网页搜索积分,然后在用完这些积分后进行补充。随后,代理需要从它之前未连接的数据提供商获取数据,它发现并购买了访问权限。Nevermined 的代理支付基础设施允许所有操作都使用一次委托和授权的信用卡完成。信用卡的消费在代理无法超出的限制范围内,而每笔服务提供商向代理收到的付款都会在 LangSmith 上被追踪。
本教程展示了使用 LangChain 和 Nevermined,您今天就可以让您的代理购买所需的物品以继续工作,而无需人工干预,而不是在需要人工付款时停滞不前。这受限于您为代理设定的支出政策。教程最后展示了向代理销售服务的商户如何设置自己的 API,以便被代理自主购买和配置,并且每笔付款在 LangSmith 中都被追踪。
代理经济正在兴起并开始规模化。像 Open AI 和 Anthropic 这样的 AI 提供商和实验室,正在从传统的订阅定价模式转向基于使用量的定价。服务的成本将与消耗量紧密相关,而不是座位成本。购买方(例如,代理购买服务)的反应是按需消费。结果是,按使用付费成为更重要的参与形式,同时微交易在支付代理工具和服务时成为核心环节。
自成立以来,Nevermined 的目标就是让每个 AI 代理都有支付和被支付的能力。这包括自主支付代理服务费用。作为代理商务类别的市场领导者,Nevermined 将继续利用所有新的工具和结算机制,让代理可以在现有和新的渠道上使用。
以下是让研究代理自主完成其工作的方案。在此示例中,一个团队在 Fleet 中启动一个代理,从众多信息源中收集研究资料。此外,代理还需要访问它尚未拥有的第三方数据和工具。使用 Nevermined,代理构建者无需编写额外代码来接入更多工具。你只需要授权一次卡片并设置限额。整个场景有四个步骤。
这并非假设。Exa 和 Baselayer 今天在生产环境中都接受自主代理的支付。
当代理可以为其访问的内容支付费用时,它就不会再停滞不前。你只要授权一次卡片并设置限额,代理就能在任务进行中购买所需的积分和服务,始终在你的限额之内。代理可以在实例化时完全自我配置核心 API,并根据需求和要求的变化,随时继续采购新的服务。在 LangSmith Fleet 中的实现如下:
在运行时,代理需要购买搜索访问权限。在此例中为 Exa 的网页搜索 API,因此会弹出授权窗口。你只需输入一次信用卡信息,它会被保存用于未来购买。代理永远看不到卡号;它通过 x402 支付。
这些限制存在于你设置的一次性消费策略中:总预算、自动停止的时间窗口、每次购买上限以及交易次数。Nevermined 在服务器端执行这些限制,在任何资金转移之前,因此一次大额或异常的购买可以暂停以等待人工介入。这可以减轻失控消费的风险;用 Nevermined 的话说,“给代理一个原始的无限支付方式,‘它能花多少?’的答案就是‘所有。’而委托的答案是精确的:一个上限、一个时间表,以及一个关闭开关。” 最重要的是,这只需设置一次,以后在授权范围内的重复和/或未来购买无需人工参与,使代理可以不间断工作。
有兴趣嵌入 Nevermined 信用卡委托的团队可以在此找到详情及代码示例:https://nevermined.ai/docs/integrations/organization-widgets:https://nevermined.ai/docs/integrations/organization-widgets。该小部件可以在此测试:https://widgets.nevermined.dev/:https://widgets.nevermined.dev/。
将其通过 Nevermined MCP 添加到 LangSmith Fleet 的说明如下:
现在它运行了。代理购买了 Exa 的 API,用完了积分,并在同一个委托下充值,无需人工参与。然后它发现需要 Baselayer 以获得验证的公司数据,并同样根据同一委托进行购买。
同样的流程也可以逆向操作:将你自己的 API 或工具变成代理可以按调用自行购买和支付的对象,并在 LangSmith 中查看每笔付款。你今天就可以连接起来。这一过程非常简单,包括连接现有的支付服务提供商 (PSP) 并配置支付条款,同时一个轻量级支付 SDK 可以保护对要货币化的 API、MCP、工具和/或代理的访问。为了便于发现,设置或修改你的 llms.txt 并创建相应的 .md 文件可以轻松完成。越来越多情况下,llms.txt 充当了代理的展示窗口,而相应的 .md 文件才是他们实际购买的内容。货币化和保护你的 API 端点的说明可以通过装饰器或路由中的中间件来实现:
同一个装饰工具在LangChain的Deep Agents框架上保持不变。Deep Agent通过其内置任务工具授权工作,买家的付款授权随之转移,因此付费工具可以放置在一个子代理中,距离卡片授权地点仅一个委托跳,无需额外代码:
这很重要,因为委派是该工具框架的核心。如果支付上下文未能通过跳跃存活,所有付费能力都必须放在顶层代理上。它得以存续,所以无论你在create_react_agent还是在create_deep_agent,变现都是一样的。
这也让你的支出政策发挥更多作用。深度客服自行决定请求需要多少次代理,因此一个用户请求可能触发多次购买。这正是上限、时钟和关闭开关的作用:委托限制整个扇出,而不仅仅是一次通话。
LangChain 的所有设置细节都可以在这里找到:https://nevermined.ai/docs/integrate/add-to-your-agent/langchain:https://nevermined.ai/docs/integrate/add-to-your-agent/langchain 和 https://nevermined.ai/docs/integrate/add-to-your-agent/deep-agents:https://nevermined.ai/docs/integrate/add-to-your-agent/deep-agents。设置一个 API 让代理可以自主购买并获得报酬,正是 Exa 和 Baselayer 所做的。
所有在 LangChain 上设置所需的详细信息都可以在这里找到:https://nevermined.ai/docs/integrate/add-to-your-agent/langchain:https://nevermined.ai/docs/integrate/add-to-your-agent/langchain。设置一个 API 让代理可以自主购买并获得报酬,正是 Exa 和 Baselayer 所做的。
接下来,一旦你通过 Nevermined 设置好 LangChain 端点,你就能看到实时跟踪。只需设置 LANGSMITH_TRACING=true,每次买入就变成独立的子树,因为 Nevermined 向跟踪中输出支付生命周期、验证和结算。显示代理推理的同一条跟踪显示了何时、花了多少钱以及花了什么,这也是 Nevermined 区分“知道代理被授权和知道代理使用了多少”之间的区别。
追踪踪迹允许超过阈值的购买进入 LangSmith 注释队列进行人工审核。此外,输出可以由 LLM 作为裁判进行评分,例如使用 LangChain 自身的 trace judge:https://www.langchain.com/blog/building-a-100x-cheaper-trace-judge-with-fireworks 以及 efficient-verifier:https://www.langchain.com/blog/designing-efficient-verifiers-for-legal-agents 工作,将支出与质量联系起来。
卡片授权可以存在于团队已经管理访问和支出的任何地方。在 LangChain 中,它可能位于计费或设置中,输入一次即可用于整个组织并在其所有代理中重复使用。在集成部分,您的代理使用的集成不仅可以连接,还可以在代理需要时即时购买。这包括付费的 MCP 服务器。它也可以作为技能文件添加,以将授权带入任何代理中。同时,追踪功能今天已经在 LangSmith 上运行。
本手册展示了在 LangChain 中代理已经可以购买和/或出售的明确方式。首先,接入卡片授权,以便代理可以在限制内购买所需内容,并在无需人工干预的情况下运行。其次,在保护您的端点并设置为在 LangChain 上实现货币化之后,您可以使用 LangSmith 来追踪支出。
本手册中展示的 websearch API 示例只是代理所需的众多工具之一,而这些工具代理无法自主获取。未来,代理依赖的每个计量类别,从推理到存储和沙箱、临时计算环境到增强服务、语音和身份,都可以成为代理购买、供应商出售的对象——同样可以实时自主进行,并通过安全措施确保支出始终在操作员授权范围内。这就是代理经济已经开始的方式,并且在 LangChain 上与 Nevermined 一起不断增长和演变。
LangSmith 是我们的代理工程平台,帮助开发者调试每个代理决策、评估更改,并一键部署。
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.
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.
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.
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.
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.
This is not hypothetical. Exa and Baselayer accept autonomous agent payments in production today.
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:https://nevermined.ai/docs/integrations/organization-widgets. The widget can be tested here: https://widgets.nevermined.dev/: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.
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:
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:https://nevermined.ai/docs/integrate/add-to-your-agent/langchain and https://nevermined.ai/docs/integrate/add-to-your-agent/deep-agents: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: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:https://www.langchain.com/blog/building-a-100x-cheaper-trace-judge-with-fireworks and efficient-verifier:https://www.langchain.com/blog/designing-efficient-verifiers-for-legal-agents work, to tie spend to quality.
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.
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.
LangSmith, our agent engineering platform, helps developers debug every agent decision, eval changes, and deploy in one click.