# llms.txt Generator - llms.txt & llms-full.txt (`psx/llms-txt-generator`) Actor

Crawl a site or sitemap and generate llms.txt and llms-full.txt in the llmstxt.org format. Robots-aware, HTTP-only, validates the result. Batch domains.

- **URL**: https://apify.com/psx/llms-txt-generator.md
- **Developed by:** [psx](https://apify.com/psx) (community)
- **Categories:** AI, SEO tools, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## llms.txt Generator (llmstxt.org)

Give it a website; get a ready-to-publish **`llms.txt`** and **`llms-full.txt`** that follow the [llmstxt.org](https://llmstxt.org) proposal, so AI assistants and agents can find and read your best content. Polite HTTP-only crawl (no browser), robots.txt and sitemap aware.

### What you get

- **llms.txt**: `# Site name`, `> summary` (from the home page meta description), then `## Section` lists of `- [Page title](url): description`, grouped by first URL path segment; legal/utility pages go under `## Optional`.
- **llms-full.txt**: the same header plus the full main content of each page converted to Markdown (nav/footer/scripts stripped, size capped).
- **Validation**: the generated llms.txt is checked against the format (H1, blockquote, H2 lists, link syntax); problems land in `specProblems`.
- **Extras**: tells you whether the site already publishes `/llms.txt`.
- Files are saved in the key-value store (`<host>-llms.txt`, `<host>-llms-full.txt`) and also returned as strings in the dataset.

### Input

| Field | Default | Description |
|---|---|---|
| `urls` | required | Up to 50 sites or domains. |
| `maxPagesPerSite` | `30` | Pages fetched per site (max 200). Billed per page. |
| `useSitemap` | `true` | Use robots.txt `Sitemap:` / `/sitemap.xml` (index and .gz supported); falls back to link crawling. |
| `maxDepth` | `2` | Link-crawl depth when there is no sitemap. |
| `includeFullText` | `true` | Build llms-full.txt. |
| `maxCharsPerPage` | `20000` | Per-page cap in llms-full.txt. |
| `delayMs` / `concurrency` | `500` / `3` | Politeness controls. |
| `respectRobots` | `true` | Obey robots.txt. |

```json
{ "urls": ["https://example.com"], "maxPagesPerSite": 50 }
```

### Output (dataset, one item per site)

```json
{ "type": "llms", "siteOrigin": "https://htmx.org", "siteName": "</> htmx", "pagesIncluded": 10, "usedSitemap": true,
  "urlsDiscovered": 188, "existingLlmsTxt": false, "specProblems": [], "llmsTxt": "# </> htmx\n\n> ...", "llmsFullTxt": "...",
  "llmsTxtFile": "htmx.org-llms.txt", "skipped": { "robots": 0, "error": 0, "noindex": 0, "nonHtml": 0, "duplicateCanonical": 1 } }
```

Pages with `noindex`, HTTP errors, non-HTML content, robots-disallowed paths and duplicate content are left out.

### Pricing (pay per event; set in Apify Console)

| Event | When | Planned price |
|---|---|---|
| `apify-actor-start` | once per run | ~$0.03 |
| `page-processed` | each page fetched and included | ~$0.005 |

Charging only happens on the Apify platform. Compare: hand-writing llms.txt, or monthly SaaS generators.

### Use via API / MCP

Call it from the Apify API, the Apify MCP server, or any agent framework; the output is plain text in `llmsTxt`, ready to save at `https://yoursite/llms.txt`. Review the result before publishing: the generator picks pages heuristically.

### Politeness and safety

Identifies as `LlmsTxtGen`; obeys robots.txt; at most 2 requests in flight per host with `delayMs` spacing; pages fetched sequentially per site; only http/https; localhost, internal hosts and private/reserved IPs are refused (at connect time and on every redirect). No JavaScript execution: client-rendered sites yield little content. Public pages only.

### Run locally

```
npm install && npm test
mkdir -p storage/key_value_stores/default
echo '{"urls":["https://example.com"],"maxPagesPerSite":5}' > storage/key_value_stores/default/INPUT.json
npm start     # dataset in storage/datasets/default/, files in storage/key_value_stores/default/
```

Tested locally on example.com, sqlite.org (link crawl), htmx.org (sitemap, 188 URLs). Docker: `docker build -t llms-txt-generator . && docker run --user 996 -v <dir>:/usr/src/app/storage llms-txt-generator`.

# Actor input Schema

## `urls` (type: `array`):

Websites to generate llms.txt for (up to 50). Bare domains accepted. Only pages on the same host are used.

## `maxPagesPerSite` (type: `integer`):

Pages fetched and billed per site.

## `useSitemap` (type: `boolean`):

Discover pages through robots.txt Sitemap entries and /sitemap.xml; falls back to link crawling.

## `maxDepth` (type: `integer`):

How many link hops to follow when no sitemap is used.

## `includeFullText` (type: `boolean`):

Also build the full-content markdown file.

## `maxCharsPerPage` (type: `integer`):

Max characters per page in llms-full.txt.

## `delayMs` (type: `integer`):

Delay between requests to one host (ms).

## `concurrency` (type: `integer`):

Sites in parallel.

## `respectRobots` (type: `boolean`):

Respect robots.txt.

## Actor input object example

```json
{
  "urls": [
    "https://example.com"
  ],
  "maxPagesPerSite": 30,
  "useSitemap": true,
  "maxDepth": 2,
  "includeFullText": true,
  "maxCharsPerPage": 20000,
  "delayMs": 500,
  "concurrency": 3,
  "respectRobots": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("psx/llms-txt-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://example.com"] }

# Run the Actor and wait for it to finish
run = client.actor("psx/llms-txt-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://example.com"
  ]
}' |
apify call psx/llms-txt-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,psx/llms-txt-generator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ib5CSVrPQ3rEldQAE/builds/E1Nj6R2IqtEbU3wTw/openapi.json
