A market briefing can be short even when the work behind it is not. An AI agent may fetch prices, open a historical window, check market hours, then request the same prices again while rewriting its answer.
With x402, individual API requests can be paid for as they happen. That makes a small research task straightforward to price, provided the application knows when it has enough data.
The useful unit is the cost of a completed task. A request price tells you what one operation costs. A task budget tells you how much the application can spend to produce an answer that meets its requirements.
This guide works through a market data example, then shows how to control repeat purchases, historical pages and uncertain payment outcomes. The budget rules are application design recommendations, not automatic features of the payment protocol.
What does an x402 API request cost?#
x402 provides an HTTP payment flow. An unpaid request can return a 402 Payment Required response with payment requirements. A payment-aware client can authorise payment and retry the request. The price comes from the service and operation being requested; x402 itself does not set a universal API rate. See the official protocol introduction.
For market data, the SiftingIO x402 catalog lists a price for each operation. The following example uses prices checked on 1 December 2026.
Imagine an agent preparing a short briefing on three instruments. Its plan calls for three current prices, two pages of historical candles and one response covering market status.
| Data needed | Paid requests | Price per request | Subtotal |
|---|---|---|---|
| Latest prices for three instruments | 3 | $0.002 | $0.006 |
| Historical candles, two pages in total | 2 | $0.010 | $0.020 |
| Market status across covered markets | 1 | $0.002 | $0.002 |
| One completed run | 6 | $0.028 |
At those prices, 500 runs with exactly that request pattern cost $14 in data API charges. This is an illustrative calculation, not a measured customer result or a fixed price for every briefing. Extra historical pages, additional purchases and other services change the total. Model, hosting and wallet-funding costs are outside this calculation.
The assumptions matter as much as the arithmetic. “Two pages” means two pages across the whole task. It does not mean two pages for every symbol, or a guarantee that a chosen date range will fit.
Start with the answer the task must produce#
Before letting an agent choose tools, define a small completion contract. For the briefing above, that might be:
- Three named instruments with an explicit as-of time.
- A historical comparison over a specified period and interval.
- Relevant market-session context.
- A clear statement when a required observation is unavailable.
This gives the application a stopping point. Once those requirements are met, rewriting the prose should normally use the collected evidence. A new fetch needs a reason, such as the price becoming too old for the task or the user requesting another instrument.
An instruction such as “keep researching until confident” leaves both the evidence requirement and the spending limit open. A bounded question makes the result easier to check and the cost easier to predict.
Set three limits before authorising payment#
A practical starting point is a limit for each request, each task and the application as a whole.
| Limit | What it controls | Illustrative policy |
|---|---|---|
| Per request | The maximum amount accepted for one approved operation | Reject a price above the configured limit for that route |
| Per task | Cumulative spending while producing one result | Allow up to $0.05 for the six-request briefing |
| Per day | Spending across all tasks and workers | Pause new purchases at a separately approved daily budget |
The $0.05 task allowance is an example, not a recommended budget for every application. It gives the planned $0.028 workflow some room while keeping further purchases bounded.
Enforce these rules in the application component that authorises payments. A prompt asking the model to “stay under five cents” is useful context, but it is not a spending control. Check the destination, operation, payment asset, network, recipient and amount against the application's approved configuration before signing.
Count pending authorisations as well as settled payments. If two workers each see $0.01 remaining and both start a $0.01 purchase, a balance check alone can overspend the task. Reserve the allowance as one coordinated operation before either worker proceeds. Release it only when the outcome is known to permit that release.
The model can choose among narrowly defined data tools. Wallet secrets and payment approval belong in the application's controlled execution path.
Buy fresh data when the task needs it#
Three calls asking for the same observation may add no useful evidence. Reuse a result within the permitted usage terms when its age and meaning still meet the task's requirements.
Different data needs different refresh rules:
| Data | A useful refresh question |
|---|---|
| Current price | Is the observation recent enough for this particular output? |
| Historical candles | Has the requested window changed, or could a candle still be updating? |
| Market status | Has the relevant session boundary passed? |
| Instrument details | Has the symbol mapping or metadata changed? |
A daily briefing and an interactive price display should not inherit the same freshness rule merely because they use the same endpoint.
Keep the data timestamp and the retrieval time separately. In SiftingIO's current-price responses, t is the Unix-millisecond time when the SiftingIO engine produced the price. It is not the time your application received the response. Historical candle timestamps identify the opening of the bar. The data methodology and endpoint documentation explain the relevant semantics.
A recent retrieval does not, by itself, make an observation recent. Check the expected session and update behaviour before deciding that another paid request will help. Our market data caching guide covers cache keys and sharing requests across application components.
Give historical research a page budget#
“Fetch the last month” is not a complete cost estimate. The number of requests depends on the interval, available observations, page size and endpoint cap.
At the catalog's current $0.01 per historical page, a ten-page job costs $0.10 in data charges. Increasing the date range or switching from daily to minute candles can change the number of pages substantially.
Define the symbol, time window, interval and maximum pages before the task starts. Follow the returned cursor only while the result still needs another page and the task has enough remaining budget.
If the page budget is reached first, preserve the partial result and identify its coverage. Do not describe a truncated series as the full requested period. The agent can then offer a narrower window or request approval for a larger budget.
Handle a timeout as an unresolved outcome#
There is an important difference between an API error response and losing the connection after sending a payment-authorised request.
SiftingIO's x402 documentation states that payment is settled after a successful data request; invalid requests and server errors are not settled. A connection timeout, however, may leave the client without the response needed to know what happened.
Keep that purchase marked as unresolved while checking the available payment evidence. Avoid immediately creating a fresh payment authorisation for the same work. Otherwise, a second successful purchase can pay for data the application already requested.
The protocol has an optional payment-identifier extension for deduplicating supported retries. Its use depends on server-advertised support and the server's retention rules. Do not assume every x402 endpoint provides it, or that a payment ID can be reused for a different request.
Measure cost against useful results#
A low average request price can hide expensive unfinished tasks. Track at least these four figures:
- Data cost per completed task: all settled data charges in the evaluation batch, including failed tasks, divided by tasks that met the completion contract.
- Completion rate: the share of tasks that returned the required evidence within budget.
- Repeat-purchase rate: repeated purchases of equivalent observations that were still usable.
- High-cost task count: runs that approached or reached the spending ceiling.
Suppose a batch spends $14 and produces 400 acceptable briefings. Its data cost per completed briefing is $0.035, even if 500 tasks were attempted. Counting only the successful tasks' own purchases would conceal the money spent on the other attempts.
Keep the request parameters, data timestamps, task identifier, payment outcome and available receipt together. This makes a costly run explainable without storing wallet secrets in the agent's conversation or logs.
Try one bounded workflow#
Choose one question your application needs to answer. Write down its data requirements, calculate the planned request cost from the live catalog, and give it explicit freshness, page and spending limits.
SiftingIO provides free sample responses for checking response shapes before making paid requests. Samples are for integration testing, not current market observations. When the response handling is ready, run the bounded task and inspect both the answer and its purchase record.
For the payment flow and working request examples, continue with the SiftingIO x402 market data guide. You will have a concrete task to test, a known allowance to spend and a clear point at which the agent can stop.
