# AI Agents

This page is for AI agents and for the people who build them. It lists the machine-readable files, shows how to give an agent the API as a tool, and explains how an agent should act on the results.

## Machine-Readable Docs

Every page of these docs is available in a form an agent can read without a browser.

- [/llms.txt](https://docs.getellora.com/llms.txt) is an index of every page, with the base URL and how to authenticate.
- [/llms-full.txt](https://docs.getellora.com/llms-full.txt) has all of the documentation in one file.
- Every page is also Markdown. Add `index.md` to its URL, for example [/platform/quickstart/index.md](https://docs.getellora.com/platform/quickstart/index.md).
- [/platform/openapi.json](https://docs.getellora.com/platform/openapi.json) is the OpenAPI file, with examples for the request, the response and every error.
- [/platform/limits.json](https://docs.getellora.com/platform/limits.json) has the limits, the price and the errors as JSON, including which errors can be retried.

## How an Agent Should Use the API

1. Check that the text is English and under the limit of 100,000 characters, and work out what it will cost. [Preparing Your Text](https://docs.getellora.com/platform/preparing-your-text/) has a function for that.
2. Send the text to the API.
3. Read `findings_count`. If `red` is `0`, the text passes and you may stop. Yellow findings need a judgment call, so follow the rule you were given or ask the person.
4. Otherwise, rewrite the sentences that have red findings. The `excerpt` shows the sentence, and the `reason` and `suggestion` are hints. Change only what the findings point at.
5. Send the new text. Stop when `red` is `0`, or after a fixed number of passes, three being a sensible limit, and tell the person what is left.
6. Handle errors as [Reliability](https://docs.getellora.com/platform/reliability/) describes. Retry a `429` and a `500`, and nothing else.

## Giving an Agent the API as a Tool

Most agent frameworks take a tool as a name, a description and a schema for its input. This definition is ready to use with the Anthropic API.

```json
{
  "name": "check_text_for_ai_slop",
  "description": "Checks English text for AI-slop patterns and returns findings, each with a severity (red, yellow or blue), the sentence it is about, an excerpt, a reason and a short suggestion. It never rewrites the text and gives no score. Use it on a draft before you show it to the person: fix every red finding, then check again.",
  "input_schema": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string",
        "description": "The English text to check, as plain text or Markdown. Up to 100,000 characters."
      }
    },
    "required": [
      "text"
    ]
  }
}
```

This is the same tool for the OpenAI API.

```json
{
  "type": "function",
  "function": {
    "name": "check_text_for_ai_slop",
    "description": "Checks English text for AI-slop patterns and returns findings, each with a severity (red, yellow or blue), the sentence it is about, an excerpt, a reason and a short suggestion. It never rewrites the text and gives no score. Use it on a draft before you show it to the person: fix every red finding, then check again.",
    "parameters": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string",
          "description": "The English text to check, as plain text or Markdown. Up to 100,000 characters."
        }
      },
      "required": [
        "text"
      ]
    }
  }
}
```

When the model calls `check_text_for_ai_slop`, your code sends the text to the API and returns the result. The function below keeps only the fields an agent needs, which saves space in its context.

```python
# detect_with_retries is the function from the Reliability guide.
def check_text_for_ai_slop(text: str) -> dict:
    result = detect_with_retries(text)
    return {
        "counts": result["findings_count"],
        "findings": [
            {key: finding[key] for key in ("severity", "sentence", "excerpt", "reason", "suggestion")}
            for finding in result["findings"]
        ],
        "cost_usd": result["cost"],
    }
```

## Keeping the Key Safe

Keep the API key in the environment of the code that runs the tool. Never put it in a prompt, a tool description or a log. The API never echoes your text back in an error, so a failed call does not leak it either.

## Controlling Cost

Every pass is charged by the words in the text, so a loop with no limit has no limit on cost either. Give the agent a maximum number of passes. A `402 insufficient_credit` means the workspace is out of credit. Stop, and tell the person, because sending the request again will not help. [Credit and Billing](https://docs.getellora.com/platform/credit-and-billing/) explains how credit works.

Source: https://docs.getellora.com/platform/ai-agents/
