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": "text-restyler-1",
"text": "Your document here.\n\nParagraphs separated by blank lines."
}'| field | type | notes |
|---|---|---|
text | string | Required. A passage to restyle. Up to 6,000 characters — roughly 1,000 words. |
model | string | Optional, defaults to text-restyler-1. |
Sending a long document
One call handles up to 6,000 characters — a long article section, or roughly 1,000 words. For anything bigger, loop over your own sections and call once per section. That is how the endpoint is meant to be used, and it is better than a single large request in every way that matters:
- 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; the fleet processes several blocks at once, and requests beyond that queue rather than fail.
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 split
The model was trained on paragraph-sized blocks, so the endpoint splits on blank lines and sends each block separately. A block longer than about 80 words is split again at sentence boundaries and the pieces are rejoined, because quality falls off outside the range the model was trained on. Past roughly 120 words in one generation it starts reformatting prose into bulleted lists. Whitespace inside a block is collapsed before sending, so a hard-wrapped paragraph is not handed to the model with newlines in it.
Not everything is sent:
| reason | what it means |
|---|---|
too_short | Under 25 words. Given a fragment the model has no signal for how long the answer should be and writes a paragraph, an 8-word input has come back as 77 words. Short blocks are returned untouched. |
too_long | Over about 1,150 words in a single block. Prompt and completion share a 4,096-token window, so a block past this cannot fit. |
structural | Headings, table rows, and lines that are mostly list markers. |
no_sentence | Long enough, but with no sentence-ending punctuation, a caption, a label, a long heading. Not prose, and the model has no signal for how long the answer should be. |
code | Fenced code blocks, at any length. |
runaway | The model produced more than 1.8x the source length, which means it ran past the end of your text into invented content. The original block is kept instead. |
Everything not rewritten is returned byte for byte, whitespace included. A block that fails leaves your original text in place rather than a gap.
Response
{
"object": "restyle",
"model": "text-restyler-1",
"text": "The restyled document.",
"blocks": [
{ "index": 0, "words": 41, "status": "rewritten" },
{ "index": 1, "words": 3, "status": "unchanged", "reason": "too_short" }
],
"rewritten": 1,
"total": 2,
"usage": {
"input_tokens": 58,
"output_tokens": 49,
"total_tokens": 107,
"cost_usd": "$0.0000091"
},
"balance_usd": "$9.99",
"limits": { "max_block_words": 1150 }
}blocks is per-block reporting so you can see what was and was not touched without diffing the two documents yourself.
If nothing was long enough
A document made entirely of headings and one-line items comes back unchanged, with rewritten: 0, 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. Blocks that were skipped are never sent to the model and cost nothing. Blocks that were generated and then rejected as runaway are billed, because the compute was spent either way.