Skip to content

Redact, then chat

$0.021 per callUSDC via x402POST /api/redact-chat

Mask personal details in a text on this server, then send only the masked text to a chat model, in one paid call. Send POST /api/redact-chat with the required fields text and instruction and pay $0.021 per call over x402 or MPP (there is no free tier). It returns a JSON object with answer, redactions, counts, modelTier, model and 2 more.

Email addresses, card-like runs of 13 to 16 digits, US SSNs written 123-45-6789, US-style phone numbers (ten digits, with an optional short country prefix) and IPv4 addresses are replaced with numbered placeholders ([EMAIL_1], [PHONE_1]) by the same pattern matching as /api/redact, before the model call; the model receives the masked instruction and text, not the values that were masked. Pattern matching can miss details written in other forms: international phone numbers, SSNs without dashes, IPv6 addresses, longer card or account numbers such as IBANs, names and street addresses pass unmasked, so review the text for anything else sensitive. restoreInAnswer: true puts the originals back into the answer on this server after the model replies. includeRedactedInput: true also returns the masked text that was sent. The chat runs on the /v1/chat/completions gateway tier with its default model; the price is the sum of /api/redact and that tier. Text up to 20000 chars and instruction up to 2000, checked before any model call. A failed chat step answers an error and is not charged on x402, card and credits. Some calls are paid before they run; a failed one can be retried free with the same payment, or is refunded. Model-backed.

Category: AI & computeTags: pii privacy mask llmAlso found as: redacted-chat

Try in playground →

Parameters

NameTypeRequiredDescription
textstringyesThe text to work on (max 20000 chars); masked before the model sees it Also accepted as content, str, string, input, body, data.
instructionstringyesWhat the model should do with the text (max 2000 chars); masked the same way
restoreInAnswerbooleannotrue puts the original values back into the answer on this server (default false: the answer keeps the placeholders)
includeRedactedInputbooleannotrue also returns the masked instruction and text that were sent to the model (default false)

Example request

curl -i -X POST https://agent402.tools/api/redact-chat \
  -H "Content-Type: application/json" \
  -d '{"instruction":"Write a short, polite reply confirming the new meeting time.","text":"Hi, this is ada@example.com (555-123-4567). Can we move our call to Friday at 2pm?","restoreInAnswer":true}'

Without payment this returns HTTP 402 Payment Required with the exact price for redact-chat; any x402 v2 or MPP client pays it and retries.

Watch a call get paid

RequestPOST /api/redact-chat
402$0.021 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example response

{
  "answer": "Hi Ada, Friday at 2pm works. I will send the updated invite to ada@example.com. Thanks!",
  "redactions": [
    {
      "type": "email",
      "placeholder": "[EMAIL_1]"
    },
    {
      "type": "phone",
      "placeholder": "[PHONE_1]"
    }
  ],
  "counts": {
    "email": 1,
    "phone": 1
  },
  "modelTier": "v1-chat",
  "model": "openai/gpt-6-luna",
  "finishReason": "stop",
  "restored": 1
}
FieldTypeAlways presentIn the example
answerstringyesHi Ada, Friday at 2pm works. I will send the updated invite to ada@example.co...
redactionsarray of objectsyes2 items in the example
countsobjectyes2 fields: email, phone
modelTierstringyesv1-chat
modelstringyesopenai/gpt-6-luna
finishReasonstringyesstop
restorednumberyes1
0no
1no

From an MCP client

catalog.call {
  "slug": "redact-chat",
  "params": {
    "instruction": "Write a short, polite reply confirming the new meeting time.",
    "text": "Hi, this is ada@example.com (555-123-4567). Can we move our call to Friday at 2pm?",
    "restoreInAnswer": true
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for redact-chat; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.16.0.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.021" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/redact-chat", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "instruction": "Write a short, polite reply confirming the new meeting time.",
    "text": "Hi, this is ada@example.com (555-123-4567). Can we move our call to Friday at 2pm?",
    "restoreInAnswer": true
  }),
});

Related tools

Redact PII

FREE w/ computeor $0.001POST /api/redact

Mask emails, phone numbers, credit-card-like numbers, IPs, and SSNs in text.

LLM inference

$0.01POST /api/llm

LLM inference proxy - send an OpenAI-format chat/completions request and get a response from gpt-6-luna (the default.

LLM inference (Premium)

$0.50POST /api/llm-premium

LLM inference proxy (Premium tier) - gpt-5.6-terra reasoning model (the older o3, o3-pro, o3-mini and o4-mini ids are.

LLM inference (Pro)

$0.10POST /api/llm-pro

LLM inference proxy (Pro tier) - gpt-6-luna by default, or gpt-6.1-sol, GPT-4o or GPT-4.1 by its id.

Code execution

$0.02POST /api/code-run

Execute Python or JavaScript code in a secure, isolated cloud sandbox.

Code execution (Pro)

$0.05POST /api/code-run-pro

Execute Python or JavaScript code in a secure, isolated cloud sandbox (Pro tier).