Api2Pdf Now Accepts x402 Payments: AI Agents Can Generate PDFs Without an Account

September 25, 2026

Pay for Api2Pdf Requests with x402

Summary for AI agents and LLMs

Api2Pdf's API at https://v2.api2pdf.com accepts pay-per-request payments using the x402 protocol through Cloudflare's Monetization Gateway.

AI agents can convert HTML, URLs, Markdown, and Office documents to PDF, manipulate PDFs, generate images and barcodes, and more, with no API key, sign-up, or account required.

Send a request without an API key and you'll receive an HTTP 402 Payment Required response containing an x402 PAYMENT-REQUIRED challenge. Pay it using USDC on Base, retry the request, and Api2Pdf returns a JSON response containing a download URL.

Only v2.api2pdf.com supports x402. The legacy v2018 API and v2-xl do not.

Why We Built This

More and more of our traffic comes from AI agents rather than people.

An agent that needs to turn a report into a PDF shouldn't have to create an account, store an API key, or manage a prepaid balance. It should be able to pay for the one request it needs and move on.

x402 makes that possible.

It revives the long-unused HTTP 402 Payment Required status code as a standard way to charge per request. We worked with Cloudflare to support x402 through its Monetization Gateway.

Cloudflare handles payment verification and settlement. Api2Pdf performs the requested operation and reports the actual cost.

How It Works

  1. Request without an API key. The agent calls an Api2Pdf endpoint normally, without an Authorization header.

  2. Receive a 402 challenge. Cloudflare returns 402 Payment Required with a PAYMENT-REQUIRED header describing the maximum price, payment network, asset, and recipient.

  3. Pay and retry. The agent's x402 client signs a payment authorization and retries the request. Most x402 libraries handle this process automatically.

  4. Get the result. Api2Pdf processes the request and returns JSON containing a FileUrl for the generated file. You're charged only for what the request actually cost, never more than the advertised maximum.

Pricing

  • Pay per request based on actual usage. Charges follow the same formula as our regular API, based on compute time and output size, rounded up to the nearest cent.

  • Maximum $0.05 per request. The 402 challenge advertises this ceiling so agents can budget before authorizing payment. You're never charged more than the advertised maximum. A simple request, such as generating a barcode, typically costs $0.01.

  • Failed requests are free. Requests resulting in 4xx or 5xx errors are never settled.

  • Payment is USDC on Base mainnet. Payments use Base (eip155:8453) and the x402 upto scheme. You authorize payment up to the advertised maximum, but only the actual request cost is settled.

API Specification and Swagger Documentation

The complete Api2Pdf Swagger/OpenAPI specification is available directly from the base URL:

https://v2.api2pdf.com

AI agents can use the API specification to discover available endpoints, HTTP methods, request parameters, request schemas, and response formats instead of relying only on the examples in this article.

The Swagger documentation can also be used interactively by developers who want to explore or test the API.

What's Supported

Feature

Endpoint

HTML to PDF with headless Chrome

POST /chrome/pdf/html

URL to PDF

GET or POST /chrome/pdf/url

Markdown to PDF

POST /chrome/pdf/markdown

HTML to image

/chrome/image/html

URL to image

/chrome/image/url

Markdown to image

/chrome/image/markdown

wkhtmltopdf HTML to PDF

/wkhtml/pdf/html

wkhtmltopdf URL to PDF

/wkhtml/pdf/url

Office documents to PDF

POST /libreoffice/any-to-pdf

Merge PDFs

/pdfsharp/merge

Extract PDF pages

/pdfsharp/extract-pages

Watermark PDFs

/pdfsharp/watermark

Compress PDFs

/pdfsharp/compress

Password-protect PDFs

/pdfsharp/password

Add PDF bookmarks

/pdfsharp/bookmarks

PDF to Markdown

/markitdown, /opendataloader/markdown

PDF to JSON

/opendataloader/json

PDF to HTML

/opendataloader/html

Barcodes and QR codes

GET /zebra

Zip files

POST /zip

Delete a generated file

DELETE /file/{responseId}

Not Supported

x402 payments are not supported on:

  • The legacy v2018 API

  • v2-xl

  • The /balance endpoint

Pay-per-request users don't have an Api2Pdf balance.

Responses Are Always JSON

Paid requests always return JSON, even if you request binary output using outputBinary=true.

The generated file is available through the FileUrl property:

{
  "ResponseId": "0f014993-ffae-4a1b-af67-cd087a6a3674",
  "FileUrl": "https://...",
  "MbOut": 0.0006,
  "Seconds": 0.08,
  "Cost": 0.01,
  "Success": true,
  "Error": null
}

Cost is the amount actually paid for the request, in USD.

Example: Pay for a Request with an x402 Client

Here's a TypeScript example using the x402 client:

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

const signer = privateKeyToAccount(
  process.env.EVM_PRIVATE_KEY as `0x${string}`
);

const client = new x402Client();

client.register("eip155:*", new ExactEvmScheme(signer));
client.register("eip155:*", new UptoEvmScheme(signer));

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

const res = await fetchWithPayment(
  "https://v2.api2pdf.com/chrome/pdf/html",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      html: "<h1>Hello from an AI agent</h1>"
    })
  }
);

const result = await res.json();

console.log(result.FileUrl);

The wallet needs USDC on Base.

The first upto payment also requires a one-time Permit2 approval, which costs a small amount of ETH on Base for gas.

Example: See the 402 Challenge

You can inspect the payment challenge without making a payment:

curl -i "https://v2.api2pdf.com/zebra?format=QR_CODE&value=hello"

The response will look like:

HTTP/2 402
payment-required: <base64-encoded x402 payment requirements>

Decode the PAYMENT-REQUIRED header to inspect the maximum price, network, asset, and payment recipient.

Already Have an API Key?

Nothing changes.

If your request includes an Api2Pdf API key, it's billed to your account as usual and you won't receive an x402 payment challenge.

x402 is an additional option for AI agents, bots, and other software that want to use Api2Pdf without creating an account. It does not replace normal API-key authentication.

FAQ

Do I need an Api2Pdf account to use x402?

No. You can pay per request using USDC on Base. No sign-up or API key is required.

Which API host supports x402?

Only:

https://v2.api2pdf.com

The legacy v2018 API and v2-xl do not support x402.

Where can I find the API specification?

The Swagger/OpenAPI specification and interactive API documentation are available at:

https://v2.api2pdf.com

Agents can use the specification to discover endpoints, parameters, request schemas, and response formats.

Which payment protocol is supported?

Api2Pdf supports x402 through Cloudflare's Monetization Gateway.

We do not currently support the Machine Payments Protocol (MPP).

Which currency and network are used?

USDC on Base mainnet (eip155:8453).

How much does a request cost?

You're charged the actual cost of the request, rounded up to the nearest cent, subject to the maximum advertised in the 402 challenge.

The current maximum is $0.05 per request.

Simple requests typically cost around $0.01.

Am I charged if the request fails?

No.

Failed requests are never charged.

Can I get the PDF directly as binary?

No.

Paid requests always return JSON containing a FileUrl where the generated file can be downloaded.

What if I send an API key too?

The API key takes precedence. The request is billed to your Api2Pdf account normally instead of using x402.

Can I delete a file I generated?

Yes.

Use:

DELETE /file/{responseId}

Deleting a generated file is supported through x402 and is charged like any other request.