Environment Variables
Looplia uses environment variables for API keys, model configuration, and development settings.
API Keys
Section titled “API Keys”| Variable | Description | Required |
|---|---|---|
ANTHROPIC_API_KEY | Anthropic API key for Claude | Yes* |
ZENMUX_API_KEY | ZenMux proxy API key | Yes* |
OPENROUTER_API_KEY | OpenRouter API key | Yes* |
OLLAMA_API_KEY | Ollama API key (defaults to “ollama”) | No |
CLAUDE_CODE_OAUTH_TOKEN | Claude Code OAuth token (alternative auth) | No |
Setting API Keys
Section titled “Setting API Keys”# Option 1: Export in current sessionexport ANTHROPIC_API_KEY=sk-ant-api03-...
# Option 2: Add to shell profile (~/.zshrc or ~/.bashrc)echo 'export ANTHROPIC_API_KEY=sk-ant-api03-...' >> ~/.zshrcsource ~/.zshrc
# Option 3: Use .env file (for development)echo 'ANTHROPIC_API_KEY=sk-ant-api03-...' >> .envenv $(cat .env) looplia run writing-kit --file test.mdOpenRouter Configuration
Section titled “OpenRouter Configuration”Use OpenRouter to access multiple AI providers through a single API with centralized model management:
# 1. Create preset in OpenRouter dashboard# Visit: https://openrouter.ai/settings/presets# - Click "Create Preset"# - Name it exactly "looplia-default"# - Select your preferred model (Claude, GPT-4, Gemini, etc.)# - Configure routing, fallbacks, and providers# - Save the preset
# 2. Set OpenRouter API keyexport OPENROUTER_API_KEY=sk-or-v1-...
# 3. Apply presetlooplia config provider preset OPENROUTER_PRESET
# 4. Run workflowlooplia run writing-kit --file article.mdBenefits:
- Access 100+ models through one integration
- Change models via dashboard without reconfiguring looplia
- Use advanced routing (fallbacks, load balancing, cost optimization)
- Centralized billing and usage tracking
Claude Code Subscription Authentication
Section titled “Claude Code Subscription Authentication”Use your existing Claude Code subscription instead of separate API credits:
# 1. Apply a subscription presetlooplia config provider preset CLAUDE_CODE_SUBSCRIPTION_SONNET
# 2. Set CLAUDE_CODE_OAUTH_TOKEN environment variable# On macOS, extract from Keychain:export CLAUDE_CODE_OAUTH_TOKEN=$(security find-generic-password -s "Claude Code-credentials" -w | jq -r '.claudeAiOauth.accessToken')
# Or set directly if you have the token:export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
# 3. Run workflowlooplia run writing-kit --file article.mdAvailable subscription presets:
CLAUDE_CODE_SUBSCRIPTION_HAIKU— Uses Claude Haiku 4.5CLAUDE_CODE_SUBSCRIPTION_SONNET— Uses Claude Sonnet 4.5CLAUDE_CODE_SUBSCRIPTION_OPUS— Uses Claude Opus 4.5
Model Configuration
Section titled “Model Configuration”| Variable | Description | Default |
|---|---|---|
LOOPLIA_AGENT_MODEL_MAIN | Override main agent model | Provider default |
LOOPLIA_AGENT_MODEL_EXECUTOR | Override skill executor model | Provider default |
ANTHROPIC_DEFAULT_HAIKU_MODEL | Override haiku tier model (SDK) | Main model |
ANTHROPIC_DEFAULT_SONNET_MODEL | Override sonnet tier model (SDK) | Main model |
ANTHROPIC_DEFAULT_OPUS_MODEL | Override opus tier model (SDK) | Main model |
Model Override Examples
Section titled “Model Override Examples”# Use Opus for main agentexport LOOPLIA_AGENT_MODEL_MAIN=claude-opus-4-20250514
# Use Haiku for executor (faster, cheaper)export LOOPLIA_AGENT_MODEL_EXECUTOR=claude-haiku-4-20250514
# Run workflowlooplia run writing-kit --file article.mdDevelopment Mode
Section titled “Development Mode”| Variable | Description | Default |
|---|---|---|
LOOPLIA_DEV | Enable development mode | false |
LOOPLIA_DEV_ROOT | Path to looplia-core source repository | - |
LOOPLIA_HOME | Override workspace path | ~/.looplia |
LOOPLIA_DEBUG | Enable debug logging | false |
LOOPLIA_OUTPUT_DIR | Default output directory for run command | cwd |
Development Mode
Section titled “Development Mode”When developing Looplia from source, use dev mode to load plugins directly without running init:
# Enable dev modeexport LOOPLIA_DEV=trueexport LOOPLIA_DEV_ROOT=~/projects/looplia-core
# Run from any directory - plugins loaded from sourcecd ~/my-contentlooplia run writing-kit --file article.mdIn dev mode:
- Plugins are loaded from
$LOOPLIA_DEV_ROOT/plugins/ - Changes to plugin files take effect immediately
- No need to run
looplia initafter changes
Debug Logging
Section titled “Debug Logging”# Enable debug outputexport LOOPLIA_DEBUG=1
# Run with verbose logginglooplia run writing-kit --file test.mdDebug logs are written to ~/.looplia/logs/.
Output Directory
Section titled “Output Directory”Use LOOPLIA_OUTPUT_DIR to set a default output location for workflow results:
# Set default output directoryexport LOOPLIA_OUTPUT_DIR=~/looplia-outputs
# Outputs will be copied here after each runlooplia run writing-kit --file article.md# → Results in ~/looplia-outputs/Priority order for output directory:
--output/-oflag (highest priority)LOOPLIA_OUTPUT_DIRenvironment variable- Current working directory (default)
Custom Workspace Path
Section titled “Custom Workspace Path”Use LOOPLIA_HOME to override the default workspace location:
# Use custom pathexport LOOPLIA_HOME=/custom/pathlooplia init
# Useful for testingexport LOOPLIA_HOME=$(mktemp -d)looplia init --yesThis is useful for:
- Testing isolated installations
- Running multiple workspaces
- CI/CD with temporary directories
Provider Configuration
Section titled “Provider Configuration”These variables work with the provider system:
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Used when provider is anthropic |
ZENMUX_API_KEY | Used when provider is zenmux (auto-mapped to ANTHROPIC_API_KEY for SDK) |
OPENROUTER_API_KEY | Used when provider is openrouter (auto-mapped to ANTHROPIC_AUTH_TOKEN for SDK) |
OLLAMA_API_KEY | Used when provider is ollama (auto-mapped to ANTHROPIC_API_KEY for SDK, defaults to “ollama”) |
Auto-Mapping
Section titled “Auto-Mapping”Looplia automatically maps provider-specific API keys to ANTHROPIC_API_KEY for SDK compatibility (except OpenRouter, which uses ANTHROPIC_AUTH_TOKEN):
ZenMux:
# Set ZenMux keyexport ZENMUX_API_KEY=sk-zenmux-...
# Configure ZenMux providerlooplia config provider preset ZENMUX_MINIMAX_M21
# The ZENMUX_API_KEY is automatically usedlooplia run writing-kit --file article.mdOpenRouter:
# Set OpenRouter keyexport OPENROUTER_API_KEY=sk-or-v1-...
# Configure OpenRouter providerlooplia config provider preset OPENROUTER_PRESET
# The OPENROUTER_API_KEY is automatically usedlooplia run writing-kit --file article.mdOllama:
# Optional: Set Ollama key (defaults to "ollama" if not set)export OLLAMA_API_KEY=ollama
# Configure Ollama providerlooplia config provider preset OLLAMA_GLM47_CLOUD
# Uses OLLAMA_API_KEY or defaults to "ollama"looplia run writing-kit --file article.mdPriority Order (v0.6.9+)
Section titled “Priority Order (v0.6.9+)”API Keys: Config file takes precedence when explicitly set:
- Subscription auth (highest priority) —
CLAUDE_CODE_OAUTH_TOKENwith subscription preset - Config file
authToken— set vialooplia config provider set auth-token - Endpoint-specific env var —
ZENMUX_API_KEYfor ZenMux,OPENROUTER_API_KEYfor OpenRouter,OLLAMA_API_KEYfor Ollama,ANTHROPIC_API_KEYfor Anthropic - Default env var (
ANTHROPIC_API_KEY) - Ollama default (lowest priority) — literal
"ollama"string when provider is Ollama and no other auth is set
Model Settings: Environment variables take precedence:
- Environment variables (highest priority)
- Config file (
~/.looplia/looplia.setting.json) - Default values (lowest priority)
# Model env vars still override configexport LOOPLIA_AGENT_MODEL_MAIN=claude-opus-4-20250514looplia run writing-kit --file article.mdCI/CD Integration
Section titled “CI/CD Integration”For CI/CD pipelines, set variables in your pipeline configuration:
GitHub Actions
Section titled “GitHub Actions”jobs: process: runs-on: ubuntu-latest env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 - run: bunx looplia init --yes - run: bunx looplia run writing-kit --file content.md --no-streamingWith Claude Code subscription:
jobs: process: runs-on: ubuntu-latest env: CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 - run: bunx looplia init --yes - run: bunx looplia config provider preset CLAUDE_CODE_SUBSCRIPTION_SONNET - run: bunx looplia run writing-kit --file content.md --no-streamingDocker
Section titled “Docker”FROM oven/bun:latestENV ANTHROPIC_API_KEY=""RUN bunx looplia init --yesCMD ["bunx", "looplia", "run", "writing-kit", "--file", "/data/content.md"]docker run -e ANTHROPIC_API_KEY=sk-ant-... -v ./content:/data my-loopliaAll Variables Reference
Section titled “All Variables Reference”| Variable | Type | Description |
|---|---|---|
ANTHROPIC_API_KEY | string | Anthropic API key |
ZENMUX_API_KEY | string | ZenMux proxy API key |
OPENROUTER_API_KEY | string | OpenRouter API key |
OLLAMA_API_KEY | string | Ollama API key (defaults to “ollama”) |
CLAUDE_CODE_OAUTH_TOKEN | string | OAuth token authentication |
LOOPLIA_AGENT_MODEL_MAIN | string | Main agent model override |
LOOPLIA_AGENT_MODEL_EXECUTOR | string | Executor model override |
ANTHROPIC_DEFAULT_HAIKU_MODEL | string | Haiku tier model (SDK) |
ANTHROPIC_DEFAULT_SONNET_MODEL | string | Sonnet tier model (SDK) |
ANTHROPIC_DEFAULT_OPUS_MODEL | string | Opus tier model (SDK) |
LOOPLIA_DEV | boolean | Enable development mode |
LOOPLIA_DEV_ROOT | path | Development source path |
LOOPLIA_HOME | path | Override workspace path (~/.looplia) |
LOOPLIA_DEBUG | boolean | Enable debug logging |
LOOPLIA_OUTPUT_DIR | path | Default output directory for run command |
See Also
Section titled “See Also”- Installation — Initial setup
- config Command — Configure via CLI
- Troubleshooting — Common issues