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
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
Example Enhancement
Before (Raw Crawl):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
Enable only when quality matters
Enable only when quality matters
Use enhancement for public-facing documentation or important sites where description quality is critical. Skip it for internal tools or quick tests.
Monitor API usage
Monitor API usage
Track OpenRouter usage via their dashboard to avoid unexpected costs. Set up billing alerts.
Use low temperature
Use low temperature
Keep
LLM_TEMPERATURE at 0.3 or lower for consistent, factual enhancements. Higher values may introduce creativity but risk hallucinations.Review enhanced output
Review enhanced output
Always review the enhanced content before publishing. While validation prevents URL loss, the LLM may occasionally misinterpret context.
Troubleshooting
Enhancement always fails
Enhancement always fails
Check:
LLM_ENHANCEMENT_ENABLED=true and valid OPENROUTER_API_KEY in .envVerify: OpenRouter API key has credits and is activeRate limit errors
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
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
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.Next Steps
Auto Updates
Schedule periodic recrawls with enhancement enabled
API Reference
Complete WebSocket API documentation