Images to PDF

$0.004 per callUSDC via x402POST /api/images-to-pdf

Combine 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.

Category: Web & documentsTags: pdf images convert convert-pdf documents

Try in playground →

Parameters

NameTypeRequiredDescription
urlsarrayyes1–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…"
}
FieldTypeAlways presentIn the example
pagesnumberyes2
bytesnumberyes16753
pdfBase64stringyesJVBERi0xLjcK…

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 an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp.

Errors and behavior

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?.({ maxAmountPerPayment: "$0.004" }); // refuse any quote above this tool's price
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:

Related tools

Extract / split PDF pages

$0.003 · POST /api/pdf-extract-pages

Pull a subset of pages into a new PDF (split).

PDF info

$0.001 · POST /api/pdf-info

Inspect a PDF without downloading the whole thing into your model: page count, title, author, subject, creator.

Merge PDFs

$0.004 · POST /api/pdf-merge

Combine several PDFs into one, in order.

Rotate PDF

$0.003 · POST /api/pdf-rotate

Rotate pages by 90/180/270°.

PDF to Markdown

$0.003 · POST /api/pdf-to-markdown

Convert a PDF to clean markdown: headings, paragraphs, and bullets reconstructed from the text layer - ready to drop.

PDF to text

$0.01 · POST /api/pdf

Fetch a PDF from a URL and extract its text content.