agentsvc.io

Guide · documents and OCR

Extract text from PDFs, scans and invoices

The user hands your agent a file it cannot read: a PDF report, a scanned letter, a photo of a receipt, a Word document. These services return the text or the fields, so the model can work with them. Failed calls are not charged.

Which service

  • PDF with a text layer: pdf-extract ($0.0055) returns the full text and the text per page.
  • Image, photo or scan: ocr ($0.009) reads PNG, JPEG, WebP, TIFF and BMP with a confidence score (80 and above is reliable). Languages like deu or eng+deu.
  • DOCX, ODT, EPUB, RTF, HTML: doc-parse ($0.009) returns clean Markdown with title, author and date.
  • Invoice: invoice-extract ($0.02) turns a PDF, photo or XRechnung/ZUGFeRD file into JSON: number, dates, seller and buyer with VAT ID, line items, tax and totals, checked against each other.

Scanned PDFs

A scanned PDF has no text layer, so pdf-extract returns almost nothing. Then convert the pages to images (for example pdftoppm -png -r 200 scan.pdf page) and send each page to ocr. Invoices can go to invoice-extract directly, it reads scans too.

Try it free

curl -X POST https://agentsvc.io/api/v1/try/invoice-extract -H "Content-Type: application/json" -d '{}'

JavaScript

npm i @x402/fetch @x402/evm viem

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/invoice-extract", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ pdf_url: "https://example.com/invoice.pdf" }),
});
console.log(await res.json());

Python

pip install "x402[httpx]" eth_account

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

client = x402Client()
register_exact_evm_client(client, EthAccountSigner(Account.from_key(PRIVATE_KEY)))
async with x402HttpxClient(client) as http:
    r = await http.post("https://agentsvc.io/api/v1/proxy/invoice-extract", json={"image_url": "https://example.com/receipt.jpg"})
    await r.aread()
    print(r.json())

From the command line

Base64 makes the body large, so write it to a file first:

printf '{"pdf_base64":"%s"}' "$(base64 -w0 report.pdf)" > body.json
curl -X POST https://agentsvc.io/api/v1/proxy/pdf-extract \
  -H "Authorization: Bearer asvc_cr_..." -H "Content-Type: application/json" \
  -d @body.json | jq -r .data.text

Paying

No account and no API key. Three ways to pay, all only for calls that succeed:

  • Wallet (x402): a separate wallet with a few dollars of USDC on Base, Solana, Polygon or Arbitrum. The x402 client pays the price from the 402 answer and retries; you pay no gas.
  • Credit token: buy one at /credits ($5 to $100, USDC on Base, +10% bonus) and send it as Authorization: Bearer. Good for a script that runs through a long list.
  • Zero: if your agent already uses the Zero CLI, it pays the 402 for you: zero fetch https://agentsvc.io/api/v1/proxy/invoice-extract -d '{"pdf_url":"https://example.com/invoice.pdf"}'

Details for every client, MCP and frameworks: docs, LangChain, Vercel AI SDK.

Claude Code, Codex or Cursor can learn this as a skill: npx skills add agentsvc/skills (source).