The llms.txt Generator includes an optional LLM enhancement feature that uses Grok 4.1-Fast (via OpenRouter) to improve the quality, clarity, and structure of generated content. This AI-powered optimization makes the output more useful for LLM consumption while preserving all original URLs and information.
LLM enhancement is optional and requires an OpenRouter API key. The original content is always returned if enhancement fails or is disabled.
The LLM must preserve all URLs from the original content. Any output that modifies, removes, or adds URLs is rejected and the original is used instead.
Strict validation ensures the enhanced content meets quality standards:
backend/llm_processor/validator.py
def validate_llms_txt(content: str, original_urls: list[str]) -> tuple[bool, list[str]]: errors = [] # Extract URLs from enhanced content enhanced_urls = extract_urls(content) # Check that all original URLs are preserved missing_urls = set(original_urls) - set(enhanced_urls) if missing_urls: errors.append(f"Missing {len(missing_urls)} URLs from original") # Check for unexpected new URLs extra_urls = set(enhanced_urls) - set(original_urls) if extra_urls: errors.append(f"Added {len(extra_urls)} URLs not in original") # Ensure content is not empty if not content.strip(): errors.append("Enhanced content is empty") # Ensure reasonable length if len(content) < 100: errors.append("Enhanced content too short") return (len(errors) == 0, errors)
LLM enhancement is configured via environment variables:
backend/.env
# Enable LLM enhancement featureLLM_ENHANCEMENT_ENABLED=true# OpenRouter API key (required if enabled)OPENROUTER_API_KEY=sk-or-v1-...# Model selectionOPENROUTER_MODEL=x-ai/grok-2-1212# Timeout and retriesLLM_TIMEOUT_SECONDS=60LLM_MAX_RETRIES=2# Temperature (0.0 = deterministic, 1.0 = creative)LLM_TEMPERATURE=0.3
# Acme Corp## Homehttps://acme.com> Home page Acme Corp leading provider solutions## Productshttps://acme.com/products> Our products page products we offer## Abouthttps://acme.com/about> About page learn more
After (LLM Enhanced):
# Acme Corp DocumentationComprehensive documentation for Acme Corp's products and services.## Getting Started### Homepagehttps://acme.com> Acme Corp is a leading provider of enterprise software solutions, specializing in cloud infrastructure and developer tools. The homepage provides an overview of the company's mission, key products, and customer success stories.## Products & Services### Product Cataloghttps://acme.com/products> Browse Acme Corp's complete product portfolio, including cloud hosting, database solutions, and CI/CD platforms. Each product page includes pricing, features, and integration guides.## Company Information### About Ushttps://acme.com/about> Learn about Acme Corp's history, team, and values. Founded in 2015, the company has grown to serve over 10,000 customers worldwide with a focus on developer experience and reliability.
Notice how the enhanced version adds context, organizes sections, improves descriptions, and maintains all original URLs.
Check: LLM_ENHANCEMENT_ENABLED=true and valid OPENROUTER_API_KEY in .envVerify: OpenRouter API key has credits and is active
Rate limit errors
Cause: Too many requests in short time periodSolution: OpenRouter has rate limits per key. Wait 60 seconds between requests or upgrade your OpenRouter plan.
Validation failures
Cause: LLM output modified or removed URLsSolution: Try a different model. Grok and Claude are very reliable at preserving URLs. GPT-4 occasionally needs more guidance.
Timeout errors
Cause: LLM took longer than LLM_TIMEOUT_SECONDS to respondSolution: Increase timeout to 90-120 seconds, or reduce input size by lowering maxPages.