Environment Configuration
Configuration and Authentication
Moltext provides a flexible configuration system to accommodate different workflows, ranging from cloud-based LLM processing to local-first raw extraction. You can configure the tool using CLI flags or environment variables.
API Key Management
If you are not using --raw mode, Moltext requires access to an LLM to normalize and compress documentation. By default, it is configured for OpenAI.
You can provide your API key in two ways:
- Environment Variable (Recommended): Define
OPENAI_API_KEYin your shell or a.envfile. - CLI Flag: Pass the key directly using the
-kor--keyoption.
# Using the CLI flag
moltext https://docs.example.com -k sk-proj-xxx
Environment Variables (.env)
Moltext automatically loads configuration from a .env file located in your current working directory. This is the preferred method for persistent configurations.
Create a .env file with the following variables:
# Required for OpenAI processing
OPENAI_API_KEY=sk-your-api-key-here
# Optional: Override the default model (defaults to gpt-4o-mini)
# MODEL_NAME=gpt-4
# Optional: Override the default OpenAI base URL
# BASE_URL=https://api.openai.com/v1
Local Inference Configuration
To use Moltext with local LLM providers (such as Ollama, LM Studio, or LocalAI), you must override the base-url. When a custom base-url is detected that does not point to OpenAI, the API key requirement is relaxed (a placeholder key is used internally).
# Example: Using Ollama
moltext https://docs.example.com \
--base-url http://localhost:11434/v1 \
--model llama3
Configuration Hierarchy
Moltext resolves configuration settings in the following order of precedence:
- Explicit CLI Flags: (e.g.,
--key,--model,--base-url) - Environment Variables: (e.g.,
OPENAI_API_KEY) - Application Defaults:
- Base URL:
https://api.openai.com/v1 - Model:
gpt-4o-mini - Output Path:
context.md - Page Limit:
100
- Base URL:
Running without Configuration (Raw Mode)
If you prefer to skip LLM processing entirely and obtain structured Markdown without an API key or local model, use the --raw flag. This bypasses all authentication logic and returns the clean, normalized content directly.
moltext https://docs.example.com --raw
Execution Limits
To prevent infinite loops or excessive API usage when parsing large documentation sites, use the --limit flag to cap the number of pages crawled.
# Limit the crawl to 50 pages
moltext https://docs.example.com --limit 50