Select x402 SDKs, facilitators, edge integrations and merchant routes by client compatibility, settlement timing and recovery of paid AI work.
Developers can charge AI agents using the x402 reference SDKs, a hosted or self-operated facilitator, edge integrations such as Cloudflare Workers and paid MCP tools, or a merchant product such as GOAT Flow API Payments. These choices occupy different layers. A server SDK, an agent wallet and a settlement service are usually complementary components, not competing replacements.
The important selection question is what happens around the payment exchange. Which client can satisfy the challenge? Who submits settlement? When does expensive AI work execute? What lets the buyer recover a paid result if the response disappears?
Official documentation and source snapshots checked on November 9, 2026 support the options below. This is an architecture selection guide, not a compiled integration tutorial or measured ranking. In particular, the checked Express implementation shows why payment middleware should not automatically be interpreted as a promise that all computation is prepaid.
Choose a combination, not one universal provider
Start by identifying the boundary you want to buy or operate. If your existing API already handles requests and produces results, you may need route-level payment integration and a settlement operator. If you need payment records and merchant configuration as well, a route product can cover a broader operational surface. Neither choice eliminates the buyer's need for a compatible signer and spending authority.
Component or option | Main job | Responsibility that remains elsewhere |
|---|---|---|
x402 reference server/client SDKs | Express payment requirements and construct compatible payment requests | Wallet authority, operator support, application delivery and recovery |
CDP hosted facilitator | Verify and settle supported signed authorizations | Paid route, pricing, job execution and result delivery |
In-process or self-hosted facilitation | Run the settlement role under your control | Key, gas, network and service operations |
Cloudflare Workers or Agents payment integration | Place payment at an edge route or MCP tool | Compatible facilitator, current dependencies and application semantics |
GOAT Flow API Payments | Configure merchant paid routes and a specific payment/receipt flow | Account enablement, compatible payer/profile and protected-resource logic |
Agent wallet and framework adapter | Let the buyer authorize and perform supported payment actions | Seller acceptance, settlement observation and fulfillment |
The distinctions help avoid an expensive category mistake: selecting a wallet library when the missing component is the seller's route, or selecting a facilitator when the missing component is durable job delivery. Each has a useful role, but only a coherent combination can complete the purchase.
For a hypothetical fixed-price report endpoint, the seller may already have the report service, entitlement records and response handling. Reference middleware with a compatible settlement operator is a plausible starting architecture. If the seller lacks payment configuration and reconciliation, adding a merchant product may be more relevant than adding another client SDK. This is a design comparison, not a tested deployment.
Pair the reference server with a compatible paying client
The reference SDKs let developers integrate payment into an application they control. The pinned Express package documentation documents paymentMiddleware(routes, resourceServer) and a resource server configured with supported payment schemes. The route remains your service; the middleware supplies the payment interaction around it.
The buyer needs the other half. The fetch package documents a payment-aware client wrapper and compatible scheme registration. A funded signer must be able to produce the authorization the seller and facilitator actually accept. A wallet balance does not establish that compatibility or permission to spend it.
Pin the transport version explicitly. The checked v2 HTTP specification uses PAYMENT-REQUIRED for the server's requirements, PAYMENT-SIGNATURE for the client's payment payload, and PAYMENT-RESPONSE for the result. The encoded JSON and relevant browser CORS handling belong to that contract. Legacy X-PAYMENT examples should not be mixed into a v2 setup by assumption.
Payment schemes and networks are separate dimensions. An exact scheme describes payment behavior; a chain identifier describes where the transaction occurs. The EVM mechanism also depends on the token and supported authorization path, such as EIP-3009 or Permit2. The exact asset contract and units matter, not only a ticker such as USDC.
Validate these together: client and server package versions, transport, scheme, network, token, recipient, amount representation and operator support. For example, Base mainnet and Base Sepolia have different CAIP-2 identifiers. A misleading comment beside an example identifier does not change the actual network. Use checked identifiers and runtime capabilities rather than copying comments as configuration truth.
This route suits a developer who wants application control and can own those integration decisions. It does not supply customer authorization policy, a durable purchase record or an AI-job recovery model merely because middleware is installed.
Delegate settlement or operate it yourself
A hosted facilitator is relevant when you want to outsource supported payment verification and transaction submission. The checked CDP facilitator documentation describes authenticated server-side access and supported payment combinations. Your resource server still decides what is sold, what it costs, and which result the buyer receives.
This is a useful separation for an API team that wants to operate the service without also operating a settlement signer. It introduces a dependency on the provider's supported schemes, networks, credentials and service behavior. Keep server credentials out of the agent and browser. Public payment requirements are not permission to use merchant infrastructure APIs.
Self-operation is another documented choice. The reference self-facilitation example shows an in-process facilitator taking the place of an HTTP facilitator client while preserving the route arrangement. A separately deployed facilitator is another architecture; it should not be confused with simply running the example inside the application.
The tradeoff is operational control. A self-operated settlement path needs an appropriate signer, gas funding, RPC access and a response to uncertain confirmations. Keeping those controls local can suit specialist infrastructure teams. It also makes key security and service reliability their responsibility. The documentation comparison provides no evidence that either model is inherently faster, cheaper or safer.
Check the actual support intersection before either choice. A protocol can describe a network while a particular operator does not serve it. A hosted URL in a quickstart is not proof of production support for your chosen asset and scheme. Obtain the active supported-capability response and reconcile it with the seller's route and buyer's signer.
Keep gas arrangements distinct from payment value and provider fees. A facilitator may submit the settlement transaction while a buyer still needs an initial approval transaction for the selected mechanism. Do not turn a gas-sponsored settlement description into a claim that all setup or every payment path is free.
Put payment at an existing edge route or MCP tool
Cloudflare is a relevant deployment option when the service already sits behind an HTTP origin or is exposed as MCP tools. Its HTTP-content payment guide documents a Worker proxy approach, so the payment boundary can sit in front of an existing service rather than require rewriting its business logic.
The MCP path is more tool-specific. The paid-tool guide documents withX402 and paidTool from agents/x402, including a structure where free and paid tools coexist. This is useful when the commercial unit is a tool invocation rather than a whole MCP connection. The reference x402 project also has an MCP package, so Cloudflare is not the only possible MCP integration route.
The implementation boundary matters more than the short example. The checked Worker guide uses the legacy x402-hono API; it is not automatically interchangeable with current Foundation @x402/hono examples. The checked MCP page also has dependency guidance and imports that require validation against a pinned Agents release. Combining snippets from these pages would not produce a verified complete implementation.
There is a concrete configuration conflict to resolve as well. The Cloudflare paidTool example pairs Base with the public x402 facilitator URL. The supported response captured from that facilitator did not advertise Base mainnet. That time-specific observation does not establish future support or a defect in every deployment. It means the example combination cannot be accepted as a proven production setup without checking the active operator.
An edge proxy can reduce changes to the origin, but the origin must not become an unpaid bypass. Define which requests can reach it, which payment-derived context it trusts, and how an authenticated internal request is distinguished from a direct public call. These are integration design requirements, not capabilities established merely by the existence of a Worker template.
Use these paths where their deployment model fits. Then validate package exports, dependencies, facilitator support and protected-origin behavior for the actual release. This guide does not transfer Express settlement ordering to Cloudflare's tools; that implementation was not audited here.
Use a merchant route product when operations matter
Some developers need more than route middleware: a receiving configuration, a paid-route definition, payment records and operational recovery. GOAT Network's GOAT Flow is relevant to that requirement, but its payment contract must be evaluated on its own terms.
The checked merchant guide makes account and route enablement part of onboarding. The merchant needs the appropriate approved/enabled setup, owner controls, a matching receiving pair and the route capability in the intended environment. Repository lists do not establish that every network, token or method is active for every merchant.
GOAT's public DIRECT path has the payer transfer ERC-20 tokens to the merchant receiver, followed by matching and verification. This is different from handing a generic facilitator a signed authorization for it to settle. The distinction changes what the buyer needs to do and what the seller should accept as evidence.
Current paid-route onboarding uses GOAT Flow's MPP integration profile. Its challenge, verification and signed Payment-Receipt form a specific contract. The retrieved documentation does not establish generic interoperability with arbitrary MPP SDKs or a reference x402 client. Shared payment terminology does not bridge different wire formats and receipt rules.
The protected service must validate the receipt under the documented profile, including the expected merchant and route, request binding, expiration and signature, plus its intended replay policy. A receipt for one purchase is not blanket permission to call unrelated resources. Where a receipt is single-use across replicas, consumption needs shared atomic enforcement rather than an in-memory flag on one server.
The commercial tradeoff is broader merchant operations in exchange for a particular product and client contract. This can fit a seller that wants managed paid-route setup and payment records. A developer seeking minimal changes to an existing reference-client ecosystem must first establish compatibility, or deliberately support a separate route.
GOAT AgentKit and PayKit occupy the payer/action side where relevant. They can help connect an agent to supported wallet and payment actions, but they do not replace merchant route protection or the service's delivery logic. Evaluate the seller product and the paying adapter separately rather than treating all GOAT components as interchangeable names.
Inspect when paid work runs relative to settlement
For inexpensive, repeatable responses, a conventional synchronous request may be a good starting point. Expensive AI jobs expose a harder question: has the seller already spent money by the time settlement fails?
The pinned Express implementation provides a concrete answer for its default path. It verifies payment, buffers the handler's output, skips settlement for handler error responses, and settles before releasing a successful buffered result. If settlement fails, it discards the buffered response. Hooks and other paths can alter behavior, so this is not a universal ordering guarantee.
The important consequence is outside the response buffer: model inference or another side effect may already have happened. Discarding bytes does not reverse a model-provider bill, cancel an external purchase or roll back an onchain action. For a hypothetical paid report service, the report can exist and compute can be spent even though the payment did not complete and the customer received no report.
Buffering also matters for delivery expectations. A path that waits for the handler to finish before releasing output should not be presented as immediate token streaming. Long jobs, large outputs and streams require an explicit design rather than the assumption that any paid HTTP wrapper preserves their existing semantics.
Variable charges introduce a separate choice. The checked EVM upto mechanism documents capped authorization and actual settlement overrides using Permit2, subject to the required deployment and provider support. This can bound a usage charge. It does not count model tokens, determine task success or guarantee result recovery.
Suppose, hypothetically, an inference task's final usage is not known at admission. The service needs a maximum authorized amount, an enforceable compute/usage bound, a rule for calculating the actual charge and a recoverable result record. A payment cap alone cannot stop an application from starting more work than its budget can cover. Decide where admission, metering and stopping are enforced before choosing the settlement mechanism.
Recover the purchase, payment and job separately
One retry can concern three different things: obtaining a payment outcome, obtaining an already-produced result, or asking for new work. The application needs enough durable state to distinguish them.
The checked EVM exact-scheme specification includes a pending-settlement possibility after broadcast when confirmation remains unresolved. The transaction identity permits reconciliation. A timeout at that stage is not proof that no payment happened, and should not automatically cause another authorization or transfer.
The payment-identifier extension supplies an idempotency building block with server-side lookup. It is not a complete durable job runner. Your application still defines which payer, method, resource and input the purchase covers, where the result lives, and which retried request may retrieve it.
A practical design can persist a logical purchase or job ID, the relevant request/input binding, payment attempt and authorization or transaction identity, execution state, result reference and delivery record. That is an architecture recommendation, not a claim that the reference SDK creates all those fields. Retention, authorization and privacy requirements should be defined for the service rather than copied from a generic example.
Separate recovery actions accordingly. An unresolved transfer needs payment reconciliation. A settled purchase with a finished job needs authorized result retrieval. A failed job may require a retry, cancellation or refund decision under the seller's terms. Payment deduplication cannot decide whether running an inference again is commercially or technically correct.
GOAT's profile similarly supports verification recovery after broadcast, but that recovers the payment path, not the AI output. Receipt verification and replay enforcement protect the purchased request; they do not recreate a result your service failed to retain. With multiple replicas, shared state must preserve the intended payment and job semantics across restarts and repeated calls.
Finally, treat refunds as their own action. Neither a 402 response nor a failed handler establishes that funds were automatically returned. Define who can authorize a refund, how it is connected to the original purchase and what happens if the refund itself is uncertain. This prevents a delivery failure from becoming an untracked second payment workflow.
Validate one complete production path
For an application team retaining its API and delivery system, reference server/client SDKs plus a compatible hosted facilitator are a reasonable starting architecture. Teams that need direct control of settlement can evaluate self-operation and its signer, gas and RPC obligations. Existing edge and MCP deployments can evaluate Workers or paidTool after resolving release and operator compatibility. Merchants needing paid-route operations can evaluate GOAT Flow with its actual receiving, client and receipt profile.
The final choice should name a concrete combination, not just a brand: transport version, scheme, network, exact asset, buyer signer, server integration, settlement operator, receiving destination and delivery policy. Assign an owner to every unresolved production-access or compatibility condition.
Then require an acceptance exercise for one real service in the intended environment. It should establish ordinary paid access, a rejected payment, an uncertain settlement, a repeated request and recovery of an already-paid result. For expensive AI work, inspect when computation starts and what remains payable if the handler or settlement fails. These are proposed checks; no such transaction or compiled application was tested for this article.
Only that end-to-end contract tells you whether the infrastructure fits your service. The HTTP exchange can be small. The purchase still needs a coherent authority, execution and recovery model.



