Price the Answer, Not the Page: Unit Economics of a Question
Roll every fetch, retry, render, and proxy hop into one number: the cost of a single delivered answer. Build the roll-up budget and recompute it yourself.
On this page
Defining the Unit: What Counts as One “Delivered Answer”
Every cost model I’ve seen for data pipelines prices the wrong thing. They price the page. “A page costs us $0.004.” Fine — but nobody buys pages. Users buy answers. A product manager asks “what does this item cost across the top five storefronts?” and the system delivers one answer. That answer may have consumed twelve fetches, three retries, two rendered pages, one model call, and a proxy hop through two countries. If your unit economics stop at “cost per page,” you cannot answer the only question that matters: what did delivering that answer cost?
So change the unit. One delivered answer is one successful response to one end-user question. Everything the pipeline burned to produce it — model tokens, fetch attempts, retries, render passes, proxy egress — goes into that answer’s cost envelope. If an attempt failed and was retried, both attempts bill to the same answer. If the user abandoned the request mid-flight, the spend still happened, so it bills to a “wasted answer” bucket that you track separately.
Here is the component list I use. Notice how many items are usually left out of naive per-page accounting:
| Component | Description | In the unit? |
|---|---|---|
| Input tokens | Prompt + context sent to the model | Yes |
| Output tokens | Generated answer text | Yes |
| Cached input tokens | Discounted repeated context | Yes, at discount |
| Tool fetches | HTTP fetches / scrape calls made on the answer’s behalf | Yes |
| Retries | Every failed attempt, priced at full rate | Yes — this is the big leak |
| Render passes | JS-rendered pages for SPA content | Yes |
| Proxy hops | Residential / ISP / mobile routing premiums | Yes |
| Embedding calls | If you retrieve context via vector search | Yes |
| Abandoned answers | Spend on requests the user never saw | Yes, as a separate bucket |
| Fixed infra (queues, storage) | Amortized platform cost | Amortized in, not per-answer |
A single answer’s raw event log makes this concrete. Here’s a pseudo-invoice for one question about products on store.example.com:
{
"answer_id": "ans_8f31c2",
"question": "What is the current price of the flagship SKU on store.example.com?",
"events": [
{"type": "fetch", "target": "https://store.example.com/flagship", "attempt": 1, "outcome": "blocked", "price_usd": 0.002},
{"type": "fetch", "target": "https://store.example.com/flagship", "attempt": 2, "outcome": "success", "price_usd": 0.002, "egress_bytes": 412000},
{"type": "render", "reason": "price injected by JS", "price_usd": 0.005},
{"type": "proxy_hop", "route": "residential, country=US", "price_usd": 0.003},
{"type": "model", "input_tokens": 3800, "cached_input_tokens": 2400, "output_tokens": 140, "price_usd": 0.0019},
{"type": "embedding", "tokens": 900, "price_usd": 0.00002}
],
"delivered": true
}
Sum it: roughly $0.014 per answer. That number is useless in isolation. It becomes useful when you compare it across answer types, watch it drift week over week, and alarm when the p95 blows past your budget. The rest of this post builds that machinery.
The Token Line Item: Pricing the Model Call Itself
Start with the line item everyone gets wrong in a different direction: they either ignore it (“the model is cheap”) or they price it off the prompt alone. The real cost is input tokens plus output tokens, with cached input tokens at whatever discount your provider gives you, plus the padding you add for safety.
Context padding deserves a paragraph of its own. If you stuff 4,000 tokens of scraped markdown into the prompt “just in case,” you pay for 4,000 tokens on every answer, forever, whether the answer needed them or not. I’ve written before about trimming scraped pages before they flood the agent context — the same discipline applies to cost. Trim the context, cut the input tokens, and the unit cost drops linearly.
Here’s a function that prices one model call from measured token counts:
PRICE_PER_1K = {
"economy": {"input": 0.0001, "cached_input": 0.00002, "output": 0.0004},
"standard": {"input": 0.0003, "cached_input": 0.00006, "output": 0.0009},
"premium": {"input": 0.0010, "cached_input": 0.00020, "output": 0.0030},
}
def model_cost(prompt_tokens: int,
cached_tokens: int,
output_tokens: int,
tier: str = "standard") -> float:
"""Base model cost for one answer about store.example.com products."""
p = PRICE_PER_1K[tier]
fresh_input = max(prompt_tokens - cached_tokens, 0)
return (fresh_input * p["input"] +
cached_tokens * p["cached_input"] +
output_tokens * p["output"]) / 1000.0
Run the same 800-token answer about store.example.com products through all three tiers:
| Tier | Input (800 tok) | Cached discount | Output (200 tok) | Cost per answer |
|---|---|---|---|---|
| Economy | $0.00008 | none assumed | $0.00008 | $0.00016 |
| Standard | $0.00024 | none assumed | $0.00018 | $0.00042 |
| Premium | $0.00080 | none assumed | $0.00060 | $0.00140 |
An opinion you may disagree with: for most product-lookup answers, the economy tier is the right default, and reaching for premium “because the answers are better” is usually compensation for bad context. A well-trimmed 800-token prompt with the right three paragraphs of scraped markdown beats a 6,000-token prompt fed to a premium model. Fix the retrieval, then pay for tokens only where the answer quality actually demands it. Cache hits matter more than tier selection — if 70% of your input tokens are cached across a session, the standard tier’s effective input cost can drop below the economy tier’s uncached cost.
Counting the Hops: Fetches, Retries, and Tool Calls in the Bill
The model call is rarely the biggest line item. The fetches behind it are — especially once retries enter the picture. A blocked page costs the same as a successful one. You paid for the proxy route, the antibot fingerprint, the attempt. The response was a block page. You retry. You pay again.
Here’s a fetch wrapped in retry logic with a per-attempt cost accumulator, using the scrape endpoint as the fetch primitive:
import time, requests
BASE = "https://api.finedata.ai"
HDRS = {"Authorization": "Bearer fd_your_api_key"}
def fetch_with_cost(url: str, max_attempts: int = 4):
cost = 0.0
for attempt in range(1, max_attempts + 1):
resp = requests.post(f"{BASE}/api/v1/scrape", headers=HDRS, json={
"url": url,
"use_residential": True,
"use_js_render": True,
"max_retries": 1, # we own the retry loop; don't double-retry
"formats": ["markdown"],
}, timeout=180)
# per-attempt unit price: residential + render + base fetch
cost += 0.002 + 0.003 + 0.005
if resp.ok and resp.json().get("status") == "ok":
return resp.json(), cost
backoff = min(2 ** attempt, 30)
time.sleep(backoff)
raise RuntimeError(f"all {max_attempts} attempts failed for {url}")
body, fetch_cost = fetch_with_cost("https://store.example.com/flagship")
Note max_retries: 1 in the payload. That’s deliberate. If the service retries internally and your client retries on top, you get multiplicative attempts — four client retries times three service retries is twelve paid fetches for one answer. I’ve covered this failure mode in detail in how retries quietly double your scraping costs; the short version is pick one retry layer and make the other one inert.
Now the arithmetic for one real answer. The question needed three fetch attempts and two tool calls:
| Hop | What happened | Cost |
|---|---|---|
| Fetch 1 | store.example.com/flagship — block page | $0.010 (residential + render) |
| Fetch 2 | Retry with sticky session — success | $0.010 |
| Fetch 3 | Related SKU page for comparison | $0.010 |
| Tool call 1 | Search tool over cached product index | $0.001 |
| Tool call 2 | Currency conversion lookup | $0.001 |
| Model call | Standard tier, 800 in / 200 out | $0.00042 |
| Total fetch+tool | $0.032 |
The model call is 1.3% of this answer’s cost. Anyone optimizing the model tier here is rearranging deck chairs. The retries are 60% of the cost. If you want the unit cost down, kill the first blocked attempt — better routing, a warmer session, a different proxy class — and the number halves immediately.
The Proxy Tax: Bandwidth, Egress, and Render Overhead
“Infra costs” is where cost models go to hide. Don’t let it. Proxy routing, egress bytes, and render time are all measurable per answer, and they belong in the unit.
First, make the route explicit and priced. A config block for the store.example.com route:
route: store.example.com
proxy:
class: residential
country: US
sticky: true # one exit IP per answer session
session_ttl: 1800
egress:
log_per_request: true # record bytes per fetch in the cost trace
render:
engine: headless
wait_for: networkidle
price_model:
per_fetch_usd: 0.002
residential_premium_usd: 0.003
render_premium_usd: 0.005
egress_usd_per_gb: 0.08
Second, measure rather than assume. Egress at $0.08/GB means a 412 KB page costs $0.00003 — trivial per answer, not trivial across ten million answers. And render latency is a cost too, in the sense that everything you pay per second of held connection eventually shows up in throughput capacity. A local measurement recipe:
#!/usr/bin/env bash
# measure one answer payload's transfer + render latency
URL="https://store.example.com/flagship"
BYTES=$(curl -sL -o /dev/null -w '%{size_download}' "$URL")
START=$(date +%s.%N)
curl -sL -o /dev/null "$URL"
END=$(date +%s.%N)
LATENCY=$(echo "$END - $START" | bc)
EGRESS_COST=$(echo "scale=8; $BYTES * 0.08 / 1073741824" | bc)
echo "bytes=$BYTES latency_s=$LATENCY egress_cost_usd=$EGRESS_COST"
bytes=412337 latency_s=1.84 egress_cost_usd=0.00003069
The egress number is small. That’s the honest finding — bandwidth is rarely your leak. The render premium and the proxy class are. A residential hop costs roughly 1.5x a datacenter hop, and a rendered page costs more than a plain fetch because a browser ran somewhere. When a domain’s reputation degrades and you escalate from datacenter to residential to ISP routing, your per-answer cost ratchets up silently unless you log the route class into the cost trace. I treat route class as a first-class field in every answer’s event log for exactly this reason. (If you want to check reputation before escalating, the /api/v1/reputation/domain/{domain} endpoint gives you per-domain signals so you escalate only when the data says you must.)
Building the Roll-Up Budget: One Number per Answer
Now assemble it. The roll-up is deliberately boring — a sum of line items — but the discipline is in what you include and how you split the distribution. Never report a single average. Report median and p95, because retries and blocked pages create a heavy right tail and the average hides it.
def roll_up(trace: list[dict]) -> dict:
"""Sum model, fetch, retry, render, and proxy line items
into one cost per delivered answer."""
model = sum(e["price_usd"] for e in trace if e["type"] == "model")
fetch = sum(e["price_usd"] for e in trace if e["type"] == "fetch")
render = sum(e["price_usd"] for e in trace if e["type"] == "render")
proxy = sum(e["price_usd"] for e in trace if e["type"] == "proxy_hop")
other = sum(e["price_usd"] for e in trace
if e["type"] in ("embedding", "tool"))
return {
"cost_per_answer": round(model + fetch + render + proxy + other, 6),
"breakdown": {
"model": round(model, 6),
"fetch_and_retry": round(fetch, 6),
"render": round(render, 6),
"proxy": round(proxy, 6),
"other": round(other, 6),
},
}
Feed it the pseudo-invoice from the first section and you get $0.014. Feed it the three-fetch answer from the hops section and you get $0.032. Both are “one answer.” That’s the point of the unit: answer types differ by an order of magnitude, and your budget has to reflect that.
| Answer type | Median cost | p95 cost | Dominant line item |
|---|---|---|---|
| Simple lookup (one product, cached context) | $0.004 | $0.011 | Fetch |
| Multi-hop research (five sources, one render) | $0.021 | $0.068 | Fetch + retries |
| Multi-hop under degraded domain reputation | $0.035 | $0.140 | Proxy premium |
The p95 is 3-6x the median in every row. If you budget at the median, you’ll blow the budget on exactly the answers that were hardest to deliver — which is backwards. Budget at p95 for capacity planning, drive the median down for margin. This is also where I disagree with the common advice to “just cache more”: caching helps the median a lot and the p95 almost not at all, because the tail is dominated by fresh fetches against domains that are having a bad day. You cannot cache your way out of the tail. You can only route, retry-budget, and degrade.
Recomputing It Yourself: A Local Unit-Economics Harness
Never trust a vendor dashboard as your only cost ledger. It aggregates across your account, lags, and almost never lets you slice by answer type. Build the local harness instead: every answer request emits a cost record at delivery time, and a small CLI recomputes your unit economics from the log whenever you want.
First, the middleware. Attach a cost_trace array to each answer request and append priced events as they happen:
class CostTraceMiddleware:
def attach(self, request):
request["cost_trace"] = []
def log_fetch(self, request, url, attempt, outcome, price):
request["cost_trace"].append({
"type": "fetch", "target": url,
"attempt": attempt, "outcome": outcome,
"price_usd": price,
})
def log_model(self, request, usage, price):
request["cost_trace"].append({
"type": "model",
"input_tokens": usage["input"],
"cached_input_tokens": usage.get("cached", 0),
"output_tokens": usage["output"],
"price_usd": price,
})
def finalize(self, request, delivered: bool):
record = {
"answer_id": request["answer_id"],
"question_type": request["qtype"],
"delivered": delivered,
"trace": request["cost_trace"],
"cost_usd": roll_up(request["cost_trace"])["cost_per_answer"],
}
append_jsonl("answers_cost.jsonl", record)
Then the recompute. This is the whole point: self-service numbers, no dashboard required.
python recompute.py --log answers_cost.jsonl --last 100
last 100 answers (84 delivered, 16 abandoned)
avg cost per delivered answer : $0.0184
median : $0.0091
p95 : $0.0712
worst : $0.1860
wasted spend (abandoned) : $0.41 total (2.2% of spend)
top leak: fetch retries on store.example.com (38% of fetch spend)
That output is a morning standup in six lines. The worst answer cost twenty times the median. The abandoned bucket is small but nonzero. And the top leak is named, with a percentage, so the next fix is obvious instead of vibes.
Where the Budget Leaks: Failure Modes That Double Your Unit Cost
Four leaks show up in nearly every pipeline I’ve audited. Each one is fixable, and each fix has a measurable effect on the same store.example.com product-question answer:
| Leak | Unit cost with leak | Unit cost fixed | Fix |
|---|---|---|---|
| Silent double retry (client + service) | $0.064 | $0.032 | One retry layer only, max_retries: 1 in the payload |
| Context stuffing (6k tokens always) | $0.048 | $0.033 | Trim to the 800 tokens the answer needs |
| Cache miss on repeated questions | $0.036 | $0.019 | Cache answer payloads keyed on question + content hash |
| Escalating to premium stealth “just in case” | $0.058 | $0.032 | Escalate on measured block rate, not superstition |
The most dangerous leak is the one nobody notices: runaway retries. A domain starts blocking hard, every answer burns its full retry budget, unit cost triples, and nothing alerts because each individual answer looks normal. The fix is a hard cap enforced per answer, with degradation instead of more attempts:
class RetryBudgetBreaker:
"""Hard-cap fetch spend per answer; degrade instead of runaway retries."""
def __init__(self, max_fetch_attempts=3, max_fetch_spend_usd=0.05):
self.max_attempts = max_fetch_attempts
self.max_spend = max_fetch_spend_usd
def before_fetch(self, request):
attempts = [e for e in request["cost_trace"] if e["type"] == "fetch"]
spend = sum(e["price_usd"] for e in attempts)
if len(attempts) >= self.max_attempts or spend >= self.max_spend:
# degrade: answer from cached data, flag staleness
request["degraded"] = True
raise FetchBudgetExceeded(request["answer_id"])
def after_fetch(self, request, price):
request["cost_trace"].append(
{"type": "fetch", "price_usd": price})
Yes, this means some answers ship stale. That’s the trade, and I think it’s the right one: a slightly stale price with a staleness flag beats a $0.18 answer, and it beats an error. If your product can’t tolerate staleness, the answer isn’t “remove the cap” — it’s “fix the routing so the first attempt succeeds.”
One more thing worth checking before you trust any of these numbers: your own success rate. If a meaningful share of your fetches return block pages with a 200 status, your per-answer cost is inflated by attempts you may not even be counting. I wrote about detecting exactly that in when your 200 OK responses are actually block pages — audit it before you budget, or you’ll be pricing phantom successes.
Wrap-Up
Price the answer, not the page. The delivered answer is the only unit your users and your finance team both understand, and it’s the only unit where every leak — retries, render premiums, proxy escalation, context stuffing, abandoned requests — shows up in one number.
The build order that works: define the unit and its cost envelope first, then price the model call from measured tokens, then accumulate fetch and retry costs per attempt, then measure egress and route class instead of guessing, then roll it all into a median-plus-p95 budget, then log every answer’s cost trace locally and recompute it yourself. Six steps, all runnable with the endpoints above, none of them requiring you to trust anyone else’s dashboard.
Start with the harness. Once every answer emits its own invoice, every optimization you make afterwards gets a before-and-after number attached to it — and that’s when cost work stops being guesswork.
Related Articles
Budget the Fetches Behind Every Data Row
Every data row rides on listing pages, pagination, and dead links. Model the fetch-to-row ratio, plug in real numbers, and budget crawls you can defend.
TechnicalToken Economics of LLM Extraction: A Cost Worksheet
Measure the real token cost of LLM extraction: tokens per page, per field, and per clean record, with a worksheet you can recompute on your own corpus.
TechnicalBreadth-First vs Depth-First Crawls: Frontier Trade-offs
Breadth-first and depth-first crawls spend your fetch budget differently. Compare coverage, discovery speed, and duplicate risk before you pick a frontier.