Environment Variables
AI Image Renamer CLI uses environment variables for configuration. This page documents all available variables and how to set them.
Required Variables
GROQ_API_KEY
Your Groq API key for authenticating with the AI service.
Required: Yes
Format: String starting with gsk_
Purpose: Authenticates your requests to the Groq API.
How to Obtain:
- Visit console.groq.com
- Sign in or create an account
- Click "Create API Key"
- Copy the key (shown only once)
Setting the Variable:
echo 'export GROQ_API_KEY="gsk_your-key-here"' >> ~/.bashrc
source ~/.bashrcecho 'export GROQ_API_KEY="gsk_your-key-here"' >> ~/.zshrc
source ~/.zshrc# Run once to add to profile
Add-Content -Path $PROFILE -Value '$env:GROQ_API_KEY = "gsk_your-key-here"'
. $PROFILE # Reload profileset -gx GROQ_API_KEY "gsk_your-key-here"Verification:
echo $GROQ_API_KEY
# Should output: gsk_xxxxxxxxxxxxxxxxError if Missing:
RuntimeError: GROQ_API_KEY environment variable is not set.
Please set it using: export GROQ_API_KEY='your-key-here'
Get a free key at: https://console.groq.com/keysConfiguration Methods
Method 1: Shell Configuration (Global)
Set the variable in your shell's configuration file for persistence across sessions.
Advantages:
- Available in all terminal sessions
- Survives restarts
- Works system-wide
Disadvantages:
- Key stored in plain text file
- All applications can read it
Method 2: .env File (Project-Local)
Create a .env file in your working directory:
# .env file contents
GROQ_API_KEY="gsk_your-key-here"The tool automatically loads this file using python-dotenv.
Advantages:
- Per-project configuration
- Easy to manage different keys for different projects
- Follows 12-factor app principles
Disadvantages:
- Risk of committing to version control
- Must create file in each project
Security
Always add .env to your .gitignore:
echo ".env" >> .gitignoreMethod 3: Session-Only (Temporary)
Set for the current terminal session only:
export GROQ_API_KEY="gsk_your-key-here"Advantages:
- Key not stored anywhere
- Cleared when terminal closes
- Good for testing or CI/CD
Disadvantages:
- Must set for each new session
- Easy to forget
Method 4: One-Time Command
Set inline with the command:
GROQ_API_KEY="gsk_your-key-here" rename-images photo.jpgAdvantages:
- No persistent storage
- Precise control
Disadvantages:
- Verbose for repeated use
- Key visible in shell history
Advanced Configuration
Multiple API Keys
If you have multiple Groq accounts or projects, use different .env files:
# Project A
cd project-a
echo 'GROQ_API_KEY="gsk_key_for_project_a"' > .env
# Project B
cd ../project-b
echo 'GROQ_API_KEY="gsk_key_for_project_b"' > .envCI/CD Integration
In CI/CD pipelines, use secret environment variables:
GitHub Actions:
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}GitLab CI:
variables:
GROQ_API_KEY: $GROQ_API_KEY # Set in GitLab CI/CD settingsDocker:
docker run -e GROQ_API_KEY="gsk_xxx" myimageDebugging
Check if your environment is configured correctly:
# Verify key is set
if [ -z "$GROQ_API_KEY" ]; then
echo "GROQ_API_KEY is not set"
else
echo "GROQ_API_KEY is configured (starts with: ${GROQ_API_KEY:0:7}...)"
fiSecurity Best Practices
Do's
✅ Use .env files with .gitignore
✅ Use secret management in CI/CD
✅ Rotate keys periodically
✅ Use separate keys for development and production
Don'ts
❌ Commit API keys to version control
❌ Share keys in chat or email
❌ Use production keys in development
❌ Store keys in publicly accessible locations
If a Key Is Compromised
- Go to console.groq.com/keys
- Find the compromised key
- Click "Revoke" or "Delete"
- Create a new key
- Update your configuration
Related Topics
- Requirements — System requirements
- Installation — Installing the tool
- Troubleshooting — Common issues