Configuration¶
Complete configuration reference for Image Namer.
Configuration Methods¶
Image Namer can be configured through:
- CLI Flags (highest priority)
- Environment Variables (medium priority)
- Defaults (lowest priority)
CLI flags override environment variables, which override defaults.
CLI Flags¶
Global Flags¶
Available for all commands:
| Flag | Values | Default | Description |
|---|---|---|---|
--provider |
ollama, openai |
ollama |
AI provider to use |
--model |
Text | gemma3:27b |
Model name |
--help |
- | - | Show help and exit |
Command-Specific Flags¶
file and folder Commands¶
| Flag | Values | Default | Description |
|---|---|---|---|
--dry-run |
Boolean | true |
Preview without changes |
--apply |
Boolean | false |
Actually rename files |
--update-refs |
Boolean | false |
Update markdown references |
--no-update-refs |
Boolean | true |
Don't update markdown references |
--refs-root |
Path | . |
Root directory for markdown search |
folder Command Only¶
| Flag | Values | Default | Description |
|---|---|---|---|
--recursive |
Boolean | false |
Process subdirectories |
Examples¶
# Use CLI flags
image-namer file photo.jpg --provider openai --model gpt-4o --apply
# Combine multiple flags
image-namer folder images/ --recursive --apply --update-refs --refs-root ~/Documents
Environment Variables¶
LLM_PROVIDER¶
Set the default AI provider.
Values: ollama, openai
Default: ollama
Example:
LLM_MODEL¶
Set the default AI model name.
Values: Any model name supported by the provider
Default: gemma3:27b
Example:
OPENAI_API_KEY¶
OpenAI API key (required when using OpenAI provider).
Format: Starts with sk-proj- or sk-
Required: Only when LLM_PROVIDER=openai
Example:
Setting Environment Variables¶
Bash/Zsh (Linux/macOS)¶
Add to ~/.bashrc or ~/.zshrc:
Reload:
Windows PowerShell¶
For persistence, use setx:
Project-Specific .env File¶
Create .env in your project:
Load before running:
Or use direnv to auto-load:
# Install direnv
brew install direnv # macOS
apt install direnv # Linux
# Enable direnv
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc # or ~/.bashrc
# Create .envrc
echo 'source .env' > .envrc
# Allow direnv
direnv allow
Defaults¶
If no configuration is provided, Image Namer uses these defaults:
| Setting | Default Value |
|---|---|
| Provider | ollama |
| Model | gemma3:27b |
| Dry-run | true (enabled) |
| Update refs | false (disabled) |
| Refs root | . (current directory) |
| Recursive | false (disabled) |
Configuration Precedence¶
Settings are resolved in this order (highest to lowest priority):
1. CLI Flags (--provider, --model)
↓
2. Environment Variables (LLM_PROVIDER, LLM_MODEL)
↓
3. Defaults (ollama, gemma3:27b)
Example¶
# Set environment
export LLM_PROVIDER=openai
export LLM_MODEL=gpt-4o
# This uses OpenAI (from environment)
image-namer file photo.jpg
# This uses Ollama (CLI flag overrides environment)
image-namer file photo.jpg --provider ollama --model llama3:8b
Provider Configuration¶
Ollama¶
Installation¶
- Download from ollama.com
- Install and start the service
- Pull a model:
Configuration¶
No configuration required—Ollama is the default provider.
Custom model:
or
Supported Models¶
Any Ollama model with vision support:
- gemma3:27b (recommended)
- llama3:8b
- llava:7b
- llava:13b
See Ollama model library for more.
OpenAI¶
Setup¶
- Get API key from platform.openai.com
- Set environment variable:
Configuration¶
Provider:
Model (optional, defaults to gemma3:27b but OpenAI will use a vision-capable model):
Supported Models¶
Vision-capable OpenAI models:
- gpt-4o (recommended)
- gpt-4-turbo
- gpt-4-vision-preview
See OpenAI models for more.
Configuration Profiles¶
Create shell scripts for different profiles:
Local Profile (Ollama)¶
#!/bin/bash
# profile-local.sh
export LLM_PROVIDER=ollama
export LLM_MODEL=gemma3:27b
image-namer "$@"
Usage:
Cloud Profile (OpenAI)¶
#!/bin/bash
# profile-cloud.sh
export LLM_PROVIDER=openai
export LLM_MODEL=gpt-4o
export OPENAI_API_KEY='sk-proj-...'
image-namer "$@"
Usage:
Per-Project Configuration¶
Project Script¶
Create a project-specific script:
#!/bin/bash
# rename-images.sh
# Project-specific config
export LLM_PROVIDER=ollama
export LLM_MODEL=llama3:8b
# Run with project-specific options
image-namer folder docs/images \
--recursive \
--apply \
--update-refs \
--refs-root docs
Makefile¶
# Makefile
.PHONY: rename-images
rename-images:
export LLM_PROVIDER=ollama && \
export LLM_MODEL=gemma3:27b && \
image-namer folder images/ --recursive --apply --update-refs
Usage:
Troubleshooting¶
"OPENAI_API_KEY environment variable not set"¶
Cause: Using OpenAI provider without setting API key
Solution:
"Invalid provider: xyz"¶
Cause: Unsupported provider name
Solution: Use ollama or openai:
Environment variables not working¶
Cause: Not exported or not reloaded
Solutions:
-
Export the variable (not just set):
-
Reload shell config:
-
Verify it's set:
CLI flags not overriding environment¶
Cause: Likely a syntax error in the command
Solution: Check command syntax:
# ✅ Correct
image-namer file photo.jpg --provider ollama
# ❌ Wrong (missing argument)
image-namer file photo.jpg --provider
Configuration Examples¶
Example 1: Default (Ollama)¶
Uses: ollama + gemma3:27b
Example 2: Environment Variables¶
Uses: ollama + llama3:8b
Example 3: CLI Flags Override¶
export LLM_PROVIDER=openai
# Uses Ollama despite environment
image-namer file photo.jpg --provider ollama --apply
Uses: ollama + gemma3:27b (CLI flag wins)
Example 4: Full Configuration¶
export LLM_PROVIDER=openai
export LLM_MODEL=gpt-4o
export OPENAI_API_KEY='sk-proj-...'
image-namer folder ~/Documents/notes/images \
--recursive \
--apply \
--update-refs \
--refs-root ~/Documents/notes
Uses: openai + gpt-4o, processes recursively, updates markdown
Best Practices¶
✅ Do¶
- Set environment variables in shell config for persistence
- Use CLI flags for one-off overrides
- Create project-specific scripts for complex workflows
- Use
--dry-run(default) to preview before applying
❌ Don't¶
- Hardcode API keys in scripts (use environment variables)
- Mix configuration methods inconsistently (confusing)
- Override defaults without understanding precedence
Next Steps¶
- CLI Commands - Complete command reference
- Configuring Providers - Detailed provider setup
- Getting Started - Quick start guide