Guides
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 is an index of every page, with the base URL and how to authenticate.
- /llms-full.txt has all of the documentation in one file.
- Every page is also Markdown. Add
index.mdto its URL, for example /platform/quickstart/index.md. - /platform/openapi.json is the OpenAPI file, with examples for the request, the response and every error.
- /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
- Check that the text is English and under the limit of 100,000 characters, and work out what it will cost. Preparing Your Text has a function for that.
- Send the text to the API.
- Read
findings_count. Ifredis0, the text passes and you may stop. Yellow findings need a judgment call, so follow the rule you were given or ask the person. - Otherwise, rewrite the sentences that have red findings. The
excerptshows the sentence, and thereasonandsuggestionare hints. Change only what the findings point at. - Send the new text. Stop when
redis0, or after a fixed number of passes, three being a sensible limit, and tell the person what is left. - Handle errors as Reliability describes. Retry a
429and a500, 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.
{
"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.
{
"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.
# 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 explains how credit works.