Skip to main content

Environment File Structure

LiteAgent uses environment files to manage API keys, configuration settings, and runtime parameters. The main configuration is stored in collector/.env.

Setting Up the Environment File

1

Copy Example File

cd agent-collector
cp collector/.env.example collector/.env
2

Edit Configuration

# Use your preferred editor
nano collector/.env
# or
code collector/.env
# or
vim collector/.env
3

Verify Configuration

# Check that required keys are set
python -c "
import os
from dotenv import load_dotenv
load_dotenv('collector/.env')

required_keys = ['OPENAI_API_KEY']
for key in required_keys:
    if os.getenv(key):
        print(f'✓ {key} is set')
    else:
        print(f'✗ {key} is missing')
"

API Keys Configuration

Primary LLM Providers

  • OpenAI
  • Anthropic
  • Google
Required for: BrowserUse, WebArena, VisualWebArena
# OpenAI API Key
OPENAI_API_KEY=sk-proj-...

# Optional: Organization ID
OPENAI_ORG_ID=org-...

# Optional: Model preferences
OPENAI_DEFAULT_MODEL=gpt-4-vision-preview
OPENAI_TEMPERATURE=0.7
OPENAI_MAX_TOKENS=4000
Getting Your Key:
  1. Visit platform.openai.com
  2. Create a new API key
  3. Copy the key (starts with sk-proj- or sk-)
Pricing: ~$0.01-0.06 per 1K tokens depending on model

Agent-Specific APIs

  • MultiOn
  • DoBrowser
  • Skyvern
Required for: MultiOn agent
# MultiOn API Key
MULTION_API_KEY=...

# Optional: MultiOn settings
MULTION_TIMEOUT=60
MULTION_MAX_RETRIES=3
Getting Your Key:
  1. Visit multion.ai
  2. Sign up for an account
  3. Generate API key from dashboard

Application Settings

Core Configuration

# Application settings
APP_NAME=LiteAgent
VERSION=1.0.0
DEBUG=false
LOG_LEVEL=INFO

# Default timeouts (seconds)
DEFAULT_TIMEOUT=180
PAGE_LOAD_TIMEOUT=30
ELEMENT_WAIT_TIMEOUT=10

# Retry settings
MAX_RETRIES=3
RETRY_DELAY=2

Browser Configuration

# Browser settings
HEADLESS=true
BROWSER_WIDTH=1920
BROWSER_HEIGHT=1080

# Chrome arguments (comma-separated)
BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usage,--disable-gpu

# Browser binary path (optional)
CHROME_EXECUTABLE_PATH=/usr/bin/google-chrome

# User agent override (optional)
USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36

Storage Configuration

# Data directories
DATA_DIR=./data
OUTPUT_DIR=./data/db
PROMPT_DIR=./data/prompts
LOG_DIR=./collector/logs
BROWSER_DATA_DIR=./data/browser_data

# Database settings
DB_MAX_CONNECTIONS=10
DB_TIMEOUT=30

# Video recording
ENABLE_VIDEO_RECORDING=true
VIDEO_QUALITY=high

Network Configuration

# Proxy settings (optional)
HTTP_PROXY=http://proxy.example.com:8080
HTTPS_PROXY=http://proxy.example.com:8080
NO_PROXY=localhost,127.0.0.1

# Request timeouts
HTTP_TIMEOUT=30
DOWNLOAD_TIMEOUT=300

# Rate limiting
REQUESTS_PER_MINUTE=60
BURST_LIMIT=10

Environment-Specific Configurations

Development Environment

Create collector/.env.dev:
# Development settings
DEBUG=true
LOG_LEVEL=DEBUG
HEADLESS=false

# Faster timeouts for development
DEFAULT_TIMEOUT=60
MAX_RETRIES=1

# Local webhook for testing
SKYVERN_WEBHOOK_URL=http://localhost:8080

# Verbose logging
VERBOSE_LOGGING=true
SAVE_SCREENSHOTS=true

Production Environment

Create collector/.env.prod:
# Production settings
DEBUG=false
LOG_LEVEL=WARNING
HEADLESS=true

# Production timeouts
DEFAULT_TIMEOUT=300
MAX_RETRIES=5

# Production webhook
SKYVERN_WEBHOOK_URL=https://your-domain.com/webhook

# Optimized for performance
ENABLE_VIDEO_RECORDING=false
SAVE_SCREENSHOTS=false

Testing Environment

Create collector/.env.test:
# Test settings
DEBUG=true
LOG_LEVEL=INFO
HEADLESS=true

# Fast tests
DEFAULT_TIMEOUT=30
MAX_RETRIES=1

# Test data isolation
OUTPUT_DIR=./data/test_db
LOG_DIR=./collector/test_logs

# Mock APIs for testing
USE_MOCK_APIS=true

Loading Environment Variables

Using with Python

from dotenv import load_dotenv
import os

# Load default environment
load_dotenv('collector/.env')

# Load environment-specific config
env = os.getenv('ENV', 'dev')
load_dotenv(f'collector/.env.{env}')

# Access variables
openai_key = os.getenv('OPENAI_API_KEY')
timeout = int(os.getenv('DEFAULT_TIMEOUT', 180))

Using with Docker

# docker-compose.yml
services:
  browseruse:
    env_file:
      - collector/.env
      - collector/.env.${ENV:-dev}
    environment:
      - ENV=${ENV:-dev}

Using with Shell Scripts

#!/bin/bash
# load_env.sh

# Load environment file
if [ -f collector/.env ]; then
    export $(grep -v '^#' collector/.env | xargs)
fi

# Load environment-specific file
ENV=${ENV:-dev}
if [ -f "collector/.env.$ENV" ]; then
    export $(grep -v '^#' "collector/.env.$ENV" | xargs)
fi

echo "Environment loaded: $ENV"

Security Best Practices

API Key Security

Never commit API keys to version control!
# Add .env files to .gitignore
echo "collector/.env*" >> .gitignore
echo "!collector/.env.example" >> .gitignore

# Verify .env files are ignored
git status  # Should not show .env files

Key Rotation

# Script to rotate API keys
#!/bin/bash
# rotate_keys.sh

echo "Rotating API keys..."

# Backup current config
cp collector/.env collector/.env.backup.$(date +%Y%m%d)

# Update keys (replace with actual new keys)
sed -i 's/OPENAI_API_KEY=.*/OPENAI_API_KEY=sk-new-key/' collector/.env
sed -i 's/ANTHROPIC_API_KEY=.*/ANTHROPIC_API_KEY=sk-ant-new-key/' collector/.env

echo "Keys rotated. Test new configuration:"
python -c "
from dotenv import load_dotenv
import os
load_dotenv('collector/.env')
print('✓ New keys loaded')
"

Environment Validation

Create a validation script:
# scripts/validate_env.py
import os
from dotenv import load_dotenv

def validate_environment():
    load_dotenv('collector/.env')

    # Required keys
    required_keys = {
        'OPENAI_API_KEY': 'OpenAI API key',
        'ANTHROPIC_API_KEY': 'Anthropic API key (for Agent E)',
    }

    # Optional keys
    optional_keys = {
        'MULTION_API_KEY': 'MultiOn API key',
        'DOBROWSER_API_KEY': 'DoBrowser API key',
        'SKYVERN_API_KEY': 'Skyvern API key',
    }

    print("🔍 Environment Validation")
    print("=" * 30)

    # Check required keys
    missing_required = []
    for key, description in required_keys.items():
        value = os.getenv(key)
        if value:
            print(f"✅ {key}: {description}")
        else:
            print(f"❌ {key}: {description} (MISSING)")
            missing_required.append(key)

    # Check optional keys
    print("\nOptional configurations:")
    for key, description in optional_keys.items():
        value = os.getenv(key)
        if value:
            print(f"✅ {key}: {description}")
        else:
            print(f"⚠️  {key}: {description} (not set)")

    # Validate settings
    timeout = os.getenv('DEFAULT_TIMEOUT', '180')
    try:
        timeout_int = int(timeout)
        if timeout_int > 0:
            print(f"✅ DEFAULT_TIMEOUT: {timeout_int}s")
        else:
            print("❌ DEFAULT_TIMEOUT: Must be positive")
    except ValueError:
        print("❌ DEFAULT_TIMEOUT: Must be a number")

    # Summary
    if missing_required:
        print(f"\n❌ Missing {len(missing_required)} required keys")
        return False
    else:
        print("\n✅ All required keys configured")
        return True

if __name__ == "__main__":
    is_valid = validate_environment()
    exit(0 if is_valid else 1)
Run validation:
python scripts/validate_env.py

Configuration Templates

Complete Example

Here’s a complete .env file template:
# =============================================================================
# LiteAgent Configuration
# =============================================================================

# -----------------------------------------------------------------------------
# LLM Provider API Keys
# -----------------------------------------------------------------------------

# OpenAI (required for BrowserUse, WebArena, VisualWebArena)
OPENAI_API_KEY=sk-proj-your-key-here
OPENAI_ORG_ID=org-your-org-id
OPENAI_DEFAULT_MODEL=gpt-4-vision-preview

# Anthropic (required for Agent E)
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
ANTHROPIC_DEFAULT_MODEL=claude-3-5-sonnet-20241022

# Google (optional)
GOOGLE_API_KEY=AIza-your-key-here
GEMINI_API_KEY=AIza-your-key-here

# -----------------------------------------------------------------------------
# Agent-Specific API Keys
# -----------------------------------------------------------------------------

# MultiOn
MULTION_API_KEY=your-multion-key

# DoBrowser
DOBROWSER_API_KEY=your-dobrowser-key

# Skyvern
SKYVERN_API_KEY=your-skyvern-key
SKYVERN_WEBHOOK_URL=http://localhost:8080

# -----------------------------------------------------------------------------
# Application Settings
# -----------------------------------------------------------------------------

# Environment
ENV=dev
DEBUG=false
LOG_LEVEL=INFO

# Timeouts
DEFAULT_TIMEOUT=180
PAGE_LOAD_TIMEOUT=30
ELEMENT_WAIT_TIMEOUT=10

# Browser
HEADLESS=true
BROWSER_WIDTH=1920
BROWSER_HEIGHT=1080
BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usage

# Storage
DATA_DIR=./data
OUTPUT_DIR=./data/db
PROMPT_DIR=./data/prompts
LOG_DIR=./collector/logs

# Features
ENABLE_VIDEO_RECORDING=true
SAVE_SCREENSHOTS=true
VERBOSE_LOGGING=false

Troubleshooting

# Test OpenAI key
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
     https://api.openai.com/v1/models | jq '.data[0].id'

# Test Anthropic key
curl -H "x-api-key: $ANTHROPIC_API_KEY" \
     https://api.anthropic.com/v1/messages \
     -d '{"model":"claude-3-haiku-20240307","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'
# Debug environment loading
import os
from dotenv import load_dotenv

print("Before loading:", os.getenv('OPENAI_API_KEY'))
result = load_dotenv('collector/.env')
print("Load result:", result)
print("After loading:", os.getenv('OPENAI_API_KEY'))

# Check file exists
import pathlib
env_file = pathlib.Path('collector/.env')
print("File exists:", env_file.exists())
print("File size:", env_file.stat().st_size if env_file.exists() else "N/A")
# Fix file permissions
chmod 600 collector/.env*  # Read/write for owner only
chown $USER:$USER collector/.env*

# Check permissions
ls -la collector/.env*

Next Steps

Running Tests

Start running tests with your configured environment

Agent Configuration

Configure individual agents

Docker Setup

Use environment with Docker deployment
I