Skip to main content
The YouTube Automation Agent requires API keys from several services to function. This guide will walk you through obtaining each key.
Keep all API keys secure and never commit them to version control. Always use environment variables or the credentials.json file.

Required API Keys

You must obtain the following API keys to run the YouTube Automation Agent:
  1. YouTube Data API - For uploading and managing videos
  2. OpenAI API - For content generation, DALL-E images, and TTS

Optional API Keys

These services enhance functionality but are not required:
  1. Google Gemini API - Alternative AI provider for content generation
  2. Azure Speech Services - High-quality text-to-speech
  3. ElevenLabs API - Premium voice generation
  4. Replicate API - Advanced video generation

YouTube Data API Setup

1

Create a Google Cloud Project

  1. Visit the Google Cloud Console
  2. Click “Select a project”“New Project”
  3. Enter a project name (e.g., “YouTube Automation”)
  4. Click “Create”
2

Enable YouTube Data API v3

  1. In your project, navigate to “APIs & Services”“Library”
  2. Search for “YouTube Data API v3”
  3. Click on it and press “Enable”
  4. Also enable “YouTube Analytics API” for analytics features
3

Create OAuth 2.0 Credentials

  1. Go to “APIs & Services”“Credentials”
  2. Click “Create Credentials”“OAuth client ID”
  3. Configure the consent screen:
    • User Type: External
    • App name: Your channel name
    • User support email: Your email
    • Add scopes: ../auth/youtube.upload, ../auth/youtube, ../auth/youtube.readonly
  4. Application type: Web application
  5. Add authorized redirect URI: http://localhost:8080/oauth2callback
  6. Click “Create”
4

Save Your Credentials

  1. Download the JSON file or copy the Client ID and Client Secret
  2. Add them to config/credentials.json:
{
  "youtube": {
    "client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
    "client_secret": "YOUR_CLIENT_SECRET",
    "redirect_uris": ["http://localhost:8080/oauth2callback"]
  }
}
5

Authenticate Your Channel

Run the authentication script:
npm run credentials:setup
Follow the prompts to authorize the application with your YouTube channel.
The OAuth consent screen may need verification if you plan to use the app publicly. For personal use, you can keep it in testing mode.

OpenAI API Setup

1

Create an OpenAI Account

Visit OpenAI Platform and sign up or log in.
2

Add Billing Information

  1. Navigate to “Settings”“Billing”
  2. Add a payment method
  3. Set up billing limits to control costs
OpenAI APIs are paid services. Set usage limits to avoid unexpected charges.
3

Generate API Key

  1. Go to API Keys
  2. Click “Create new secret key”
  3. Name it (e.g., “YouTube Automation”)
  4. Copy the key immediately (it won’t be shown again)
4

Add to Environment Variables

Add the API key to your .env file:
OPENAI_API_KEY=sk-proj-...
Or add to config/credentials.json:
{
  "openai": {
    "apiKey": "sk-proj-...",
    "model": "gpt-4-turbo-preview"
  }
}
The YouTube Automation Agent uses OpenAI for:
  • GPT-4/GPT-3.5: Content generation, script writing, SEO optimization
  • DALL-E 3: Thumbnail generation and visual assets
  • TTS (Text-to-Speech): Voice narration for videos

Google Gemini API Setup (Optional)

1

Get Gemini API Key

  1. Visit Google AI Studio
  2. Click “Get API Key”
  3. Select your Google Cloud project or create a new one
  4. Copy the generated API key
2

Add to Credentials

{
  "gemini": {
    "apiKey": "YOUR_GEMINI_API_KEY"
  }
}
Gemini can be used as an alternative or fallback to OpenAI for content generation.

Azure Speech Services Setup (Optional)

1

Create Azure Account

Sign up at Azure Portal
2

Create Speech Service

  1. Click “Create a resource”
  2. Search for “Speech”
  3. Click “Create”
  4. Configure:
    • Subscription: Your Azure subscription
    • Resource group: Create new or select existing
    • Region: Choose closest region (e.g., eastus)
    • Pricing tier: F0 (free) or S0 (standard)
  5. Click “Review + create”
3

Get Keys

  1. Go to your Speech resource
  2. Navigate to “Keys and Endpoint”
  3. Copy Key 1 and Region
4

Add to Configuration

AZURE_SPEECH_KEY=your_subscription_key
AZURE_SPEECH_REGION=eastus

ElevenLabs API Setup (Optional)

1

Sign Up

Create an account at ElevenLabs
2

Get API Key

  1. Navigate to your Profile Settings
  2. Copy your API key from the “API Key” section
3

Select Voice ID

  1. Go to Voice Library
  2. Choose a voice and copy its Voice ID
4

Configure

ELEVENLABS_API_KEY=your_api_key
ELEVENLABS_VOICE_ID=your_voice_id

Replicate API Setup (Optional)

1

Create Account

Sign up at Replicate
2

Get API Token

  1. Go to Account Settings
  2. Copy your API token
3

Add to Environment

REPLICATE_API_KEY=r8_...
Replicate provides access to advanced AI models for video generation using Stable Video Diffusion.

Verification

After obtaining all API keys, verify your setup:
npm run credentials:setup
The setup wizard will test all configured API connections and report any issues.
Typical monthly costs for moderate usage:
  • YouTube API: Free (with quota limits)
  • OpenAI: $20-100 depending on video frequency
  • Azure Speech: $0-20 (generous free tier)
  • ElevenLabs: $5-99 based on plan
  • Replicate: Pay per use, ~$0.01-0.50 per video

Next Steps

Once you have your API keys:
  1. Configure Environment Variables
  2. Set Up AI Providers
  3. Configure YouTube Settings