官方更新 AWS ML Blog Thu, 08 Oct 2026 正文 ok 1701 words

面向 AI Agent 的按次推理付费:BlockRun 与 Incarna 如何使用 Amazon Bedrock AgentCore payments

英文标题:Pay-per-inference for AI agents: How BlockRun and Incarna use Amazon Bedrock AgentCore payments

Amazon Bedrock AgentCore payments 为 AI Agent 提供托管式按需支付能力,并由基础设施而非模型本身强制执行支出上限。Incarna 通过该服务,让其 Agent 能够经由 x402 协议按每次请求向 BlockRun 支付模型推理费用。该团队将接入 x402 支付的工作量从原计划的两到三个月缩短至三天,仅编写约 200 行应用代码。在 Beta 阶段,Agent 已完成超过 1,000 笔链上独立结算的支付,每次费用介于 0.001 美元至 0.05 美元之间。
打开原文相关 2.7 · 机会 2
media1.3 MB media1.3 MB media2.4 KB media345.0 KB media141.2 KB media346.5 KB media95.7 KB media19.0 KB media25.2 KB media22.7 KB media64.1 KB

中文

当 AI Agent 运行时,往往需要购买某项服务才能完成任务:一次模型推理、一次 API 响应、访问网页内容,或调用另一个 Agent。这些采购金额小、频率高,有时每笔仅为几分之一美分;它们发生在 Agent 的循环中,且没有人工可供审批。

Amazon Bedrock AgentCore payments消除了这一负担。它为 Agent 提供托管式按需支付方式,并由基础设施而非模型来执行支出限制。本文将介绍 Incarna 如何使用 AgentCore payments,让其 Agent 按每次请求向 BlockRun 支付模型推理费用。BlockRun 是一个按量付费的推理路由器,通过 x402 提供来自超过 15 家供应商的 90 多种模型;每次调用均被独立报价和结算。AgentCore payments 可与兼容 x402 的端点配合使用,包括 Amazon Bedrock 推理端点。借助该服务,Incarna 团队将增加 x402 支付支持所需的工作从数月缩短至数天,并将端到端的按次推理付费流程投入生产环境。

挑战:按请求支付推理费用

按次推理付费是一种高频、低价值的模式。一个 Agent 在单次会话中可能进行数百笔小额采购,每笔价值仅为几分之一美分。银行卡网络并非为亚美分支付而设计。自建支付基础设施意味着必须同时解决多个难题:确定资金存放位置和每笔付款如何签名,支持 x402 等新兴支付协议,并防止自主 Agent 过度支出。

AgentCore payments 提供什么

Amazon Bedrock AgentCore 是一个用于大规模构建、连接和优化 Agent 的平台,支持任意框架或模型。AgentCore payments 是 Amazon Bedrock AgentCore 的一项托管能力,开发者可以通过几行代码为 Agent 添加支付功能。它负责处理支付协议、连接钱包、签署交易,以及执行支出限制。开发者只需集成一项托管服务,而不必自行组装这些组件。以下特性使其特别适合按次推理付费:

  • 托管钱包。 Incarna 使用 Coinbase CDP 连接器为每个 Agent 配置钱包。客户拥有该钱包,并授予 Incarna 使用该钱包的委托授权。
  • 原生协议处理。 当付费端点返回 HTTP 402(“需要付款”)时,Agent 会使用 AgentCore payments 通过 x402 完成支付。它使用已配置的钱包签署交易,并向商家返回加密证明。
  • 基础设施层面的支出治理。 AgentCore payments 在模型之外强制执行限制,因此即使 Agent 的提示词被操纵,它也无法超出限制。
  • 可审计的结算。 支付以稳定币结算。Incarna 在 Base 网络上使用 USDC,每笔交易均可在链上验证。

下图展示了端到端架构。AgentCore 运行 Agent,BlockRun 提供按量计费的推理服务,而 AgentCore payments 连接客户钱包、执行支出上限,并代表 Agent 的 Incarna 身份签署每笔付款。

架构图:Agent 请求经由 AgentCore 流向 BlockRun,AgentCore payments 使用 Agent 自身钱包签署 x402 支付

图 1:按次推理付费架构。Agent 请求经由 AgentCore 流向 BlockRun(HTTP 402),AgentCore payments 使用 Agent 自身钱包签署 x402 支付。

来源:incarna.io/aws-blockrun-incarna-partnership

前提条件

Incarna 所采用的路径也向其他团队开放,AgentCore payments 可以为你配置所需组件。你可以通过 AWS Agent Toolkit 中的 AgentCore payments skill 进行引导式对话完成设置,该工具支持 Claude Code、Kiro 或 Codex。你也可以使用 AgentCore CLI、AgentCore SDK 或 AWS SDK 自行创建各个组件。

首先,将 Coinbase CDP 或 Stripe Privy 凭证存储为支付凭证提供商,这会将密钥保存在 AWS Secrets Manager 中,而不是写入代码。创建一个 Payment Manager 和连接器,以基于这些凭证协调支付,并同时设置默认支出上限。随后创建支付工具,即 Agent 用于付款的嵌入式钱包。最终用户为其注资,并通过重定向 URL 授予签名权限;在测试网络上,你可以使用测试网 USDC 为其注资。

流程:买卖一次推理服务

在此集成中,BlockRun 是卖方。BlockRun 从实时目录中提供按量计费的模型推理,每次调用均独立完成报价、支付和结算。一次推理的流程很直接:

  1. Agent 需要调用模型。它集成 BlockRun,后者负责供应商选择和交付,无需订阅每家供应商的服务。
  2. BlockRun 返回 PaymentRequired 挑战以及该次调用的价格。
  3. Agent 打开支付会话并调用 ProcessPayment。AgentCore payments 会根据会话设置的支出上限检查报价,并从 Agent 自身的钱包地址签署授权。
  4. 卖方验证支付签名。
  5. BlockRun 提供推理服务并记录收费,即一笔按调用计的小额费用。

由于结算按请求进行,Agent 只需为实际使用的服务付费;如果 Agent 决定不发起某次调用,则不会产生任何成本。

AgentCore payments 支持两种 x402 支付方案:exact 和 upto。当价格预先已知时,通常使用 exact 方案。upto 方案适用于动态定价资源。Agent 授权一个最高金额,推理服务提供商在结束时根据实际使用量结算,但不会超过该上限。

控制支出

让开发者能够放心让 Agent 动用真实资金的关键在于支付会话。会话设定一个上限,即 Agent 最多可以支出的金额,AgentCore payments 会在基础设施层面执行这一上限。Agent 自身的代码和提示词均无法修改它。每个会话还包含过期时间,Incarna 将其会话设置为一天的预算。如果 Agent 逻辑出现问题,它仍无法超过客户设定的限额进行支出。即使当前未使用会话级预算的集成,也可以在不修改代码的情况下采用该机制。有关这些控制措施的更多信息,请参阅 通过内置护栏实现安全的 Agent 支付。

结果

Incarna 已在 Base 上将按次推理付费流程投入生产环境,BlockRun 负责卖方服务,AgentCore payments 则治理每一笔交易。

“下一代 AI Agent 不应在更高性能与可持续的经济性之间被迫做出选择。BlockRun 的开源路由器让开发者能够完全掌控自己的模型集合,同时持续受益于 BlockRun 基于基准测试不断改进的路由能力——以更低的 Token 成本带来更高的任务成功率。借助 AgentCore payments 和 x402 提供的 Agent 所需支出控制能力,这种智能便能在现实世界中安全地发挥作用。”

— BlockRun 创始人 Vicky Fu

Incarna 团队在三天内完成了完整的 AgentCore payments 集成:一天用于开发,两天用于测试。这大约涉及 200 行应用代码,而最初预计需要两到三个月。在 Beta 阶段,Agent 已处理超过 1,000 笔付款,每次调用的费用范围为 0.001 美元至 0.05 美元,每笔均在链上独立结算。

“AgentCore payments 覆盖了 Agent 通过 x402 支付所需的一切:客户拥有的钱包、资金注入和撤销流程、由平台执行的支出上限,以及同时处理两个版本 x402 的签名能力。我们一行都没写。”

— Incarna 创始人 Justin Zhou

结论

AgentCore payments 为 Agent 提供了一种受治理的按需支付方式,用于购买其使用的服务。BlockRun 和 Incarna 展示了端到端流程如何协同工作:Agent 为推理服务付款,供应商进行计量和结算,而身份主体拥有该笔交易。如果你正在构建需要在运行过程中购买服务的 Agent,可以通过 AgentCore payments 这一个受治理的集成入口添加该能力。

入门指南

准备为你的 Agent 添加按次推理付费功能了吗?以下是开始方法:

  1. 设置 AgentCore payments。 使用钱包连接和支出策略创建 Payment Manager。将 Coinbase CDP 钱包作为你的凭证提供商进行连接。有关分步说明,请参阅 AgentCore payments 开发者指南。
  2. 使用预算开启支付会话。 在 Agent 开始任务之前,创建一个符合该工作负载需求的支出上限会话。Agent 在此上限内进行交易,基础设施将负责执行限制。
  3. 调用付费端点。 将你的 Agent 指向兼容 x402 的服务,例如 BlockRun。当端点返回 HTTP 402 时,使用支付详细信息调用 ProcessPayment。AgentCore payments 会处理签名,并返回 Agent 可用于访问服务的证明。

如需查看代码,请参阅 GitHub 上的 AgentCore payments 示例。

了解更多

关于 BlockRun 和 Incarna

BlockRun 是一个按量付费的推理路由器,通过 x402 支付协议提供模型推理服务。Agent 可通过单一的按量计费端点访问实时模型目录。每次调用均在 Base 上以 USDC 独立完成报价、授权、支付和结算。BlockRun 负责供应商选择和交付,因此 Agent 只需一次集成,即可访问众多模型,无需与每家供应商单独订阅或建立计费关系。

Incarna 由 SpreadX 构建,为 AI Agent 提供跨会话、模型和运行时持续存在的身份。每个身份均拥有自己的钱包、电子邮件地址、社交账户和操作历史,并在多次运行中始终关联至同一个 ID。当 Agent 为服务付费时,链上付款方是 Agent 自身的身份,而非共享的平台密钥,因此每笔交易都可归属于一个持久的单一实体。Incarna 已在 Base 主网上线,并进行真实结算。


关于作者

Peter Jiang

Peter 是 AWS 的高级软件开发工程师,常驻美国华盛顿州西雅图。他是 Amazon Bedrock AgentCore payments 计划背后工程团队的核心成员,该计划旨在为 AI Agent 提供支付能力。Peter 在金融和支付行业拥有超过 8 年经验,曾推出多个涵盖银行、加密货币和 Agent 系统的从零开始项目。此前,他曾在 Susquehanna International Group 从事超低延迟交易系统工作。

Guy Bachar

Guy 是 AWS 的高级解决方案架构师,与金融科技和资本市场公司合作,专注于 Agentic AI、自主商业和云转型。他专注于构建让 AI Agent 能够代表客户在支付、客户体验和治理等领域采取行动的系统。

Chethan Shriyan

Chethan 是 AWS 的首席技术产品经理,常驻美国华盛顿州西雅图。他在产品和业务管理领域拥有近 13 年经验,其中超过 7 年任职于 Amazon。他热衷于构建和交付能够为客户生活带来有意义影响的技术产品。

English / 原文

When an AI agent runs, it often needs to buy something to finish a task: a model inference, an API response, access web content, or a call to another agent. These purchases are small and frequent, sometimes a fraction of a cent each, and they happen inside the agent’s loop with no person available to approve them.

Amazon Bedrock AgentCore payments removes that burden. It gives agents a managed way to pay for services on demand, with spending limits enforced by the infrastructure rather than by the model. In this post, we look at how Incarna used AgentCore payments to let its agents pay BlockRun for model inference one request at a time. BlockRun is a pay-as-you-go inference router serving more than 90 models from more than 15 providers over x402, each call quoted and settled independently. AgentCore payments works with x402-compatible endpoints, including Amazon Bedrock inference endpoints. With the service, the Incarna team cut the work of adding x402 payment support from months to days, and put an end-to-end pay-per-inference flow into production.

The challenge: Paying for inference by the request

Paying per inference is a high-frequency, low-value pattern. An agent might make hundreds of small purchases in a single session, each worth a fraction of a cent. Card networks weren’t built for sub-cent payments. Building your own rails means solving several hard problems at once. You must decide where the money is held and how each payment is signed, support emerging payment protocols such as x402, and keep an autonomous agent from overspending.

What AgentCore payments provides

Amazon Bedrock AgentCore is a platform to build, connect, and optimize agents at scale, with any framework or model. AgentCore payments is a managed capability of Amazon Bedrock AgentCore that builders can use to add payments to their agents in a few lines of code. It handles the payment protocol, connects to a wallet, signs the transaction, and enforces spending limits. Builders integrate through one managed service instead of assembling the parts on their own. A few things make it a good fit for pay-per-inference:

  • Managed wallets. Incarna provisions each agent’s wallet using the Coinbase CDP connector. The customer owns it and grants Incarna a delegated authorization to use the wallet.
  • Native protocol handling. When a paid endpoint answers with HTTP 402 (“Payment Required”), the agent uses AgentCore payments to make the payment over x402. It signs the transaction with the configured wallet and returns cryptographic proof to the merchant.
  • Spending governance at the infrastructure layer. AgentCore payments enforces limits outside the model, so an agent can’t exceed them even if its prompt is manipulated.
  • Settlement you can audit. Payments settle in a stablecoin. Incarna uses USDC on the Base network, and each transaction is verifiable on-chain.

The following diagram illustrates the end-to-end architecture. AgentCore runs the agent, BlockRun serves metered inference, and AgentCore payments connects to the customer’s wallet, enforces the spending limit, and signs each payment on behalf of the agent’s Incarna identity.

Architecture diagram: an agent request flows through AgentCore to BlockRun, with AgentCore payments signing the x402 payment from the agent’s own wallet

Figure 1: Pay-per-inference architecture. Agent request flows through AgentCore to BlockRun (HTTP 402), with AgentCore payments signing the x402 payment from the agent’s own wallet

Source: incarna.io/aws-blockrun-incarna-partnership

Prerequisites

The path Incarna followed is open to other teams, and AgentCore payments provisions the pieces for you. You can set them up through a guided conversation with the AgentCore payments skill in the Agent Toolkit for AWS (in Claude Code, Kiro, or Codex). You can also create each one yourself with the AgentCore CLI, the AgentCore SDK, or the AWS SDK.

Start by storing your Coinbase CDP or Stripe Privy credentials as a payment credential provider, which keeps the secrets in AWS Secrets Manager instead of your code. Create a Payment Manager and connector to coordinate payments against those credentials, and set a default spending limit while you’re there. Then create a payment instrument, the embedded wallet the agent pays from. The end user funds it and grants signing permission through a redirect URL, and on a test network you can fund it with testnet USDC.

The flow: Buying and selling one inference

In this integration, BlockRun is the seller. BlockRun serves metered model inference from a live catalog, and each call is quoted, paid, and settled on its own. The flow for a single inference is straightforward:

  1. The agent needs a model call. It integrates with BlockRun, which handles provider selection and delivery. No per-provider subscription required.
  2. BlockRun answers with PaymentRequired challenge and a price for that specific call.
  3. It opens a payment session and calls ProcessPayment. AgentCore payments checks the quote against the spending limits set for the session and signs the authorization from the agent’s own wallet address.
  4. The seller verifies the payment signature.
  5. BlockRun serves the inference and records the charge, a small per-call amount.

Because settlement happens per request, the agent pays only for what it uses, and a call the agent chooses not to make costs nothing.

AgentCore payments supports two x402 payment schemes: exact and upto. The exact scheme is usually used when the price is known up front. The upto scheme suits resources with dynamic pricing. The agent authorizes a ceiling amount, and the inference provider settles for actual usage at the end, up to that ceiling.

Keeping spend under control

The piece that makes builders comfortable letting an agent move real money is the payment session. A session sets a ceiling, the most the agent can spend, and AgentCore payments enforces that ceiling at the infrastructure layer. The agent’s own code and prompt can’t change it. Each session also carries an expiry time, and Incarna sizes its sessions to a day’s budget. If something goes wrong in the agent’s logic, it still can’t spend past the limit the customer set. Even integrations that don’t use session-level budgets today can adopt it without code changes. For more on how these controls work, see Enable safe agentic payments with built-in guardrails.

Results

Incarna put the pay-per-inference flow into production on Base, with BlockRun serving the sell side and AgentCore payments governing every transaction.

“The next generation of AI agents shouldn’t have to choose between better performance and sustainable economics. BlockRun’s open source router gives developers full control over their own model set, while continuously benefiting from BlockRun’s ongoing benchmark-driven routing improvements—delivering higher task success rates at lower token cost. And with AgentCore payments and x402 providing the spending controls agents need, that intelligence can be put to work safely in the real world.”

— Vicky Fu, Founder, BlockRun

The Incarna team completed the full AgentCore payments integration in three days: one to build and two to test. That was roughly 200 lines of application code, against the two to three months originally scoped. Across the beta, agents have processed over 1,000 payments ranging from $0.001 to $0.05 per call, each settling individually on-chain.

“AgentCore payments covered everything we needed for an agent to pay over x402: a wallet the customer owns, a funding and revocation flow, a spending limit the platform enforces, and signing that handles both versions of x402. We wrote none of it.”

— Justin Zhou, Founder, Incarna

Conclusion

AgentCore payments gives agents a governed, on-demand way to pay for the services they use. BlockRun and Incarna show how it comes together end to end: an agent that pays for inference, a provider that meters and settles it, and an identity that owns the transaction. If you’re building agents that need to buy services as they run, you can add that capability through a single, governed integration point with AgentCore payments.

Getting started

Ready to add pay-per-inference to your agents? Here’s how to start:

  1. Set up AgentCore payments. Create a Payment Manager with your wallet connection and spending policies. Connect a Coinbase CDP wallet as your credential provider. See the AgentCore payments developer guide for step-by-step instructions.
  2. Open a payment session with your budget. Before the agent starts a task, open a session with a spending cap that fits the workload. The agent transacts within that ceiling and the infrastructure enforces it.
  3. Call a paid endpoint. Point your agent at an x402-compatible service (like BlockRun). When the endpoint returns HTTP 402, call ProcessPayment with the payment details. AgentCore payments handles the signing and returns proof the agent can present to access the service.

To explore the code, see the AgentCore payments samples on GitHub.

Learn more

About BlockRun and Incarna

BlockRun is a pay-as-you-go inference router that serves model inference over the x402 payment protocol. Agents reach a live catalog of models through a single metered endpoint. Each call is independently quoted, authorized, paid, and settled on Base (USDC). BlockRun handles provider selection and delivery so agents access many models through one integration without per-provider subscriptions or billing relationships.

Incarna , built by SpreadX, gives AI agents a persistent identity that survives sessions, models, and runtimes. Each identity carries its own wallet, email address, social accounts, and an action history that stays attached to one ID across runs. When an agent pays for a service, the on-chain payer is the agent’s own identity rather than a shared platform key, making every transaction attributable to a single durable entity. Incarna is live on Base mainnet with real settlement.


About the authors

Peter Jiang

Peter is a Senior Software Developer at AWS, based in Seattle, WA. He is a core member of the engineering team behind the Amazon Bedrock AgentCore payments initiative, which enables AI agents with payments capability. With over 8 years of experience in the financial and payments industry, Peter has launched multiple greenfield projects spanning banking, crypto, and agentic systems. Previously, he worked on ultra-low-latency trading systems at Susquehanna International Group.

Guy Bachar

Guy is a Senior Solutions Architect at AWS, working with fintech and capital markets firms on agentic AI, autonomous commerce, and cloud transformation. He focuses on building systems where AI agents act on behalf of customers across payments, customer experience, and governance.

Chethan Shriyan

Chethan is a Principal Product Manager, Technical at AWS, based in Seattle, WA. He brings nearly 13 years of experience in product and business management, including over 7 years at Amazon. He is passionate about building and delivering technology products that create meaningful impact in customers’ lives.