> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/darkzOGx/youtube-automation-agent/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Complete reference for all environment variables used in YouTube Automation Agent

Environment variables control the behavior of the YouTube Automation Agent. Configure them in a `.env` file in the project root.

## Setup

<Steps>
  <Step title="Copy Example File">
    ```bash theme={null}
    cp .env.example .env
    ```
  </Step>

  <Step title="Edit Configuration">
    Open `.env` in your text editor and fill in the required values.
  </Step>

  <Step title="Verify Settings">
    ```bash theme={null}
    npm run setup
    ```
  </Step>
</Steps>

***

## Required Variables

These variables must be set for the system to function:

### OpenAI Configuration

```bash theme={null}
OPENAI_API_KEY=sk-proj-...
```

<Note>
  Required for content generation, DALL-E image creation, and text-to-speech features.
</Note>

Get your key from [OpenAI Platform](https://platform.openai.com/api-keys).

***

## Application Settings

Control the core behavior of the application:

### Node Environment

```bash theme={null}
NODE_ENV=production
```

<Accordion title="Available Values">
  * `development` - Enables verbose logging and debug features
  * `production` - Optimized for deployment
  * `test` - For running tests
</Accordion>

### Server Port

```bash theme={null}
PORT=3456
```

The port where the web interface will be accessible. Default: `3456`

### Logging Level

```bash theme={null}
LOG_LEVEL=info
```

<Accordion title="Available Levels">
  * `error` - Only errors
  * `warn` - Warnings and errors
  * `info` - General information (recommended)
  * `debug` - Detailed debugging information
  * `verbose` - Everything including API calls
</Accordion>

***

## Channel Settings

Configure your YouTube channel identity:

```bash theme={null}
CHANNEL_NAME=Your Channel Name
DEFAULT_AUTHOR=Your Name
TARGET_AUDIENCE=Your target audience description
```

**Examples:**

```bash theme={null}
CHANNEL_NAME=Tech Explainers
DEFAULT_AUTHOR=Alex Johnson
TARGET_AUDIENCE=Tech enthusiasts aged 18-35 interested in AI and automation
```

***

## YouTube Settings

Control YouTube-specific behavior:

### Region

```bash theme={null}
YOUTUBE_REGION=US
```

Two-letter country code for content trending and recommendations.

<Accordion title="Common Region Codes">
  * `US` - United States
  * `GB` - United Kingdom
  * `CA` - Canada
  * `AU` - Australia
  * `IN` - India
  * `DE` - Germany
  * `FR` - France
  * `JP` - Japan
</Accordion>

### Default Privacy Status

```bash theme={null}
DEFAULT_PRIVACY_STATUS=public
```

<Tabs>
  <Tab title="public">
    Videos are visible to everyone and appear in search results and recommendations.
  </Tab>

  <Tab title="unlisted">
    Videos are only accessible via direct link. Not shown in search or recommendations.
  </Tab>

  <Tab title="private">
    Videos are only visible to you and users you specifically share with.
  </Tab>
</Tabs>

***

## Content Settings

Control how content is processed and formatted:

```bash theme={null}
AUTO_SHORTEN_CONTENT=true
AUTO_ADD_BACKLINKS=true
PRESERVE_FORMATTING=true
AUTO_RESIZE_IMAGES=true
MAX_IMAGE_WIDTH=1280
MAX_IMAGE_HEIGHT=720
IMAGE_QUALITY=90
```

### Content Processing

| Variable               | Type    | Default | Description                                  |
| ---------------------- | ------- | ------- | -------------------------------------------- |
| `AUTO_SHORTEN_CONTENT` | boolean | `true`  | Automatically trim content to optimal length |
| `AUTO_ADD_BACKLINKS`   | boolean | `true`  | Add channel links in video descriptions      |
| `PRESERVE_FORMATTING`  | boolean | `true`  | Maintain original text formatting            |

### Image Processing

| Variable             | Type    | Default | Description                                       |
| -------------------- | ------- | ------- | ------------------------------------------------- |
| `AUTO_RESIZE_IMAGES` | boolean | `true`  | Automatically resize images to optimal dimensions |
| `MAX_IMAGE_WIDTH`    | number  | `1280`  | Maximum image width in pixels                     |
| `MAX_IMAGE_HEIGHT`   | number  | `720`   | Maximum image height in pixels                    |
| `IMAGE_QUALITY`      | number  | `90`    | JPEG quality (1-100)                              |

***

## Rate Limiting

Prevent API quota exhaustion:

```bash theme={null}
GLOBAL_RATE_LIMIT_PER_HOUR=50
DEFAULT_DELAY_BETWEEN_POSTS=60000
```

<Warning>
  YouTube API has strict quota limits. Exceeding them will result in temporary suspension of API access.
</Warning>

| Variable                      | Type   | Default | Description                              |
| ----------------------------- | ------ | ------- | ---------------------------------------- |
| `GLOBAL_RATE_LIMIT_PER_HOUR`  | number | `50`    | Maximum API requests per hour            |
| `DEFAULT_DELAY_BETWEEN_POSTS` | number | `60000` | Delay between operations in milliseconds |

***

## Text-to-Speech Settings

```bash theme={null}
TTS_VOICE=en-US-JennyNeural
```

<Accordion title="Available Azure Voices">
  **Female Voices:**

  * `en-US-JennyNeural` - Friendly, professional
  * `en-US-AriaNeural` - Clear, expressive
  * `en-US-AmberNeural` - Warm, conversational

  **Male Voices:**

  * `en-US-GuyNeural` - Professional, authoritative
  * `en-US-DavisNeural` - Clear, trustworthy
  * `en-US-TonyNeural` - News-style delivery
</Accordion>

***

## Security

```bash theme={null}
JWT_SECRET=generate-a-random-secret-here
```

<Warning>
  Generate a strong, random secret for JWT token signing. Never use the default value in production.
</Warning>

**Generate a secure secret:**

```bash theme={null}
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
```

***

## Analytics & Monitoring

```bash theme={null}
ENABLE_ANALYTICS=true
ANALYTICS_DB_PATH=./data/analytics.db
```

| Variable            | Type    | Default               | Description                     |
| ------------------- | ------- | --------------------- | ------------------------------- |
| `ENABLE_ANALYTICS`  | boolean | `true`                | Track video performance metrics |
| `ANALYTICS_DB_PATH` | string  | `./data/analytics.db` | SQLite database location        |

***

## File Upload Settings

```bash theme={null}
MAX_FILE_SIZE=52428800
UPLOAD_PATH=./uploads
```

| Variable        | Type   | Default     | Description                         |
| --------------- | ------ | ----------- | ----------------------------------- |
| `MAX_FILE_SIZE` | number | `52428800`  | Maximum upload size in bytes (50MB) |
| `UPLOAD_PATH`   | string | `./uploads` | Directory for uploaded files        |

<Note>
  YouTube supports videos up to 256GB, but initial uploads are limited to 15 minutes (or 128GB for verified accounts).
</Note>

***

## Error Handling

```bash theme={null}
RETRY_ATTEMPTS=3
RETRY_DELAY=5000
```

| Variable         | Type   | Default | Description                                    |
| ---------------- | ------ | ------- | ---------------------------------------------- |
| `RETRY_ATTEMPTS` | number | `3`     | Number of retry attempts for failed operations |
| `RETRY_DELAY`    | number | `5000`  | Delay between retries in milliseconds          |

***

## Automation Settings

These are generated by the setup script but can be manually configured:

```bash theme={null}
DAILY_CONTENT_ENABLED=true
AUTO_PUBLISH_ENABLED=true
OPTIMIZATION_ENABLED=true
CONTENT_BUFFER_DAYS=3
MAX_DAILY_POSTS=1
```

<Tabs>
  <Tab title="Content Automation">
    **DAILY\_CONTENT\_ENABLED**

    Enable daily content generation pipeline.

    **CONTENT\_BUFFER\_DAYS**

    Number of days of content to keep in the buffer (queue).

    **MAX\_DAILY\_POSTS**

    Maximum number of videos to publish per day.
  </Tab>

  <Tab title="Publishing">
    **AUTO\_PUBLISH\_ENABLED**

    Automatically publish videos at scheduled times.

    Set to `false` to manually review content before publishing.
  </Tab>

  <Tab title="Optimization">
    **OPTIMIZATION\_ENABLED**

    Enable AI-powered SEO and performance optimization.

    Includes:

    * Title/description optimization
    * Tag generation
    * Thumbnail A/B testing
    * Best time to publish analysis
  </Tab>
</Tabs>

***

## Notification Settings

```bash theme={null}
NOTIFICATION_ENABLED=true
```

Enable console notifications for important events (uploads, errors, milestones).

***

## Debug Settings

```bash theme={null}
DEBUG_MODE=false
VERBOSE_LOGGING=false
SAVE_SCREENSHOTS=false
SCREENSHOT_PATH=./debug/screenshots
```

<Warning>
  Only enable debug settings during development. They generate large log files and slow down the system.
</Warning>

| Variable           | Type    | Default               | Description                              |
| ------------------ | ------- | --------------------- | ---------------------------------------- |
| `DEBUG_MODE`       | boolean | `false`               | Enable detailed debugging                |
| `VERBOSE_LOGGING`  | boolean | `false`               | Log all API requests/responses           |
| `SAVE_SCREENSHOTS` | boolean | `false`               | Save screenshots during video generation |
| `SCREENSHOT_PATH`  | string  | `./debug/screenshots` | Screenshot storage location              |

***

## Optional API Keys

These can be set as environment variables instead of in `credentials.json`:

```bash theme={null}
# ElevenLabs (Premium TTS)
ELEVENLABS_API_KEY=your_api_key
ELEVENLABS_VOICE_ID=your_voice_id

# Azure Speech Services
AZURE_SPEECH_KEY=your_subscription_key
AZURE_SPEECH_REGION=eastus

# Replicate (Advanced Video Generation)
REPLICATE_API_KEY=r8_...

# Google Gemini
GEMINI_API_KEY=your_gemini_key
```

***

## Example Complete Configuration

```bash theme={null}
# YouTube Automation Agent Environment Configuration

# Required
OPENAI_API_KEY=sk-proj-abc123...

# Application
NODE_ENV=production
PORT=3456
LOG_LEVEL=info

# Channel
CHANNEL_NAME=AI Tech Stories
DEFAULT_AUTHOR=Sarah Chen
TARGET_AUDIENCE=Tech enthusiasts interested in AI and automation

# YouTube
YOUTUBE_REGION=US
DEFAULT_PRIVACY_STATUS=public

# Content
AUTO_SHORTEN_CONTENT=true
AUTO_ADD_BACKLINKS=true
PRESERVE_FORMATTING=true
AUTO_RESIZE_IMAGES=true
MAX_IMAGE_WIDTH=1280
MAX_IMAGE_HEIGHT=720
IMAGE_QUALITY=90

# Rate Limiting
GLOBAL_RATE_LIMIT_PER_HOUR=50
DEFAULT_DELAY_BETWEEN_POSTS=60000

# TTS
TTS_VOICE=en-US-JennyNeural

# Security
JWT_SECRET=a1b2c3d4e5f6...

# Analytics
ENABLE_ANALYTICS=true
ANALYTICS_DB_PATH=./data/analytics.db

# Files
MAX_FILE_SIZE=52428800
UPLOAD_PATH=./uploads

# Error Handling
RETRY_ATTEMPTS=3
RETRY_DELAY=5000

# Automation
DAILY_CONTENT_ENABLED=true
AUTO_PUBLISH_ENABLED=true
OPTIMIZATION_ENABLED=true
CONTENT_BUFFER_DAYS=3
MAX_DAILY_POSTS=1

# Notifications
NOTIFICATION_ENABLED=true

# Debug (Development only)
DEBUG_MODE=false
VERBOSE_LOGGING=false
```

## Next Steps

<CardGroup cols={2}>
  <Card title="AI Providers" icon="robot" href="/configuration/ai-providers">
    Configure OpenAI, Gemini, and other AI services
  </Card>

  <Card title="YouTube Setup" icon="youtube" href="/configuration/youtube-setup">
    Complete YouTube API configuration and authentication
  </Card>
</CardGroup>
