Skip to main content
HomeLanding pagesPaying an agent for a task: the fix
LANDING PAGE

Paying an agent for a task: the fix

7 min read·Last updated June 2, 2026

To pay an agent for a task, gate the endpoint that runs the task with x402: one paid call settles in USDC and triggers the task, returning the result. For one agent hiring another, this is agent-to-agent payment. Note x402 settles before the work runs, so it is pay-to-run, not pay-on-verified-completion; handle success guarantees at the application level rather than expecting built-in escrow.

The problem

You want to pay an agent for doing a task, run this analysis, generate this report, complete this job, and have the payment tied to the task rather than to small individual calls. Or you have one agent that needs to hire another to do a piece of work and pay it for the result. The per-call payment model you have seems too granular for a task, and you are not sure how to structure payment around a unit of work an agent completes.

This is the agent-task-payment problem. The friction is mapping the idea of paying for a task, a discrete job with a result, onto a payment rail that settles per call. It feels like a mismatch: a task is bigger than a single data fetch, so how do you charge for it? The symptom is wanting task-level payment without a clear way to express it. The fix is to see that a task is just a paid call at a different granularity, and to gate it accordingly, while being honest about what the payment does and does not guarantee.

How task payment maps to per-call

The key insight is that task payment is per-call payment at the granularity of a task. A task is a unit of work that an endpoint performs and returns a result for, so paying for the task is paying for the call that runs it. Where a small per-call payment might be for a quick data lookup, a task payment is for a call that does more, the analysis, the report, the job, but it is the same mechanism: one paid call, one unit of work, one result.

So there is no separate task-payment system to build; you use x402 at the task's granularity. You gate the route that runs the task and price it for the value of the task, and the caller pays once for that call. This reframing dissolves the apparent mismatch: a task is not too big for per-call payment, it just defines a larger, more valuable unit than a trivial fetch. Once you see a task as a priced call, the fix is the familiar x402 gating applied to the task endpoint.

The fix

The fix is to gate the task's endpoint with x402 and price it for the task. You front the route that runs the task with the x402 adapter and set a price reflecting the task's value. A caller, a human-driven client or another agent, calls the route, settles the price in USDC, and the task runs, returning its result. One paid call corresponds to one task performed, which is exactly the task-level payment you wanted.

For the case where one agent hires another, the same gating makes it agent-to-agent: the hiring agent calls the doing agent's gated task endpoint and pays from its wallet, and the doing agent runs the task and returns the result. Each agent has its own wallet and spend limit, so the payment is attributed per agent. The fix, then, is to gate the task route and charge for the call that runs it, using the same x402 mechanism at task granularity. The agent-to-agent mechanics are in how-to-handle-agent-to-agent-payments.

Pay-to-run, not pay-on-completion

Here is the honest nuance that matters for task payment: x402 settles the payment before the server runs the task, so it is pay-to-run, not pay-on-verified-completion. The caller pays, then the task executes; there is no built-in escrow that holds the payment and releases it only if the task succeeds. If you imagine task payment as paying only when the outcome is delivered and verified, that is not what the protocol provides on its own.

This is worth being clear about so you design around it rather than assume a guarantee that is not there. If your task is reliable, pay-to-run is fine: the call pays and the task delivers, the same as any paid API. If you need stronger guarantees, handle them at the application level, for example, have the task endpoint charge only when it can actually deliver the result, price the task to reflect its success rate, or build a verification-and-refund flow in your own logic. The point is that the payment is tied to the call, not to a verified outcome, so success guarantees are your design problem, not a feature you can assume.

Hiring another agent for a task

The richest version of task payment is one agent hiring another, which is agent-to-agent payment for a unit of work. A planning agent that cannot do everything itself can delegate a task to a specialist agent and pay it for the result: it calls the specialist's gated task endpoint, settles the price, and gets the work back. The specialist earns per task, the planner pays per task, and both stay within their own spend limits.

This is how agents compose into a workflow that involves money: each agent does what it is good at and is paid for it, hired by other agents as needed. The trust model is the agent-to-agent one, the payer leans on the doing agent's identity to decide it is worth hiring, and the doing agent leans on verified payment before running the task. So task payment between agents is just agent-to-agent payment where the call corresponds to a task, which is covered conceptually in what-is-agent-to-agent-payment.

Describe the task first

One practical point: keep task discovery free so a caller knows what it is paying for. Before a caller pays for a task, it should be able to learn what the task does, what inputs it needs, and what result it returns, on a free, ungated route or description. A caller, especially an autonomous agent, will not pay for a task it cannot understand, so the free description is what lets it decide the task is worth the price.

This mirrors the keep-discovery-free principle for any paid endpoint, applied to tasks: the doing agent or service describes its tasks openly, prices them, and gates only the execution. A planning agent can then read the available tasks, choose the one it needs, and pay for it, which is what makes a market of agent tasks work. So part of structuring task payment is describing the task clearly and freely, then charging for running it, not gating the very information a caller needs to decide to pay.

Sizing the price to the task

Because a task is a larger unit than a trivial call, price it for what the task is worth, not for a tiny fetch. Set the price from the task's real cost to deliver, the compute, data, and upstream calls it consumes, plus a margin, so each completed task is profitable. A task that runs an expensive analysis warrants a higher price than one that formats text, and the price should reflect that difference rather than a flat per-call rate.

Then check it against your spend limits if an agent is the one paying: the per-transaction cap must be high enough to allow a single task payment, since a task can cost more than a small call. Size both sides, the task's price and the paying agent's cap, so a legitimate task payment goes through while runaway spend is still bounded.

If you need to pay an agent for a task, the path is x402 at task granularity. The agent-to-agent mechanics, for one agent hiring another, are in how-to-handle-agent-to-agent-payments, and the concept is in what-is-agent-to-agent-payment. Together they take you from wanting task-level payment to gating tasks and paying per job, with honest handling of what the payment guarantees. Pricing is on the pricing page.

FAQ

Frequently asked questions.

How do I pay an agent for completing a task?

Gate the endpoint that runs the task with x402, so a single paid call triggers the task. The caller settles the price in USDC, the task runs, and the result returns. For one agent hiring another to do a task, the same flow is agent-to-agent payment. The task becomes a paid call: pay, the task runs, you get the result.

Does the agent get paid only if the task succeeds?

Not by default. x402 settles payment before the server runs the task, so it is pay-to-run rather than pay-on-verified-completion. There is no built-in escrow that releases only on success. If you need success guarantees, handle them at the application level, for example by having the task endpoint only charge when it can deliver, or by pricing to reflect reliability.

How is task payment different from per-call payment?

It is a way of thinking about per-call payment: a task is one paid call that does a unit of work and returns a result. Mechanically it is the same x402 settlement; the framing is that the call corresponds to a task rather than a small data fetch. So paying for a task is gating the task's route and charging for the call that runs it.

Can one agent pay another agent to do a task?

Yes, that is agent-to-agent payment. The hiring agent calls the doing agent's gated task endpoint, settles the price in USDC from its wallet, and the doing agent runs the task and returns the result. Each has its own wallet, so the payment is attributed per agent. This is how agents compose, hiring and paying each other for units of work.

What if the task takes a long time?

x402 settles the payment on the call, so for a long-running task you design the endpoint accordingly: it might pay to start the task and return a handle the caller polls, with the payment covering the work regardless of duration. The payment timing is tied to the call, so structure the task endpoint so the paid call cleanly corresponds to the unit of work you are charging for.

Create your free agent wallet in 5 minutes.

First payment confirmed in under ten minutes. Free to start.