Agent API — x402 pay-per-check

Let your agent check its own chat

One POST, no API key, no signup. A panel of counter models cross-examines the conversation and returns a consensus hallucination report. Payment (when enabled) is machine-native via the x402 protocol.

Endpoint

POST https://hallucinated.chat/api/agent/check

Self-describing: a GET to the same URL returns the full request schema, the available counter models, and whether payment is currently required. POST without selections and the API answers with the multiselect questions to relay to your user. One-line integration for ANY tool-using LLM: fetch /skill.md and follow it. Machine-readable site summary at /llms.txt.

Check a conversation

curl -X POST https://hallucinated.chat/api/agent/check \
  -H "Content-Type: application/json" \
  -d '{
    "transcript": "User: When was the Eiffel Tower completed?\nAssistant: It was completed in 1887 by Antoni Gaudi.",
    "analysisTypes": ["hallucination"],
    "context": "The Eiffel Tower was completed on 31 March 1889 by Gustave Eiffel'\''s company."
  }'

Send either messages (an array of {role, content}) or transcript (raw text with User: / Assistant: lines, a JSON array, or a ChatGPT export). Optional: judgeModelIds, analysisTypes (hallucination | drift | groundedness), and context — grounding text the claims are verified against.

Response

{
  "score": 62,                     // 0-100 consensus hallucination risk
  "severity": "high",              // low | medium | high
  "judgedBy": 2,                   // counter models that returned a verdict
  "flaggedBy": 2,                  // counter models that flagged at least one claim
  "judgeResults": [{ "modelId": "gpt-5-mini", "isSuccess": true, "report": { … } }],
  "flaggedClaims": [{
    "claim": "The Eiffel Tower was designed by Antoni Gaudi",
    "quote": "designed by the architect Antoni Gaudí",
    "messageIndex": 1,
    "verdict": "contradicted",
    "confidence": 97,
    "explanation": "The grounding context names Gustave Eiffel's company.",
    "judgeName": "GPT-5 Mini"
  }]
}

Guide your user — model multiselect & expected fee

Building an agent on top of this? The recommended flow: GET this endpoint and present request.judgeModelIds.available to your user as a multiselect (every counter model ships with its per-million-token prices), then preview the fee with estimateOnly: true before asking them to pay — tokens are computed from the actual chat + context, the response size is assumed, and the x402 fee is max($0.01, 2× estimated model cost).

# Free — nothing runs, nothing is charged. Returns token counts and
# the exact final price the real check will require.
curl -X POST https://hallucinated.chat/api/agent/check \
  -H "Content-Type: application/json" \
  -d '{
    "estimateOnly": true,
    "judgeModelIds": ["claude-sonnet-5", "deepseek-v4"],
    "transcript": "User: …\nAssistant: …"
  }'
# → {"tokens": {"input": 52340, "assumedOutput": 1100},
#    "perJudge": [{"modelId": "claude-sonnet-5", "estimatedUsd": 0.139}, …],
#    "paymentEnabled": true, "expectedFeeUsdc": 0.28}

Paying with x402

When payment is enabled, the endpoint speaks x402 — the HTTP-native payment protocol built on the 402 status code. No account, no card: your agent pays per check in USDC. The first check per caller is free — try it before funding a wallet.

# 1. An unpaid request returns HTTP 402 with payment requirements:
#    {"x402Version": 1, "accepts": [{"scheme": "exact", "network": "base",
#      "maxAmountRequired": "10000", "asset": "USDC", "payTo": "0x…", …}]}
#
# 2. Sign the payment with any x402 client (e.g. the x402-fetch / x402-axios
#    packages wrap this automatically), then retry:
curl -X POST https://hallucinated.chat/api/agent/check \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <base64-signed-payment-payload>" \
  -d '{"messages": [{"role": "user", "content": "…"}, {"role": "assistant", "content": "…"}]}'
#
# 3. The settlement receipt arrives in the X-PAYMENT-RESPONSE response header.

How any agent pays — official x402 clients

Your agent needs exactly one thing: an EVM wallet key with USDC on Base. Payments are gasless EIP-3009 signatures — no ETH, no gas, no account with us. The official x402 client SDKs handle the whole 402 → sign → retry loop invisibly:

// npm i x402-fetch viem — pays automatically on 402
import { privateKeyToAccount } from "viem/accounts";
import { wrapFetchWithPayment } from "x402-fetch";

const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY);
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay("https://hallucinated.chat/api/agent/check", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ transcript: "User: …\nAssistant: …" }),
});
const report = await res.json(); // 402 → sign USDC payment → retry, invisibly
# pip install x402 eth-account — same flow for Python agents
from eth_account import Account
from x402.clients.requests import x402_requests

session = x402_requests(Account.from_key(os.environ["WALLET_PRIVATE_KEY"]))
r = session.post("https://hallucinated.chat/api/agent/check",
                 json={"transcript": "User: …\nAssistant: …"})
  • Claude / Claude Code: run the JS snippet via Bash with WALLET_PRIVATE_KEY in env — or simply say "Fetch https://hallucinated.chat/skill.md and follow it."
  • Other stacks: x402-axios (interceptor), x402-hono / x402-express for resellers, LangChain/CrewAI via the Python client.
  • Testing: set the network to base-sepolia and use faucet USDC before going to mainnet.

Give your agent a wallet — the 5-minute setup

Pick the path that matches your user. All of them end with the same thing: the agent can answer HTTP 402 with a signed USDC payment on Base.

A · Throwaway key (any agent that can run code)

# Generate a fresh throwaway wallet for your agent (never reuse your main wallet):
node -e "const a=require('viem/accounts');const k=a.generatePrivateKey();
console.log('key:',k);console.log('address:',a.privateKeyToAccount(k).address)"
# 1. Save the key as WALLET_PRIVATE_KEY in your agent's env (never in code/git).
# 2. Send a few dollars of USDC **on the Base network** to the address
#    (from Coinbase, Binance, or any exchange — pick network: Base).
# 3. Done. No ETH needed — x402 transfers are gasless for the payer.

B · Coinbase Agentic Wallet (no raw keys)

npx @coinbase/payments-mcp gives a desktop agent a managed wallet with its own funding and approval UX — the agent gets x402 tools, your user never touches a private key.

C · Cloudflare Agents SDK (hosted agents)

// Cloudflare Agents SDK — wrap any client with x402 payments
// (works against hallucinated.chat: we speak standard x402 v1 on Base)
import { privateKeyToAccount } from "viem/accounts";
import { withX402Client } from "agents/x402";

const account = privateKeyToAccount(this.env.WALLET_PRIVATE_KEY);
const client = withX402Client(baseClient, {
  network: "base",
  account,
  // human-in-the-loop: ask before every payment (or null for autonomous)
  onPaymentRequired: (payment) => this.requestUserApproval(payment),
});

D · No wallet at all

POST /api/agent/payment-link with {amountUsd} returns a one-time card checkout link your agent hands to its user — and the first check per caller is free anyway.

  • Safety rules: use a dedicated agent wallet, keep only a few dollars in it, store the key in env/secrets (never code), and top up rather than pre-fund.
  • Approval flow: have the agent preview with estimateOnly and show the user the exact price before paying — our skill does this by default, and Cloudflare's onPaymentRequired callback is the same pattern for hosted agents.
  • Receipts: every settlement returns an X-PAYMENT-RESPONSE header with the on-chain transaction — log it for your audit trail.

Available counter models

gpt-5.6-lunagpt-5.6-terraclaude-opus-5claude-sonnet-5claude-fable-5gemini-3.6-flashgemini-3.1-progrok-4.5sonar-prodeepseek-v4qwen3.8-maxkimi-k3

Default for agents: gpt-5.6-luna + deepseek-v4 (fast and cheap). Pass up to 8 counter models for a stronger consensus. Slugs are verified against the live OpenRouter catalog.