Skip to main content
All use cases
Usage-based API billingSaaS

Price the call for what it costs. Refund the rest, automatically.

Extracta sells document extraction as an API — invoices, contracts, and scanned PDFs turned into structured JSON. A one-page receipt and a forty-page contract cost wildly different amounts to process, so a flat per-call price either overcharges the easy job or eats the loss on the hard one. With Meter, the calling agent signs a spending cap before the call runs, Extracta meters the real pages and compute time against that cap, and the unused difference refunds on-chain the moment the job finishes. The receipt reseals with the true number, not the estimate it started with.

BeforeFlat per-call price → guesswork on every job
AfterSigned cap → metered usage → unused balance refunds on-chain
100%
of the unused cap refunded automatically
Try it in the Sandbox
Signed cap
Before the call runs
The calling agent commits to a ceiling upfront, never an open tab
Metered live
Against the cap
Pages processed, tokens spent, compute time — the job's true cost
On-chain refund
Unused balance returned
The gap between cap and actual usage settles back automatically
Resealed
True number, not the estimate
The receipt closes on what the call actually cost
What the receipt shows

The call closes on what it actually cost, not what it was capped at.

One extraction job, end to end: the agent signs a $0.80 spending cap before the call runs, Extracta's API meters pages processed and compute time against that cap, and the moment the job finishes, the unused balance refunds on-chain. The receipt reseals with the real metered number, not the cap it started with.

  • The cap is signed before the call runs — the API can't charge past it
  • Real usage, pages processed and compute time, is metered against the cap, not estimated
  • The unused difference refunds on-chain the moment the job settles, no invoice, no dispute

Extract line items from a 40-page vendor contract, capped at $0.80.

Signing a $0.80 cap for this job — metering pages processed against it, and refunding whatever's left once the extraction finishes.

Metered API call · document extraction
call_8f21 · Extracta /extract
Metered · refunded · sealed
Job40-page vendor contract → structured JSON
Cap signed$0.80 · USDC
Metered usage$0.34 · 40 pages · 61s compute
Refunded$0.46 · on-chain · automatic
ReceiptResealed at $0.34
receipt-call8f21.jsonusage-trace.json
metered · refunded · sealedrcp_mtr8f21
The pain

The conversation is the easy part.

Usage-based APIs guess. A flat per-call price either overcharges the easy jobs or eats the loss on the hard ones, and nobody finds out which until the invoice runs at month end. Sellers pad the price to cover the worst case; callers pay for capacity they never used; disputing a shortfall is a support ticket, not a protocol.

Price every call flat, padded to cover the worst-case job

The agent signs a spending cap sized to the actual job upfront

Chase a shortfall on the hard jobs with a manual invoice

codespar_meter tracks real usage against the cap as the call runs

Let callers overpay on every easy job to cover the average

The unused difference between cap and real usage refunds on-chain

Reconcile a disputed call by hand against the server logs

The receipt reseals with the metered number, not the estimate

How the agent does it

Priced by the call, settled by the machine loop.

codespar_meter signs the spending cap before the call runs, meters the real usage as the API executes, and settles the difference on-chain the moment the job finishes. Meter has no price of its own — it rides inside codespar_pay's settlement, so Extracta pays Gate's same 1% fee on the real metered amount, not on the cap.

01
Request
Extracta API

Extraction job submitted

02
Sign cap
codespar_meter

$0.80 ceiling signed

Meter
03
Process
Extracta engine

40 pages · 61s compute

04
Meter usage
codespar_meter

$0.34 metered against cap

Meter
05
Settle + refund
codespar_pay

$0.46 refunded on-chain · resealed

Gate settlement
Architecture

The calling agent opens a session and signs a spending cap before the extraction runs. Extracta's API meters real usage — pages processed, compute time — against that cap as the job executes. When it finishes, codespar_pay settles on the metered amount and refunds the unused balance on-chain automatically; the receipt reseals with the true number under Gate's 1% settlement fee. This machine loop is built end to end and merged, running in beta behind a flag while the final mainnet verification runs complete.

In code

A few lines. The whole loop.

metered-api-access.ts
const session = await codespar.sessions.create();

const job = await session.execute("codespar_meter", {
  cap: 0.80,
  currency: "USDC",
  metric: "pages_processed",
  provider: "extracta",
});

const result = await extracta.extract({
  file: contractPdf,
  capToken: job.capToken,
});

// Extracta reports real usage back through the same cap
await session.execute("codespar_meter", {
  capToken: job.capToken,
  usage: { pages: 40, computeSeconds: 61 },
});

// codespar_pay settles on the metered amount, refunds the rest on-chain
const receipt = await session.execute("codespar_pay", { capToken: job.capToken });
// receipt.amount === "$0.34" · receipt.refunded === "$0.46" · sealed
100% · sealedreceipt · rcp_metere
Featured tools
codespar_meter

Signs the spending cap before the call runs and meters real usage against it as the job executes.

codespar_pay

Settles on the metered amount and refunds the unused cap on-chain, under Gate's 1% fee.

codespar_ledger

Reseals the receipt with the real metered number once usage settles.

See the meta-tool reference
MCP servers wired

Ship it this afternoon.

Open the sandbox, point a session at your providers, and run the whole loop against real rails in minutes — not the quarter it takes to build it by hand.

Metered API access — CodeSpar | CodeSpar