# OpenAI Agents SDK: check several quotes on one page

Last updated: 2026-10-12

An OpenAI Agents SDK agent that checks up to 20 quotes from one web page in one call to `POST /v1/verify/quotes` before it cites them. Price: US$0.02 per call, for 1 to 20 quotes. Each quote comes back `exact`, `fuzzy` or `none`, with offsets and context, plus the page's verdict and an Ed25519-signed receipt. Payments are in USDC with x402 v2 on Base mainnet (real USDC).

Two ways to connect: the `quoteproof-mcp` server over stdio (no client code), or plain HTTP with x402.

The same check for other frameworks: [LangChain](https://vehcdj664efetfrsolne5umanq.srv.us/examples/langchain.md), [LlamaIndex](https://vehcdj664efetfrsolne5umanq.srv.us/examples/llamaindex.md) and [Claude Agent SDK](https://vehcdj664efetfrsolne5umanq.srv.us/examples/claude-agent-sdk.md).

## Install

Node.js 20 or later.

```sh
npm init -y && npm pkg set type=module
npm install @openai/agents zod
export OPENAI_API_KEY=...
```

`quoteproof-mcp` needs no install: `npx` fetches version 0.1.33 from [`/dl`](https://vehcdj664efetfrsolne5umanq.srv.us/dl/index.json), which lists its sha256. To pay, set `QUOTEPROOF_X402_KEY` to the private key (`0x` and 64 hex digits) of a wallet holding a little USDC. The key stays in the MCP server's process.

## With the MCP server

```js
// agent-mcp.mjs: checks quotes with attestpage_verify_quotes before citing them.
import { Agent, MCPServerStdio, run } from '@openai/agents';

const ORIGIN = 'https://vehcdj664efetfrsolne5umanq.srv.us';
const env = { QUOTEPROOF_URL: ORIGIN, QUOTEPROOF_MAX_USD: '0.02', QUOTEPROOF_SESSION_USD: '0.20' };
if (process.env.QUOTEPROOF_X402_KEY) env.QUOTEPROOF_X402_KEY = process.env.QUOTEPROOF_X402_KEY;

const attestpage = new MCPServerStdio({
  name: 'attestpage',
  command: 'npx',
  args: ['-y', `${ORIGIN}/dl/quoteproof-mcp-0.1.33.tgz`],
  env,
});
await attestpage.connect();

try {
  const agent = new Agent({
    name: 'Source checker',
    instructions: 'Before you quote a web page, call attestpage_verify_quotes once with the url and every quote you plan to use. '
      + 'Cite a quote only when its match is exact or fuzzy and page.content_kind is real. '
      + 'If a tool fails with trial_exhausted or payment_refused_locally, give the price and stop.',
    mcpServers: [attestpage],
  });
  const result = await run(agent, 'Does https://www.iana.org/help/example-domains say "These domains may be used as '
    + 'illustrative examples in documents" and "without prior coordination with us"?');
  console.log(result.finalOutput);
} finally {
  await attestpage.close();
}
```

```sh
node agent-mcp.mjs                             # free trial
QUOTEPROOF_X402_KEY=0x... node agent-mcp.mjs   # pays US$0.02 per call in USDC
```

The server refuses any offer above `QUOTEPROOF_MAX_USD` with `payment_refused_locally` and signs nothing.

## With HTTP and x402

```sh
npm install @x402/fetch @x402/evm viem
```

```js
// agent-http.mjs: the same check as a function tool that pays with x402.
import { Agent, run, tool } from '@openai/agents';
import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { registerExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';
import { z } from 'zod';

const ORIGIN = 'https://vehcdj664efetfrsolne5umanq.srv.us';
const MAX_UNITS = 20000; // US$0.02 in USDC (6 decimals): the most one call may cost

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.ATTESTPAGE_X402_KEY) });
client.registerPolicy((_version, reqs) => reqs.filter((r) => r.network === 'eip155:8453' && Number(r.amount) <= MAX_UNITS));
const payingFetch = wrapFetchWithPayment(fetch, client);

const verifyQuotes = tool({
  name: 'verify_quotes',
  description: 'Use before quoting one web page several times: checks 1 to 20 quotes against the page at url. '
    + 'Returns results[i].match (exact, fuzzy or none), page.content_kind and a signed receipt. US$0.02 per call.',
  parameters: z.object({ url: z.string(), quotes: z.array(z.string()).min(1).max(20) }),
  execute: async ({ url, quotes }) => {
    try {
      const res = await payingFetch(`${ORIGIN}/v1/verify/quotes`, {
        method: 'POST',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ url, quotes }),
      });
      return await res.json();
    } catch (e) {
      return { error: e.message }; // payment refused by the policy above, network error: tell the agent why
    }
  },
});

const agent = new Agent({
  name: 'Source checker',
  instructions: 'Before you quote a web page, call verify_quotes once with every quote you plan to use from it. '
    + 'Cite a quote only when its match is exact or fuzzy and page.content_kind is real. '
    + 'If the tool returns an error, say what it was and stop.',
  tools: [verifyQuotes],
});
console.log((await run(agent, process.argv.slice(2).join(' '))).finalOutput);
```

```sh
ATTESTPAGE_X402_KEY=0x... node agent-http.mjs 'Does https://www.iana.org/help/example-domains say "without prior coordination with us"?'
```

The first request gets a 402 with the price in the `PAYMENT-REQUIRED` header; `@x402/fetch` signs the payment and sends it again. The policy keeps only offers on Base (`eip155:8453`) of at most US$0.02; anything else is refused before anything is signed, and the tool returns the reason as `error`. A request the service refuses (bad URL, empty quote) is refused before payment and not charged.

## What comes back

- `results[i].match`: `exact`, `fuzzy` or `none`, in the order of `quotes`. Read `page.content_kind` first: `none` on a `bot_wall` or `js_shell` page means the page could not be read.
- `receipt`: a signed JWS of what the fetcher saw and when. `POST /v1/receipt/verify` checks it for free, or check it offline with [`verify-receipt.mjs`](https://vehcdj664efetfrsolne5umanq.srv.us/docs/verify-offline).
- Try the answer shape first with the free sample: `GET https://vehcdj664efetfrsolne5umanq.srv.us/v1/sample/quotes`.

## Terms

Pay per call, no account. See [Payments](https://vehcdj664efetfrsolne5umanq.srv.us/docs/payments), [Limits](https://vehcdj664efetfrsolne5umanq.srv.us/docs/limits) and the [Terms](https://vehcdj664efetfrsolne5umanq.srv.us/terms).
