Configure Bring Your Own AI¶
QLens reads its provider registry from:
- Linux/macOS:
~/.config/qlens/ai.yaml - Windows:
%APPDATA%\qlens\ai.yaml - Override:
QLENS_AI_CONFIG=/path/to/ai.yaml
Inspect built-in defaults¶
qlens ai list
qlens ai validate
qlens ai doctor mock
Native OpenAI¶
Create the provider without storing the key:
qlens ai init openai \
--type openai \
--model-env QLENS_AI_MODEL \
--api-key-env OPENAI_API_KEY \
--default
Then set credentials in the shell:
export OPENAI_API_KEY="your-secret-key"
export QLENS_AI_MODEL="your-approved-model"
qlens ai doctor openai
Generate a Bangla monologue:
qlens publication ai-draft PUB-000001 \
--provider openai \
--profile monologue_bn \
--actor Mamun
OpenRouter or another OpenAI-compatible API¶
qlens ai init openrouter \
--type openai_compatible \
--base-url https://openrouter.ai/api/v1 \
--api-key-env OPENROUTER_API_KEY \
--model openai/gpt-5 \
--default
export OPENROUTER_API_KEY="your-key"
qlens ai doctor openrouter
The same pattern works for a private compatible gateway by changing --base-url, key environment variable, and model.
Local Ollama¶
Install Ollama, pull a model, then register it:
ollama pull llama3.1
qlens ai init local-ollama \
--type ollama \
--base-url http://127.0.0.1:11434 \
--model llama3.1 \
--default
qlens ai doctor local-ollama --network
Generate locally:
qlens publication ai-draft PUB-000001 \
--provider local-ollama \
--profile monologue_en
Network diagnostics¶
Configuration-only diagnostics do not contact a provider:
qlens ai doctor openai
Explicit connection test:
qlens ai doctor openai --network
Security¶
Never write a key into ai.yaml, a publication object, .env committed to Git, NUR JavaScript, or command history. QLens rejects direct api_key, token, and secret fields.