# Preparing Your Text

You may send plain text or Markdown. This guide explains what the API does with what you send, how long it may be, and what you are charged for.

## Plain Text or Markdown

You may send plain text or Markdown, and common HTML tags are understood too. Before it checks anything, the API turns what you sent into plain text. That means a sentence in a bullet, a heading or a bold phrase is checked just like a sentence in a paragraph.

Send the text as you have it. You do not need to strip the formatting first, because the API also looks at the formatting itself, such as headings and lists.

## What Is Checked and What Is Skipped

| In your text | What the API does |
| --- | --- |
| Headings, list items and quotes | The words are checked. The markers (`#`, `-`, `1.`, `>`) are removed. |
| Bold and italic text | The words are checked. The marks are removed. |
| Link text | The words are checked. The address is skipped. |
| Table cells | Each cell is checked as its own sentence. |
| Words inside common HTML tags | The words are checked. The tags are removed. |
| Code, in fenced blocks or inline | Skipped, because code is not prose. |
| Web addresses | Skipped. |
| Images | Skipped, including the alt text. |
| Dividers and HTML comments | Skipped. |
| Footnote marks and link definitions | Skipped. |

Code that is indented but not fenced is not recognised as code, so its words are checked like any other text. A line that is wrapped in the middle of a sentence is joined to the next one, so a phrase that crosses a line break is still found.

## Sentence Numbers and Excerpts

Findings refer to the text after it has been turned into plain text. Sentence 1 is the first sentence of the prose, after any code, divider or comment, and an excerpt is the words of that sentence without any Markdown marks.

The API does not return character offsets. To find a finding in your original, search for a few words from its excerpt.

## Length

Each request may contain up to 100,000 characters. Characters are Unicode characters, not bytes, so an accented letter or an emoji counts as one. Whitespace at the start and end is removed before the text is checked.

Text that is empty, or only whitespace, is rejected with `400 invalid_request`. Text over the limit is rejected with `413 text_too_large`.

For a longer document, send it in parts and add up the results. Split it at paragraph breaks, so that no sentence is cut in two. Each part is a separate call. Sentence numbers start again at 1 in every part. Findings about the text as a whole (scope `document`) are reported for each part, not for the whole document.

```python
def split_text(text: str, limit: int = 100_000) -> list[str]:
    parts, current = [], ""
    for paragraph in text.split("\n\n"):
        if len(paragraph) > limit:
            raise ValueError("A paragraph is longer than the limit; split it at a sentence.")
        if current and len(current) + len(paragraph) + 2 > limit:
            parts.append(current)
            current = ""
        current = f"{current}\n\n{paragraph}" if current else paragraph
    if current:
        parts.append(current)
    return parts
```

## Language

The API supports English text only. Other languages are not supported.

## What You Are Charged For

You are charged for the words in what you send, before it is turned into plain text. So the words in code, links and markup count too, even though they are skipped when the text is checked. If you do not want to pay for them, remove them before you send. The [API Reference](https://docs.getellora.com/platform/api/) has the exact rule for counting words.

You can work out the cost before you send. The price is $0.10 per 1,000 words, and the API rounds the cost up to the next micro-dollar. This counting rule matches the API's for English text.

**Python**

```python
PRICE_PER_1000_WORDS = 0.10  # US dollars


def count_words(text: str) -> int:
    """Counts words the way the API charges for them (for English text)."""
    return sum(1 for piece in text.split() if any(ch.isalnum() for ch in piece))


def estimate_cost(text: str) -> float:
    return count_words(text) / 1000 * PRICE_PER_1000_WORDS
```

**JavaScript**

```javascript
const PRICE_PER_1000_WORDS = 0.10; // US dollars

// Counts words the way the API charges for them (for English text).
const countWords = (text) => text.split(/\s+/).filter((piece) => /[\p{L}\p{N}]/u.test(piece)).length;

const estimateCost = (text) => (countWords(text) / 1000) * PRICE_PER_1000_WORDS;
```

Source: https://docs.getellora.com/platform/preparing-your-text/
