Extract invoice data to JSON with verbatim quotes, confidence scores, arithmetic checks.
Send a PDF, an image or plain text and get vendor, customer, invoice number, dates, currency, totals, VAT breakdown and line items in one fixed schema. Every field carries its value, the verbatim quote it came from and a confidence score, and the totals are checked arithmetically. Documents are not stored.
$0.003 per page (max 10 pages per call) in USDC on Base via x402, or pay by card with prepaid credits (3 credits per page) · 1 free call per caller · no signup ·
POST / GET https://freetier-agent-api.pages.dev/api/invoice-json
Use invoice-json for invoices and receipts (fixed accounting schema, quotes, arithmetic checks). Use extract-json for any other short text with your own JSON schema. Use page-rag to turn a web page into Markdown for retrieval.
| Name | Type | Description |
|---|---|---|
url | string | public http(s) URL of a PDF, PNG, JPEG or WebP invoice/receipt (max 8 MB) |
text | string | invoice text instead of a file (max 40,000 chars) |
file_base64 | string | POST JSON only: base64 file content |
mime_type | string | POST JSON only: application/pdf, image/png, image/jpeg, image/webp or text/plain |
{
"document_type": {
"value": "invoice",
"quote": "Amazon Web Services Invoice",
"confidence": 0.9
},
"vendor": {
"name": {
"value": "Amazon Web Services, Inc.",
"quote": "Amazon Web Services, Inc.",
"confidence": 0.95
},
"address": {
"value": "410 Terry Ave North Seattle, WA 98109-5210, US",
"quote": "410 Terry Ave North Seattle, WA 98109-5210, US",
"confidence": 0.95
},
"vat_id": {
"value": null,
"quote": null,
"confidence": null
},
"email": {
"value": null,
"quote": null,
"confidence": null
},
"phone": {
"value": null,
"quote": null,
"confidence": null
},
"iban": {
"value": null,
"quote": null,
"confidence": null
}
},
"customer": {
"name": {
"value": "iViveLabs Limited",
"quote": "iViveLabs Limited",
"confidence": 0.95
},
"address": {
"value": "93B Sai Yu Chung Yuen Long, N.T., 0000, HK",
"quote": "93B Sai Yu Chung Yuen Long, N.T., 0000, HK",
"confidence": 0.95
},
"vat_id": {
"value": null,
"quote": null,
"confidence": null
}
},
"invoice_number": {
"value": "42183017",
"quote": "Invoice Number: 42183017",
"confidence": 0.95
},
"order_number": {
"value": null,
"quote": null,
"confidence": null
},
"issue_date": {
"value": "2014-08-03",
"quote": "Invoice Date: August 3 , 2014",
"confidence": 0.9
},
"due_date": {
"value": "2014-08-03",
"quote": "TOTAL AMOUNT DUE ON August 3 , 2014",
"confidence": 0.9
},
"currency": {
"value": "USD",
"quote": "$4.11",
"confidence": 0.9
},
"payment_terms": {
"value": null,
"quote": null,
"confidence": null
},
"totals": {
"subtotal": {
"value": 4.11,
"quote": "Charges $4.11",
"confidence": 0.98
},
"vat_total": {
"value": 0,
"quote": "Tax * $0.00",
"confidence": 0.98
},
"total": {
"value": 4.11,
"quote": "Total for this invoice $4.11",
"confidence": 0.98
},
"amount_due": {
"value": 4.11,
"quote": "TOTAL AMOUNT DUE ON August 3 , 2014 $4.11",
"confidence": 0.9
}
},
"vat_breakdown": [
{
"rate": 0,
"base": 0.01,
"amount": 0,
"quote": "VAT ** $0.00",
"confidence": 0.85
},
{
"rate": 0,
"base": 1.87,
"amount": 0,
"quote": "VAT ** $0.00",
"confidence": 0.85
}
],
"line_items": [
{
"description": "AWS Data Transfer",
"quantity": null,
"unit_price": null,
"amount": 0.01,
"vat_rate": 0,
"quote": "AWS Data Transfer $0.01",
"confidence": 0.85
},
{
"description": "Amazon Elastic Compute Cloud",
"quantity": null,
"unit_price": null,
"amount": 1.87,
"vat_rate": 0,
"quote": "Amazon Elastic Compute Cloud $1.87",
"confidence": 0.85
}
],
"checks": {
"subtotal_plus_vat_equals_total": true,
"line_items_sum_equals_subtotal_or_total": true,
"vat_breakdown_sum_equals_vat_total": true,
"due_date_not_before_issue_date": true
},
"overall_confidence": 0.94,
"missing": [
"vendor_vat_id",
"vendor_email"
],
"pages": 1,
"billed_usd": 0.003,
"input": "pdf",
"text_chars": 1839,
"model": "@cf/mistralai/mistral-small-3.1-24b-instruct",
"confidence_method": "Per field: 0.6 if the quote is found verbatim in the document text (+0.3 if the value matches the quote; 0.35 base if the quote is not verbatim), then +0.08/...",
"limits": "LLM extraction can misread layouts; check important values (quotes make that quick). Scanned PDFs need image input. Documents are not stored.",
"sources": [
{
"name": "Cloudflare Workers AI: toMarkdown (PDF text layer), Mistral Small 3.1 24B (OCR of images + field extraction; fallback Llama 3.3 70B / Llama 4 Scout / Gemma 3...",
"url": "https://developers.cloudflare.com/workers-ai/",
"note": "Documents are processed in memory and not stored or logged. No third-party LLM API."
}
]
}
curl -s -X POST https://freetier-agent-api.pages.dev/api/invoice-json \
-H 'Content-Type: application/json' \
-d '{"url":"https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/AzureInterior.pdf"}'
Buy a credit pack on Gumroad (1,000 credits $3), then send your license key. The X-Credits-Remaining response header shows your balance; failed calls are not charged.
curl -s -X POST https://freetier-agent-api.pages.dev/api/invoice-json \
-H 'X-License-Key: YOUR-LICENSE-KEY' \
-H 'Content-Type: application/json' \
-d '{"url":"https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/AzureInterior.pdf"}'
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY); // wallet with USDC on Base
const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
const res = await fetchWithPayment("https://freetier-agent-api.pages.dev/api/invoice-json", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({"url":"https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/AzureInterior.pdf"}),
});
console.log(await res.json());
# pip install "x402[httpx,evm]" eth-account
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
async def main():
client = x402Client()
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))
async with x402HttpxClient(client) as http:
r = await http.post("https://freetier-agent-api.pages.dev/api/invoice-json", json={"url":"https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/AzureInterior.pdf"})
print(r.json())
asyncio.run(main())
A bare request without parameters returns the HTTP 402 payment challenge (x402 v2 in the PAYMENT-REQUIRED header, v1 in the body). Invalid input gets a 400 before any payment.
Failed calls are never charged. Failed calls are never charged: the payment is verified first, the request runs, and the payment is settled only if it succeeded. Errors (4xx/5xx) are not settled, and invalid input is rejected before any payment or free call.
Independent monitoring of this endpoint: 402index service page (health, 30-day uptime, p50 latency).
invoice_json at https://freetier-agent-api.pages.dev/mcp (Streamable HTTP; in-band x402 payment via _meta["x402/payment"], or card credits via the X-License-Key header)Agent Extraction API by FreeTier Kits · Terms · llms.txt · /.well-known/x402 · MCP: https://freetier-agent-api.pages.dev/mcp · Contact: tec@mail.grokbot.com
This site and its texts were written with AI assistance and reviewed for accuracy; example outputs are real responses from the API.