> ## 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.

# Getting API Keys

> Step-by-step guide to obtaining all required API keys for the YouTube Automation Agent

The YouTube Automation Agent requires API keys from several services to function. This guide will walk you through obtaining each key.

<Warning>
  Keep all API keys secure and never commit them to version control. Always use environment variables or the credentials.json file.
</Warning>

## 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:

3. **Google Gemini API** - Alternative AI provider for content generation
4. **Azure Speech Services** - High-quality text-to-speech
5. **ElevenLabs API** - Premium voice generation
6. **Replicate API** - Advanced video generation

***

## YouTube Data API Setup

<Steps>
  <Step title="Create a Google Cloud Project">
    1. Visit the [Google Cloud Console](https://console.cloud.google.com/)
    2. Click **"Select a project"** → **"New Project"**
    3. Enter a project name (e.g., "YouTube Automation")
    4. Click **"Create"**
  </Step>

  <Step title="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
  </Step>

  <Step title="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"**
  </Step>

  <Step title="Save Your Credentials">
    1. Download the JSON file or copy the **Client ID** and **Client Secret**
    2. Add them to `config/credentials.json`:

    ```json theme={null}
    {
      "youtube": {
        "client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
        "client_secret": "YOUR_CLIENT_SECRET",
        "redirect_uris": ["http://localhost:8080/oauth2callback"]
      }
    }
    ```
  </Step>

  <Step title="Authenticate Your Channel">
    Run the authentication script:

    ```bash theme={null}
    npm run credentials:setup
    ```

    Follow the prompts to authorize the application with your YouTube channel.
  </Step>
</Steps>

<Note>
  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.
</Note>

***

## OpenAI API Setup

<Steps>
  <Step title="Create an OpenAI Account">
    Visit [OpenAI Platform](https://platform.openai.com/) and sign up or log in.
  </Step>

  <Step title="Add Billing Information">
    1. Navigate to **"Settings"** → **"Billing"**
    2. Add a payment method
    3. Set up billing limits to control costs

    <Warning>
      OpenAI APIs are paid services. Set usage limits to avoid unexpected charges.
    </Warning>
  </Step>

  <Step title="Generate API Key">
    1. Go to [API Keys](https://platform.openai.com/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)
  </Step>

  <Step title="Add to Environment Variables">
    Add the API key to your `.env` file:

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

    Or add to `config/credentials.json`:

    ```json theme={null}
    {
      "openai": {
        "apiKey": "sk-proj-...",
        "model": "gpt-4-turbo-preview"
      }
    }
    ```
  </Step>
</Steps>

<Accordion title="What does OpenAI provide?">
  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
</Accordion>

***

## Google Gemini API Setup (Optional)

<Steps>
  <Step title="Get Gemini API Key">
    1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey)
    2. Click **"Get API Key"**
    3. Select your Google Cloud project or create a new one
    4. Copy the generated API key
  </Step>

  <Step title="Add to Credentials">
    ```json theme={null}
    {
      "gemini": {
        "apiKey": "YOUR_GEMINI_API_KEY"
      }
    }
    ```
  </Step>
</Steps>

<Note>
  Gemini can be used as an alternative or fallback to OpenAI for content generation.
</Note>

***

## Azure Speech Services Setup (Optional)

<Steps>
  <Step title="Create Azure Account">
    Sign up at [Azure Portal](https://portal.azure.com/)
  </Step>

  <Step title="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"**
  </Step>

  <Step title="Get Keys">
    1. Go to your Speech resource
    2. Navigate to **"Keys and Endpoint"**
    3. Copy **Key 1** and **Region**
  </Step>

  <Step title="Add to Configuration">
    ```bash theme={null}
    AZURE_SPEECH_KEY=your_subscription_key
    AZURE_SPEECH_REGION=eastus
    ```
  </Step>
</Steps>

***

## ElevenLabs API Setup (Optional)

<Steps>
  <Step title="Sign Up">
    Create an account at [ElevenLabs](https://elevenlabs.io/)
  </Step>

  <Step title="Get API Key">
    1. Navigate to your [Profile Settings](https://elevenlabs.io/profile)
    2. Copy your API key from the "API Key" section
  </Step>

  <Step title="Select Voice ID">
    1. Go to [Voice Library](https://elevenlabs.io/voice-library)
    2. Choose a voice and copy its Voice ID
  </Step>

  <Step title="Configure">
    ```bash theme={null}
    ELEVENLABS_API_KEY=your_api_key
    ELEVENLABS_VOICE_ID=your_voice_id
    ```
  </Step>
</Steps>

***

## Replicate API Setup (Optional)

<Steps>
  <Step title="Create Account">
    Sign up at [Replicate](https://replicate.com/)
  </Step>

  <Step title="Get API Token">
    1. Go to [Account Settings](https://replicate.com/account/api-tokens)
    2. Copy your API token
  </Step>

  <Step title="Add to Environment">
    ```bash theme={null}
    REPLICATE_API_KEY=r8_...
    ```
  </Step>
</Steps>

<Note>
  Replicate provides access to advanced AI models for video generation using Stable Video Diffusion.
</Note>

***

## Verification

After obtaining all API keys, verify your setup:

```bash theme={null}
npm run credentials:setup
```

The setup wizard will test all configured API connections and report any issues.

<Accordion title="Cost Estimates">
  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
</Accordion>

## Next Steps

Once you have your API keys:

1. [Configure Environment Variables](/configuration/environment-variables)
2. [Set Up AI Providers](/configuration/ai-providers)
3. [Configure YouTube Settings](/configuration/youtube-setup)
