Environment & Auth
Configuration & Authentication
Moltext is designed to be flexible, supporting everything from zero-auth local parsing to high-density LLM compilation via cloud providers. Authentication requirements depend entirely on your chosen Processing Mode.
Authentication Modes
The compiler operates in three distinct authentication states based on your CLI flags:
| Mode | Flag | Auth Required | Description |
| :--- | :--- | :--- | :--- |
| Raw Mode | --raw | None | Bypasses LLM processing. Returns structured Markdown using only local parsing. |
| Local Inference | --base-url <url> | Optional | Used for local providers like Ollama or LM Studio. Defaults to a dummy key if none is provided. |
| OpenAI (Default) | (None) | Required | Uses OpenAI’s API to normalize and compress documentation into agent-native context. |
Environment Variables
Moltext supports .env files in your current working directory via dotenv. This is the recommended way to manage keys for automated workflows.
| Variable | Description |
| :--- | :--- |
| OPENAI_API_KEY | Your OpenAI API key. Required for cloud-based compilation unless --raw is used. |
Usage & Examples
1. Using OpenAI (Standard)
To use the default gpt-4o-mini model for high-density compilation, you must provide an API key.
Via Environment Variable:
export OPENAI_API_KEY='sk-...'
moltext https://docs.example.com
Via CLI Flag:
moltext https://docs.example.com --key sk-...
2. Local Inference (Ollama / LM Studio)
When targeting a local inference server, Moltext skips the strict OpenAI key requirement. If no key is provided via -k, the system automatically uses a dummy-key to satisfy the underlying API client.
# Example: Using Ollama
moltext https://docs.example.com \
--base-url http://localhost:11434/v1 \
--model llama3
3. Raw Mode (Zero-Auth)
If you do not want to use an LLM or do not have an API key available, use the --raw flag. This mode performs structural cleaning and HTML-to-Markdown conversion entirely on your local machine.
moltext https://docs.example.com --raw
Troubleshooting Auth Issues
- Missing Key Error: If you attempt to run Moltext without
--rawor a custom--base-url, the tool will check for theOPENAI_API_KEYenvironment variable. If it is missing, the process will exit with a❌ Error: API Key is required for OpenAImessage. - Base URL Overrides: Ensure your
--base-urlincludes the version suffix (e.g.,/v1) if your local provider requires it to remain compatible with the OpenAI SDK structure.