Getting started
AmberPen is a proofreading API: send text, get back the exact list of edits that corrects it —
apply them with applyEdits to reconstruct the corrected text. The @amber-pen/sdk package is a small, dependency-free Fetch client that works anywhere fetch is available — Node 18+, Bun, Deno, browsers, and edge runtimes — in both
TypeScript and JavaScript.
At its core is a purpose-built correction pipeline tuned for proofreading quality and low-latency performance.
Install
bunx jsr add @amber-pen/sdk
# or: npx jsr add @amber-pen/sdk Proofread your first text
Create a test key in the API-key dashboard—no paid plan is
required—then create a client and call proofread:
import { applyEdits, createAmberPenClient } from "@amber-pen/sdk";
const amberPen = createAmberPenClient({ apiKey });
const result = await amberPen.proofread({
text: "This are a sentnce.",
});
for (const edit of result.edits) {
console.log(`${edit.original} → ${edit.replacement}`);
}
// "are" → "is"
// "sentnce" → "sentence"
console.log(applyEdits("This are a sentnce.", result.edits));
// "This is a sentence." The response is a compact list of edits — sorted, non-overlapping replacements with
UTF-16 offsets you can pass straight to String.prototype.slice or use to highlight
changes in an editor. applyEdits(text, edits) reconstructs the corrected text.
Choose a mode
correct(default) — a single model pass corrects the text. Fastest and cheapest.evaluate— a second pass reviews each proposed edit, drops the unwarranted ones, and adds ranked replacements, acategory, and a one-sentenceexplanationto the rest. Higher precision; billed at twice the character usage ofcorrectmode.
const result = await amberPen.proofread({
text: "This are a sentnce.",
mode: "evaluate",
});
// The extra pass drops the edits it rejects and enriches the rest.
if (result.mode === "evaluate") {
for (const edit of result.edits) {
console.log(edit.category, edit.explanation, edit.possibleReplacements);
// "grammar" "The singular subject “This” takes “is”." ["is"]
}
} Handle errors
Non-successful HTTP responses throw AmberPenApiError, which carries the status code
and the parsed error body. Network and abort errors from fetch pass through
unchanged.
import { AmberPenApiError } from "@amber-pen/sdk";
try {
await amberPen.proofread({ text });
} catch (error) {
if (error instanceof AmberPenApiError) {
console.error(error.status, error.body);
} else {
throw error; // network or abort error from fetch
}
} Next steps
- Testing for free — learn the test-key limits, usage headers, and path to production.
- Custom dictionaries — preserve product terms, domain vocabulary, and names.
- SDK reference — every client option, method, and exported type.
- Incremental proofreading — pass a
textIdto only re-proofread the parts of a document that changed. - HTTP API reference — endpoints, request fields, and response shapes for integrating without the SDK.