# Citation & Quote Verifier for AI Output (`plusonets/citation-claim-verifier`) Actor

Checks whether a cited page is reachable and whether the quoted passage is actually on it.

- **URL**: https://apify.com/plusonets/citation-claim-verifier.md
- **Developed by:** [Olalekan Johnson](https://apify.com/plusonets) (community)
- **Categories:** AI, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 claim checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Citation & Quote Verifier for AI Output

Check a citation before you ship it. Give this Actor a claim, a URL, and the quote the model used. It fetches the page, tells you whether that quote is actually there, and records the HTTP trail.

It is for editors, researchers, and anyone reviewing AI output who needs a flat, webhook-friendly row per citation: reachable or not, exact or fuzzy match, paywall, PDF, and the closest Wayback Machine snapshot.

Unofficial, and not affiliated with the Internet Archive, the Wikimedia Foundation, the National Archives, the W3C, OpenAI, or Anthropic. A match is evidence from the fetched text. It is not legal advice and it is not a ruling that the source is true.

### What you put in

Leave the input empty, or keep the prefilled list, to check eight public citations (real quotes, wrong quotes, a page with no quote, a dead link, and a one-page PDF). That run is meant to finish in under two minutes.

Or send your own list:

```json
{
  "items": [
    {
      "claim": "The preamble says the people ordained the Constitution to form a more perfect Union.",
      "url": "https://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "We the People of the United States, in Order to form a more perfect Union"
    }
  ]
}
```

`inlineText` accepts the same citations as JSON (an array, or an object with `items`), as CSV with `claim`, `url`, and `quote` columns, or as Markdown. A Markdown link becomes a citation. A blockquote next to that link becomes the quote.

`url` and `quote` are optional. No URL is recorded as `unsupported` and is not billed. No quote, on a page that loads, is a reachability check (`no_quote_given`).

An explicit empty `items` array does not fall back to the demo. An omitted `items` field does.

### What you get

One dataset row per citation. Offsets refer to the cleaned page text (tags removed, whitespace collapsed, spaces HTML inserts before punctuation removed). The full page is not stored. `evidenceSnippet` is a short window around the match, and `evidenceHash` is its SHA-256.

```json
{
  "resultId": "a1b2c3d4e5f678901234",
  "inputIndex": 0,
  "inputSource": "items",
  "claim": "The preamble says the people ordained the Constitution to form a more perfect Union.",
  "url": "https://www.archives.gov/founding-docs/constitution-transcript",
  "quote": "We the People of the United States, in Order to form a more perfect Union",
  "status": "verified",
  "coverage": "complete",
  "confidence": 0.95,
  "reason": "Exact quote found in the extracted page text.",
  "reachable": true,
  "httpStatus": 200,
  "finalUrl": "https://www.archives.gov/founding-docs/constitution-transcript",
  "redirectChain": "https://www.archives.gov/founding-docs/constitution-transcript (200)",
  "redirectCount": 0,
  "pageTitle": "The Constitution of the United States: A Transcription | National Archives",
  "publishedDate": null,
  "paywall": false,
  "loginWall": false,
  "isPdf": false,
  "quoteExact": true,
  "quoteFuzzy": true,
  "quoteMatchKind": "exact",
  "matchStart": 120,
  "matchEnd": 195,
  "matchCount": 1,
  "evidenceSnippet": "We the People of the United States, in Order to form a more perfect Union",
  "waybackAvailable": true,
  "waybackUrl": "https://web.archive.org/web/20261019111022/https://www.archives.gov/founding-docs/constitution-transcript",
  "llmVerdict": null,
  "llmProvider": "none",
  "charged": true,
  "chargeEvent": "claim-checked",
  "observedAt": "2026-10-23T13:00:00Z",
  "fillRate": 1,
  "schemaVersion": "1"
}
```

`status` is one of:

| Status | Meaning |
| --- | --- |
| `verified` | The quote is on the page, exactly or after normalising case, whitespace, and quotation marks. |
| `quote_not_found` | The page loaded and the quote is not in the extracted text. |
| `unreachable` | Non-success HTTP status, soft 404, or the host did not answer. |
| `paywalled` | HTTP 401/402, or a paywall/login wall, and the quote was not in the visible text. |
| `no_quote_given` | The page loaded and there was no quote to search for. |
| `blocked` | Challenge, captcha, or HTTP 429. The quote is not searched in that interstitial. |
| `unsupported` | No URL, or the URL is not allowed (private, local, `file:`). Not billed. |
| `no_results` | Nothing billable was delivered. Not billed. |

The key-value record `OUTPUT` is the run summary: counts by status, `rowsCharged`, `rowsDropped`, `fillRate`, `chargedUnits`, and error counters for `proxy`, `rate-limit`, `blocked`, `network`, and `other`.

A named store, `citation-claim-verifier-baseline`, remembers the last good observation per URL and claim. A timeout, proxy error, or other ambiguous failure does not overwrite it. Turn on `alertOnlyOnChange` to push and bill only rows whose status, match kind, or page-text hash changed.

### Pricing

This Actor uses pay-per-event pricing. Apify also charges a $0.005 start event once per run. There is no per-dataset-item charge.

| Event | When it is billed | Price |
| --- | --- | --- |
| `claim-checked` | A citation row passed validation and the fill-rate check | $0.01 |
| `llm-verdict` | A supports / neutral / contradicts verdict was parsed from your model | $0.01 extra |

You're only charged for rows that pass validation. Unsupported URLs, empty runs, ambiguous failures, and rows held back by the charge cap are not billed. The same idempotency key is not billed twice inside a run. A new run checks the pages again and can bill again.

`maxChargeUsd` stops new billing once the estimated total, using the prices above, reaches the cap. The platform's own max total charge still wins when it is set.

| Run | Billable units | Total, including the $0.005 start |
| --- | --- | --- |
| Demo, 8 checks, no model | 8 × `claim-checked` | about $0.085 |
| 100 checks, no model | 100 × `claim-checked` | about $1.005 |
| 100 checks, each with a model verdict | 100 × `claim-checked` + 100 × `llm-verdict` | about $2.005 |

1,000 results ≈ $10, plus the start event. 1,000 results that each also receive an LLM verdict ≈ $20, plus the start event.

### Scope and limits

- HTTP first. Redirects are followed manually (up to `maxRedirects`) and each hop is refused if it points at a private, loopback, or link-local address. `localhost`, `.local`, metadata hostnames, embedded credentials, and `file:` URLs are refused.
- Bodies are capped at 5 MB. PDFs use the first 30 pages. Quotes shorter than 8 characters (12 after normalisation) are not treated as matches.
- Fuzzy matching folds case, whitespace, and curly quotes or dashes. It does not do paraphrase or edit-distance matching. The quote needs to be the passage, not a summary of it.
- JavaScript-only pages can come back with almost no text (`quote_not_found`, coverage `empty`). `browserFallback` is off by default. When on, the Actor retries once with a browser-like User-Agent, then imports Playwright only if that package is installed. The published image does not include a browser, and memory stays at 512 MB (1024 MB maximum) so a real browser is not the supported path.
- Paywalls are detected, not bypassed. Captchas are not solved. A datacenter IP can be blocked; that is a `blocked` row.
- Wayback lookup calls `https://archive.org/wayback/available`. It is best-effort. A lookup error lowers coverage from `complete` to `partial` and does not fail the check.
- Optional model verdicts use your key against OpenAI (`gpt-4o-mini`) or Anthropic (`claude-3-5-haiku-latest`), temperature 0. The model sees the claim and a short excerpt, and it is told the excerpt is untrusted data. No key, or provider `none`, keeps the deterministic quote match and does not call a model. A failed model call still delivers the quote-match row and does not bill `llm-verdict`.
- At most 200 citations per run. Polite User-Agent, per-host delay, and retries for timeouts, 429, 502, and 503.
- Personal data is not a target. Do not point this at sites whose terms forbid automated access.

### Integrations

The dataset is flat and CSV-friendly. Point a webhook at the run, or pull `{{links.apiDefaultDatasetUrl}}/items` and the `OUTPUT` record.

- **Make / n8n:** HTTP module, “run an Actor”, then iterate the dataset items. Map `status`, `url`, `quoteMatchKind`, and `evidenceSnippet` into a sheet or a review queue. Use `alertOnlyOnChange` on a schedule if you only want rows that moved.
- **Google Sheets:** Apify’s Google Sheets integration, or a webhook that appends `claim`, `status`, `finalUrl`, `httpStatus`, `quoteMatchKind`, `waybackUrl`, `llmVerdict`, and `charged`.
- **Webhook:** The default dataset push is one JSON object per citation. `charged: false` with a `dropReason` means that row was stored and not billed.

### Run locally

```bash
pip install -r requirements.txt
python -m src
```

With no input in the local key-value store, the eight-citation demo runs. Tests:

```bash
pip install pytest pytest-asyncio jsonschema referencing
pytest -m "not smoke"
pytest -m smoke
```

### FAQ

**Why is a wrong quote still billed?** The page was fetched and the absence is the result. You are paying for the check, not only for hits.

**Why was a row free?** It failed validation, the URL is not allowed, the run had nothing to check, the charge cap was already hit, or alert-only mode suppressed an unchanged citation.

**Does the model see the whole page?** No. It sees the claim and a short excerpt. Quote matching does not need a model.

**Will it match a paraphrase?** No. Exact text, or the same text with different case, whitespace, or quote characters.

**Can I raise memory and turn on a browser?** You can set `browserFallback` to true, but this image has no Playwright browser. Install one only in a private build, and expect to need more than the 1024 MB cap before that path is reliable.

### Contact

Questions and bug reports: plusonecares@gmail.com. Apify username: plusonets.

# Actor input Schema

## `items` (type: `array`):

Each item is a claim, an optional source URL, and an optional quote to find on that page. Leave this empty and omit inline text to run the eight-citation demo.

## `inlineText` (type: `string`):

Optional extra citations. JSON object or array, a CSV with claim/url/quote columns, or Markdown links. A blockquote next to a link is used as the quote.

## `maxItems` (type: `integer`):

Stop after this many citations. The cap is 200.

## `maxChargeUsd` (type: `number`):

Stop billing once the estimated total reaches this amount. Uses the suggested event prices as a local estimate. The platform max total charge still applies.

## `llmProvider` (type: `string`):

Optional supports / neutral / contradicts verdict. Quote matching still runs when this is none.

## `llmApiKey` (type: `string`):

Your OpenAI or Anthropic key. Stored encrypted. Never sent anywhere except that provider.

## `llmModel` (type: `string`):

Optional model id. Empty uses gpt-4o-mini or claude-3-5-haiku-latest.

## `checkWayback` (type: `boolean`):

Ask archive.org for the closest snapshot URL. Unofficial. A lookup failure does not fail the citation check.

## `browserFallback` (type: `boolean`):

Off by default. When on, a JavaScript-empty page is retried with a browser-like User-Agent, then with Playwright only if that package is installed. The published image does not include a browser.

## `alertOnlyOnChange` (type: `boolean`):

Push and bill a citation only when its status, match kind, or page text hash changed since the last successful run.

## `dedupe` (type: `boolean`):

Skip later rows with the same claim, URL, and quote, ignoring case on the claim and quote.

## `requestTimeoutSecs` (type: `integer`):

Seconds to wait for each HTTP response.

## `maxConcurrency` (type: `integer`):

How many citations to fetch at once.

## `maxRedirects` (type: `integer`):

How many redirects to follow. Each hop is checked for private addresses.

## Actor input object example

```json
{
  "items": [
    {
      "claim": "The Constitution's preamble says the people ordained it to form a more perfect Union.",
      "url": "http://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "We the People of the United States, in Order to form a more perfect Union"
    },
    {
      "claim": "The preamble still begins with the words We the People.",
      "url": "https://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "we  the  people of the united states, in order to form a more perfect union"
    },
    {
      "claim": "The Constitution's preamble names a colony on Mars.",
      "url": "https://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "We the Robots of Mars, in Order to form a more perfect Colony"
    },
    {
      "claim": "The National Archives publishes a transcription of the Declaration of Independence.",
      "url": "https://www.archives.gov/founding-docs/declaration-transcript",
      "quote": null
    },
    {
      "claim": "Python is a high-level, general-purpose programming language.",
      "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
      "quote": "Python is a high-level, general-purpose programming language"
    },
    {
      "claim": "Python was invented by Linus Torvalds as a spreadsheet macro language.",
      "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
      "quote": "Python was invented by Linus Torvalds as a spreadsheet macro language"
    },
    {
      "claim": "A National Archives page documents this citation-verifier demo.",
      "url": "https://www.archives.gov/founding-docs/citation-claim-verifier-missing-page",
      "quote": "This page documents the citation verifier."
    },
    {
      "claim": "The W3C dummy PDF says Dummy PDF file.",
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
      "quote": "Dummy PDF file"
    }
  ],
  "inlineText": "",
  "maxItems": 50,
  "maxChargeUsd": 5,
  "llmProvider": "none",
  "llmModel": "",
  "checkWayback": true,
  "browserFallback": false,
  "alertOnlyOnChange": false,
  "dedupe": true,
  "requestTimeoutSecs": 20,
  "maxConcurrency": 4,
  "maxRedirects": 5
}
```

# Actor output Schema

## `results` (type: `string`):

Default dataset. One row per checked citation.

## `report` (type: `string`):

OUTPUT record with counts, rowsCharged, rowsDropped, fillRate, and error counters.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "items": [
        {
            "claim": "The Constitution's preamble says the people ordained it to form a more perfect Union.",
            "url": "http://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "We the People of the United States, in Order to form a more perfect Union"
        },
        {
            "claim": "The preamble still begins with the words We the People.",
            "url": "https://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "we  the  people of the united states, in order to form a more perfect union"
        },
        {
            "claim": "The Constitution's preamble names a colony on Mars.",
            "url": "https://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "We the Robots of Mars, in Order to form a more perfect Colony"
        },
        {
            "claim": "The National Archives publishes a transcription of the Declaration of Independence.",
            "url": "https://www.archives.gov/founding-docs/declaration-transcript",
            "quote": null
        },
        {
            "claim": "Python is a high-level, general-purpose programming language.",
            "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
            "quote": "Python is a high-level, general-purpose programming language"
        },
        {
            "claim": "Python was invented by Linus Torvalds as a spreadsheet macro language.",
            "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
            "quote": "Python was invented by Linus Torvalds as a spreadsheet macro language"
        },
        {
            "claim": "A National Archives page documents this citation-verifier demo.",
            "url": "https://www.archives.gov/founding-docs/citation-claim-verifier-missing-page",
            "quote": "This page documents the citation verifier."
        },
        {
            "claim": "The W3C dummy PDF says Dummy PDF file.",
            "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
            "quote": "Dummy PDF file"
        }
    ],
    "inlineText": "",
    "maxItems": 50,
    "maxChargeUsd": 5,
    "llmProvider": "none",
    "llmModel": "",
    "checkWayback": true,
    "browserFallback": false,
    "alertOnlyOnChange": false,
    "dedupe": true,
    "requestTimeoutSecs": 20,
    "maxConcurrency": 4,
    "maxRedirects": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("plusonets/citation-claim-verifier").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "items": [
        {
            "claim": "The Constitution's preamble says the people ordained it to form a more perfect Union.",
            "url": "http://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "We the People of the United States, in Order to form a more perfect Union",
        },
        {
            "claim": "The preamble still begins with the words We the People.",
            "url": "https://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "we  the  people of the united states, in order to form a more perfect union",
        },
        {
            "claim": "The Constitution's preamble names a colony on Mars.",
            "url": "https://www.archives.gov/founding-docs/constitution-transcript",
            "quote": "We the Robots of Mars, in Order to form a more perfect Colony",
        },
        {
            "claim": "The National Archives publishes a transcription of the Declaration of Independence.",
            "url": "https://www.archives.gov/founding-docs/declaration-transcript",
            "quote": None,
        },
        {
            "claim": "Python is a high-level, general-purpose programming language.",
            "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
            "quote": "Python is a high-level, general-purpose programming language",
        },
        {
            "claim": "Python was invented by Linus Torvalds as a spreadsheet macro language.",
            "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
            "quote": "Python was invented by Linus Torvalds as a spreadsheet macro language",
        },
        {
            "claim": "A National Archives page documents this citation-verifier demo.",
            "url": "https://www.archives.gov/founding-docs/citation-claim-verifier-missing-page",
            "quote": "This page documents the citation verifier.",
        },
        {
            "claim": "The W3C dummy PDF says Dummy PDF file.",
            "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
            "quote": "Dummy PDF file",
        },
    ],
    "inlineText": "",
    "maxItems": 50,
    "maxChargeUsd": 5,
    "llmProvider": "none",
    "llmModel": "",
    "checkWayback": True,
    "browserFallback": False,
    "alertOnlyOnChange": False,
    "dedupe": True,
    "requestTimeoutSecs": 20,
    "maxConcurrency": 4,
    "maxRedirects": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("plusonets/citation-claim-verifier").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "items": [
    {
      "claim": "The Constitution'\''s preamble says the people ordained it to form a more perfect Union.",
      "url": "http://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "We the People of the United States, in Order to form a more perfect Union"
    },
    {
      "claim": "The preamble still begins with the words We the People.",
      "url": "https://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "we  the  people of the united states, in order to form a more perfect union"
    },
    {
      "claim": "The Constitution'\''s preamble names a colony on Mars.",
      "url": "https://www.archives.gov/founding-docs/constitution-transcript",
      "quote": "We the Robots of Mars, in Order to form a more perfect Colony"
    },
    {
      "claim": "The National Archives publishes a transcription of the Declaration of Independence.",
      "url": "https://www.archives.gov/founding-docs/declaration-transcript",
      "quote": null
    },
    {
      "claim": "Python is a high-level, general-purpose programming language.",
      "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
      "quote": "Python is a high-level, general-purpose programming language"
    },
    {
      "claim": "Python was invented by Linus Torvalds as a spreadsheet macro language.",
      "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
      "quote": "Python was invented by Linus Torvalds as a spreadsheet macro language"
    },
    {
      "claim": "A National Archives page documents this citation-verifier demo.",
      "url": "https://www.archives.gov/founding-docs/citation-claim-verifier-missing-page",
      "quote": "This page documents the citation verifier."
    },
    {
      "claim": "The W3C dummy PDF says Dummy PDF file.",
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
      "quote": "Dummy PDF file"
    }
  ],
  "inlineText": "",
  "maxItems": 50,
  "maxChargeUsd": 5,
  "llmProvider": "none",
  "llmModel": "",
  "checkWayback": true,
  "browserFallback": false,
  "alertOnlyOnChange": false,
  "dedupe": true,
  "requestTimeoutSecs": 20,
  "maxConcurrency": 4,
  "maxRedirects": 5
}' |
apify call plusonets/citation-claim-verifier --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plusonets/citation-claim-verifier"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/BNrkiuSqszNfMdzzY/builds/kxBtkdkx6hUSMiZea/openapi.json
