Images to PDF
POST /api/images-to-pdfCombine PNG/JPEG images into a single PDF, one image per page. Send POST /api/images-to-pdf with the required field urls and pay $0.004 per call over x402 or MPP (there is no free tier). It returns a JSON object with pages, bytes and pdfBase64.
Body: {"urls":["https://…/1.png","https://…/2.jpg"]}. Returns the PDF as base64.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
urls | array | yes | 1–20 public PNG/JPEG image URLs |
Example request
curl -i -X POST https://agent402.tools/api/images-to-pdf \
-H "Content-Type: application/json" \
-d '{"urls":["https://agent402.tools/fixtures/sample-image.png","https://agent402.tools/fixtures/sample-image.png"]}'
Without payment this returns HTTP 402 Payment Required with the exact price for images-to-pdf; any x402 v2 or MPP client pays it and retries.
Example response
{
"pages": 2,
"bytes": 16753,
"pdfBase64": "JVBERi0xLjcK…"
}
| Field | Type | Always present | In the example |
|---|---|---|---|
pages | number | yes | 2 |
bytes | number | yes | 16753 |
pdfBase64 | string | yes | JVBERi0xLjcK… |
From an MCP client
catalog.call {
"slug": "images-to-pdf",
"params": {
"urls": [
"https://agent402.tools/fixtures/sample-image.png",
"https://agent402.tools/fixtures/sample-image.png"
]
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for images-to-pdf; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
urlsis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/images-to-pdf returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/images-to-pdf", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"urls": [
"https://agent402.tools/fixtures/sample-image.png",
"https://agent402.tools/fixtures/sample-image.png"
]
}),
});
Part of these workflows
Images to PDF is one step in this skill pack, each sold as a single call:
- Document intelligence - Turn any PDF or image URL into structured data - metadata, extracted text, sliced page ranges, OCR for scanned docs, decoded barcodes / QR codes - without falling back to a vision LLM guess. Built for the messy 30% of documents where pdf-to-markdown alone returns nothing useful.
Related tools
Extract / split PDF pages
POST /api/pdf-extract-pagesPull a subset of pages into a new PDF (split). Body: {"url":"https://…/file.pdf","pages":"1-3,5"}. Returns the new PDF a…
PDF info
POST /api/pdf-infoInspect a PDF without downloading the whole thing into your model: page count, title, author, subject, creator, producer…
Merge PDFs
POST /api/pdf-mergeCombine several PDFs into one, in order. Body: {"urls":["https://…/a.pdf","https://…/b.pdf"]}. Returns the merged PDF as…
Rotate PDF
POST /api/pdf-rotateRotate pages by 90/180/270°. Body: {"url":"https://…/file.pdf","degrees":90,"pages":"1-3"?}. Omit "pages" to rotate all.…
PDF to Markdown
POST /api/pdf-to-markdownConvert a PDF to clean markdown: headings, paragraphs, and bullets reconstructed from the text layer - ready to drop int…
PDF to text
POST /api/pdfFetch a PDF from a URL and extract its text content. Returns page count, document info, and the full text (up to 20MB PD…