Redact, then chat
POST /api/redact-chatMask 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.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
text | string | yes | The text to work on (max 20000 chars); masked before the model sees it Also accepted as content, str, string, input, body, data. |
instruction | string | yes | What the model should do with the text (max 2000 chars); masked the same way |
restoreInAnswer | boolean | no | true puts the original values back into the answer on this server (default false: the answer keeps the placeholders) |
includeRedactedInput | boolean | no | true 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
POST /api/redact-chat$0.021 USDCPAYMENT-SIGNATUREon 14 chains200 OKAgent402-ReceiptEd25519Example 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
}| Field | Type | Always present | In the example |
|---|---|---|---|
answer | string | yes | Hi Ada, Friday at 2pm works. I will send the updated invite to ada@example.co... |
redactions | array of objects | yes | 2 items in the example |
counts | object | yes | 2 fields: email, phone |
modelTier | string | yes | v1-chat |
model | string | yes | openai/gpt-6-luna |
finishReason | string | yes | stop |
restored | number | yes | 1 |
0 | no | ||
1 | no |
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
textandinstructionare required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. Some calls are paid before they run; a failed one can be retried free with the same payment, or is refunded. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool runs a model, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - Model-backed: the answer is generated by a model, so the same input can produce a different result.
- A
GETorHEADto /api/redact-chat returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
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
Mask emails, phone numbers, credit-card-like numbers, IPs, and SSNs in text.
LLM inference
LLM inference proxy - send an OpenAI-format chat/completions request and get a response from gpt-6-luna (the default.
LLM inference (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)
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
Execute Python or JavaScript code in a secure, isolated cloud sandbox.
Code execution (Pro)
Execute Python or JavaScript code in a secure, isolated cloud sandbox (Pro tier).