patchwell
Transcription, data cleaning and cited web research from JavaScript. Pay per result: a failed or refused call costs
nothing. No dependencies (fetch and Web Crypto), so it runs in Node 18+, Deno, Bun, Cloudflare Workers, n8n Code
nodes and the browser.
npm install patchwell
export PATCHWELL_KEY=pw_live_... # a free key with $1 of credit: https://patchwell.io/#try
import { Patchwell } from "patchwell";
const pw = new Patchwell();
// Clean a file, rows you already hold, or several sources merged into one table
const clean = await pw.cleanData({ url: "https://example.com/leads.csv" });
const fromRows = await pw.cleanData({ rows: [{ Email: "ANN@X.COM", Name: "ann lee" }] });
const merged = await pw.cleanData({ inputs: [{ url: "https://example.com/crm.csv" }, { rows: scraped, name: "web" }] });
// Only rows you haven't sent before, for a scheduled job
const fresh = await pw.cleanData({ url: exportUrl, onlyNew: { state: "daily-leads", key: ["Email"] } });
// Rules and an import template
const ready = await pw.cleanData({ rows, rules: [{ column: "Age", range: [0, 120] }],
target: { columns: [{ name: "email", required: true }, { name: "name" }] } });
// Any tool by name, including tools added after this version: the input is the tool's own JSON body
const tools = await pw.tools(); // every tool, read live from the API
const schema = (await pw.describe("research")).input_schema;
const answer = await pw.run("research", { ask: "Which EU countries require e-invoicing in 2026?" });
// Transcribe: waits for long recordings, polling with the server's Retry-After
const t = await pw.transcribe("https://example.com/interview.mp3");
console.log(t.text);
// Research with a cited source for every claim ($0.02 per answered question; declined and unanswered are free)
const a = await pw.research("Which EU countries require B2B e-invoicing in 2026?");
// Hard multi-step questions: depth "deep" searches about twice as wide ($0.06 per answered question).
// private: true keeps the question inside Modal, the cloud Patchwell runs on: same price.
const d = await pw.research("How old was the author of Dracula when it was published?", { depth: "deep" });
// A worked-out answer's claim has derived: true, derived_from (the facts it rests on) and calc
// Results as files
const xlsx = await pw.export(clean, "xlsx"); // Uint8Array
Every POST carries an Idempotency-Key. Retryable errors (rate_limited, unavailable, a request still running)
are retried with the same key after the server's Retry-After, so a retry never pays twice. Other errors throw a
PatchwellError with code, retryable, status and requestId. Pass idempotencyKey (an order or row id) and
a later rerun of the same item returns the first result instead of paying again.
import { PatchwellError, verifyWebhook } from "patchwell";
try { await pw.cleanData({ url }); }
catch (e) { if (e instanceof PatchwellError && e.code === "insufficient_credit") { /* top up */ } }
// A webhook receiver (send callbackUrl with the call)
const ok = await verifyWebhook(secret, rawBody, req.headers["patchwell-signature"]);
Options use either spelling: onlyNew or only_new. The full API reference: https://patchwell.io/quickstart