endpoint
POST /v1/restyle
Takes a document, rewrites the prose in it, and gives it back with your formatting intact. This is the endpoint to use.
Request
curl https://meragpt.com/v1/restyle \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "restyler-1",
"text": "Your document here.\n\nParagraphs separated by blank lines."
}'Add "mode": "strict" to keep your wording and only remove AI tells (see strict mode).
| field | type | notes |
|---|---|---|
text | string | Required. The text to restyle. Up to 60,000 characters — roughly 10,000 words. |
model | string | Optional, defaults to restyler-1, which serves the latest Restyler 1.x (today 1.1). restyler-1.1 names the version explicitly. |
mode | string | Optional. "strict" removes AI tells and changes nothing else. Anything else, or leaving it out, is the default rewrite. |
Sending a long document
One call handles up to 60,000 characters — roughly 10,000 words, a whole long article. It is read 900 words at a time, whole paragraphs together, and comes back with your paragraph breaks as sent. For anything bigger, loop over your own sections and call once per section, which also helps with long documents under the limit:
- You get results as you go, rather than one long wait ending in everything or nothing.
- A failure costs you one section, not the whole document. Retry just that one — the rest is already done and already paid for.
- You keep your own structure. The endpoint rejoins what it splits, but only you know where a chapter ends.
Split on your own boundaries — headings, chapters, whatever the document already has — rather than at a fixed character count, which would cut a paragraph in half and hand the model a fragment. Sections can be sent concurrently.
for (const section of doc.split(/
#{1,3} /)) {
const res = await fetch('https://meragpt.com/v1/restyle', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MERAGPT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: section }),
})
const { text } = await res.json()
out.push(text)
}Over the limit you get 400 input_too_large, which names the size you sent, so you can catch it and split further.
How your document is read
Your text is split on blank lines into paragraphs, and consecutive paragraphs are rewritten together, up to 900 words at a time, so the model sees each paragraph in context. The pieces are rejoined with your own paragraph breaks. Headings, tables, list markers and code come back exactly as sent.
A paragraph comes back as you sent it, with status: "unchanged" and a reason, when its rewrite would have been wrong:
| reason | what it means |
|---|---|
invented:number, invented:url | The rewrite added a number or a link that is not in your text. |
repeat | The rewrite repeated a sentence. |
empty, runaway | The model returned nothing, or ran past the end of your text. |
structure | The rewrite merged or split paragraphs and could not be redone one paragraph at a time. |
Everything not rewritten is returned byte for byte. A request the service cannot finish is a 429 with Retry-After and is not charged; you never get a billed 200 with your own text back for lack of capacity.
Strict mode
"mode": "strict" is for text whose wording must survive: your own writing, posts, anything already approved. It keeps every word and removes the marks that make text read as machine-written: em dashes become a colon, a semicolon or parentheses, exclamation marks become full stops, and sentence-opening filler is dropped. It runs without the model, so it is not charged and returns at once. Text without those tells comes back unchanged, with reason: "no_tells".
Response
{
"id": "req_4f1c9a0b2e7d6c5a3b8e9f01",
"object": "restyle",
"model": "restyler-1",
"text": "The restyled document.",
"blocks": [
{ "index": 0, "words": 41, "status": "rewritten" },
{ "index": 1, "words": 38, "status": "unchanged", "reason": "invented:number" }
],
"rewritten": 1,
"total": 2,
"usage": {
"input_tokens": 112,
"output_tokens": 98,
"total_tokens": 210,
"cost_usd": "$0.0000202"
},
"balance_usd": "$9.99"
}blocks has one entry per paragraph, so you can see what was and was not touched without diffing the two documents yourself.
If there was nothing to rewrite
A document made entirely of headings and list items, or a strict-mode request, comes back with zero usage and no charge. That is a 200, not an error: your text is intact and the response says why.
Cost
Billed on the tokens actually processed, at the rate on the model page. Headings, tables and code are never sent to the model and cost nothing. A paragraph that was generated and then returned unchanged is billed, because the compute was spent either way. Strict mode is free.
Worked examples
The cookbooks have runnable recipes with real output, including restyling a draft and then checking that every number survived. Start with this one.