Skip to main content

Overview

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.

How It Works

1

Initial Crawl

The crawler extracts raw content from the website:
backend/main.py
2

Enhancement Request

If enabled, the content is sent to the LLM processor:
backend/main.py
3

Validation

The enhanced content is validated to ensure quality:
backend/llm_processor/processor.py
4

Fallback on Failure

If enhancement fails, the original content is used:
backend/llm_processor/processor.py

What Gets Enhanced?

The LLM optimization focuses on:

Clarity

  • Rewrites awkward or unclear descriptions
  • Removes boilerplate and redundant text
  • Improves grammar and readability

Structure

  • Organizes content into logical sections
  • Adds hierarchy where appropriate
  • Groups related pages together

Completeness

  • Fills in missing context
  • Expands terse descriptions
  • Adds relevant details

Consistency

  • Standardizes formatting
  • Unifies tone and style
  • Normalizes terminology
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.

Validation & Safety

Strict validation ensures the enhanced content meets quality standards:
backend/llm_processor/validator.py

Description Truncation

To prevent excessively long outputs, descriptions are intelligently truncated:
backend/llm_processor/validator.py

Configuration

LLM enhancement is configured via environment variables:
backend/.env
boolean
default:"false"
Master toggle for LLM enhancement feature
string
required
Your OpenRouter API key from openrouter.ai
string
default:"x-ai/grok-2-1212"
Model to use for enhancement. Options:
  • x-ai/grok-2-1212 - Grok 4.1-Fast (recommended, fast and high-quality)
  • anthropic/claude-3.5-sonnet - Claude 3.5 Sonnet (excellent quality, slower)
  • openai/gpt-4o - GPT-4 Omni (good quality, moderate speed)
integer
default:"60"
Maximum time to wait for LLM response
integer
default:"2"
Number of retries on rate limit or timeout
float
default:"0.3"
Sampling temperature (0.0-1.0). Lower = more deterministic, higher = more creative

API Usage

Enable enhancement via WebSocket request:

Processing Results

The processor returns detailed statistics:
backend/llm_processor/models.py
Success statistics:
Failure result:

Example Enhancement

Before (Raw Crawl):
After (LLM Enhanced):
Notice how the enhanced version adds context, organizes sections, improves descriptions, and maintains all original URLs.

Cost Considerations

LLM enhancement incurs API costs via OpenRouter:

Grok 4.1-Fast

Cost: ~$0.02-0.05 per crawl Speed: 2-4 seconds Quality: Excellent

Claude 3.5 Sonnet

Cost: ~$0.10-0.20 per crawl Speed: 5-10 seconds Quality: Outstanding
Costs vary based on input size. A typical 50-page crawl generates ~5-10k tokens of input.

Best Practices

Use enhancement for public-facing documentation or important sites where description quality is critical. Skip it for internal tools or quick tests.
Track OpenRouter usage via their dashboard to avoid unexpected costs. Set up billing alerts.
Keep LLM_TEMPERATURE at 0.3 or lower for consistent, factual enhancements. Higher values may introduce creativity but risk hallucinations.
Always review the enhanced content before publishing. While validation prevents URL loss, the LLM may occasionally misinterpret context.

Troubleshooting

Check: LLM_ENHANCEMENT_ENABLED=true and valid OPENROUTER_API_KEY in .envVerify: OpenRouter API key has credits and is active
Cause: Too many requests in short time periodSolution: OpenRouter has rate limits per key. Wait 60 seconds between requests or upgrade your OpenRouter plan.
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.
Cause: LLM took longer than LLM_TIMEOUT_SECONDS to respondSolution: Increase timeout to 90-120 seconds, or reduce input size by lowering maxPages.

Next Steps

Auto Updates

Schedule periodic recrawls with enhancement enabled

API Reference

Complete WebSocket API documentation