Skip to content

Pay for Steel with x402

Beta

Set up your agent

Give your coding agent a Steel browser and the Steel skills, so that it browses and writes Steel code the right way. Learn more

Install the Steel CLI. It signs you in and installs the skills for your coding agents.

curl -fsS https://setup.steel.dev | sh

Or send this prompt to your coding agent, and it does the same:

Read https://setup.steel.dev/install.md and follow it to set up Steel for this coding client.
Then continue my requested task using the installed Steel skill.

Set up your agent →

x402 lets you call Steel's Quick actions, Scrape, Screenshot and PDF, and pay for each request with USDC from a wallet. You need no Steel account and no API key. The x402 protocol uses the HTTP status 402 Payment Required to ask for a payment, and an x402 client library pays it for you.

Steel serves x402 requests at https://x402.steel.dev. Each request costs $0.01 in USDC (10000 base units), on the network that you pay from. There is no subscription and no charge for browser time. See Pricing for the other ways to pay.

Before you begin

  • A wallet on Base or Solana that holds USDC.
  • For the program on this page, Node.js and a Base wallet's private key in the PRIVATE_KEY environment variable.

Steel accepts USDC on these networks:

NetworkUSDC contract address
Base (mainnet)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Solana (mainnet)EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

Set up the integration

Payment flow

An x402 client library does steps 2 and 3 of a paid request for you:

  1. You send a request to an endpoint. Steel returns 402 Payment Required, with the amount, networks and recipient.
  2. Your wallet signs a payment authorization for that amount.
  3. You send the request again with the signed payment in the PAYMENT-SIGNATURE header. Steel returns 200 OK with the result.

To see the payment details, send a request without a payment:

curl -i -X POST https://x402.steel.dev/v1/scrape \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "format": ["markdown"]}'

The response has the status 402 Payment Required. Its JSON body lists the payment options in accepts, one on Base and one on Solana, each for 10000 base units of USDC. The PAYMENT-REQUIRED header has the same details, encoded in base64.

Pay for a request

This program pays for one scrape with x402 and prints the result.

x402-scrape.mts
import { ExactEvmScheme } from "@x402/evm";
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const response = await fetchWithPay("https://x402.steel.dev/v1/scrape", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com", format: ["markdown"] }),
});

console.log(response.status);
console.log(await response.json());

It wraps fetch with @x402/fetch, so that it pays when Steel asks. Steel uses version 2 of the protocol. The older x402-fetch package is for version 1, and it cannot read Steel's response.

Install the libraries and run the program:

npm install @x402/fetch @x402/evm viem
npx tsx x402-scrape.mts

The program prints 200, then the scrape result as JSON. Each run pays $0.01 in USDC from the wallet.

If the wallet does not hold enough USDC, the program prints 402 and a response with the error invalid_exact_evm_insufficient_balance.

Endpoints and parameters

Every endpoint takes a POST with a JSON body and returns JSON.

EndpointWhat it does
POST /v1/scrapeLoads a page and returns it as HTML, Markdown or readable text, with a screenshot or a PDF if you ask for one.
POST /v1/screenshotTakes a screenshot of a page.
POST /v1/pdfRenders a page as a PDF.
ParameterTypeEndpointsDescription
urlstringAllThe URL of the page to load. Required.
formatstring[]ScrapeThe output formats: html, readability, cleaned_html or markdown. The default is html.
screenshotbooleanScrapeAdds a screenshot to the response.
pdfbooleanScrapeAdds a PDF to the response.
fullPagebooleanScreenshotCaptures the full page, not only the visible part.
delaynumberAllThe time to wait before the action, in milliseconds.
useProxybooleanAllRoutes the request through a residential proxy from Steel.

Next steps