cookbook · Restyler 1 · Content editing
Restyle a draft, then check the numbers
AI-written drafts often come back padded with filler and hype, making them hard to send as-is. This recipe runs a product update through Restyle to strip the fluff, then uses a ten-line regex check to confirm that every number in the original survived the rewrite.
The draft
We are thrilled to announce that our latest update delivers a seamless and robust experience. In today's fast-paced world, exports now run up to 3x faster, and you can schedule them for 6am daily. Furthermore, we have introduced a comprehensive dark mode that elevates your workflow to new heights.
Request
POST /v1/restyle, documented in the Restyler 1 reference.
curl https://meragpt.com/v1/restyle \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-restyler-1",
"text": "We are thrilled to announce that our latest update delivers a seamless and robust experience. In today'\''s fast-paced world, exports now run up to 3x faster, and you can schedule them for 6am daily. Furthermore, we have introduced a comprehensive dark mode that elevates your workflow to new heights."
}'What came back
The real output from running this recipe, unedited.
{
"text": "Exports are now running up to 3x faster than before! You can also schedule them for 6am daily. We’ve added a dark mode option too, which will make your life easier in the dark."
}Python
import os, requests
API = "https://meragpt.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MERAGPT_API_KEY']}"}
import re
draft = "We are thrilled to announce that our latest update delivers a seamless and robust experience. In today's fast-paced world, exports now run up to 3x faster, and you can schedule them for 6am daily. Furthermore, we have introduced a comprehensive dark mode that elevates your workflow to new heights."
r = requests.post(f"{API}/restyle", headers=HEADERS, json={"model": "text-restyler-1", "text": draft}).json()
rewrite = r["text"]
# every number in the draft must still be in the rewrite
numbers = lambda s: set(re.findall(r"\d+(?:[.,]\d+)?", s))
missing = numbers(draft) - numbers(rewrite)
if missing:
raise ValueError(f"numbers lost in the rewrite: {missing}")
print(rewrite) # a person still reads it before it goes out
TypeScript
const API = "https://meragpt.com/v1";
const headers = {
Authorization: `Bearer ${process.env.MERAGPT_API_KEY}`,
"Content-Type": "application/json",
};
const draft = "We are thrilled to announce that our latest update delivers a seamless and robust experience. In today's fast-paced world, exports now run up to 3x faster, and you can schedule them for 6am daily. Furthermore, we have introduced a comprehensive dark mode that elevates your workflow to new heights.";
const r = await fetch(`${API}/restyle`, {
method: "POST",
headers,
body: JSON.stringify({ model: "text-restyler-1", text: draft }),
}).then((res) => res.json());
// every number in the draft must still be in the rewrite
const numbers = (s: string) => new Set(s.match(/\d+(?:[.,]\d+)?/g) ?? []);
const kept = numbers(r.text);
const missing = [...numbers(draft)].filter((n) => !kept.has(n));
if (missing.length) throw new Error(`numbers lost in the rewrite: ${missing.join(", ")}`);
console.log(r.text); // a person still reads it before it goes out
When to trust it
The numbers are trustworthy here because the regex check verifies them programmatically. But Restyle can add new content, such as the clause about dark mode making your life easier, so a person should still read the result before sending.
Try it without code in the playground.