Skip to main content
The llms.txt Generator exposes a WebSocket API that allows programmatic generation of llms.txt files. This guide covers authentication, message formats, and implementation patterns.

Overview

The API uses WebSockets for real-time bidirectional communication, allowing you to:
  • Send crawl requests with custom parameters
  • Receive real-time progress updates
  • Get the generated llms.txt content
  • Retrieve hosted CDN URLs

Authentication

The API supports two authentication methods:

Setting Up API Key

Configure authentication in your backend .env file:
.env
Generate a secure API key:
Generate Key

WebSocket Endpoint

URL: wss://your-backend.com/ws/crawl Query Parameters:
  • token (string, optional): JWT authentication token
  • api_key (string, optional): Direct API key authentication
One authentication method (token or api_key) is required unless API_KEY is not configured in the backend.

Request Format

After establishing the WebSocket connection, send a JSON payload to initiate crawling:

Message Schema

string
required
The base URL of the website to crawl. Must include protocol (http:// or https://).Example: "https://example.com"
integer
default:50
Maximum number of pages to crawl.Range: 1-200Example: 50
integer
default:500
Character limit for page description excerpts.Range: 100-2000Example: 500
boolean
default:false
Enable scheduled recrawls for this site.Requires Supabase configuration.
integer
default:10080
Minutes between scheduled recrawls (default: 7 days).Only used when enableAutoUpdate is true.
boolean
default:false
Enable LLM-powered content enhancement.Requires LLM_ENHANCEMENT_ENABLED=true in backend config.
boolean
default:true
Use Brightdata proxy for JavaScript rendering.Falls back to the backend’s BRIGHTDATA_ENABLED setting if not specified.

Example Request

Response Format

The server sends JSON messages with a type and content field:

Message Types

string
Progress updates and informational messages.
string
The complete generated llms.txt content.
string
The public CDN URL where the llms.txt file is hosted.
string
Error messages when something goes wrong.

Implementation Examples

JavaScript/TypeScript

Python

Python Client

Error Handling

Connection Errors

Server-Side Errors

The server sends error messages with type: "error":
Error Message
Common error messages:
  • "Failed to fetch <url>: Connection timeout" - Target site is unreachable
  • "Invalid URL format" - URL validation failed
  • "Max pages must be between 1 and 200" - Invalid parameter
  • "Crawl interrupted" - Unexpected crawl termination

Rate Limiting

The API does not currently implement rate limiting at the application level. Consider implementing rate limiting in your client code or using a reverse proxy (CloudFlare, nginx) for production deployments.
Client-side rate limiting example:
Rate Limiting

Testing

Using wscat

Test the WebSocket API from the command line:
Install wscat
Connect and Send

Health Check

Verify the backend is running:
Health Endpoint
Expected response:

Next Steps

Configuration

Learn about all environment variables and settings

Web Interface

Use the user-friendly web UI instead of the API

API Reference

View the complete API specification

Deployment

Deploy your own instance