Authentication¶
Claude Code Media Generator supports multiple authentication methods for Google APIs.
Using Claude Code Skill?
If you have the /generative skill installed, use the built-in setup wizard:
/generative config setup
This will guide you through API configuration step-by-step.
Authentication Methods Overview¶
| Method | Type | Best For | Interactive |
|---|---|---|---|
| API Key | Static Key | Quick start, Gemini API | No |
| OAuth2 (gcloud) | OAuth 2.0 | Full Vertex AI access | Yes (browser) |
| Service Account | OAuth 2.0 JWT | Server/automation | No |
Method 1: API Key (Recommended for Start)¶
Get Your API Key¶
- Go to Google AI Studio
- Click Get API Key
- Create a new key or use existing
API Key Types¶
| Prefix | Type | Works With |
|---|---|---|
AIzaSy... | Gemini API Key | Gemini API endpoint |
AQ.Ab8R... | Vertex AI Key | Vertex AI endpoint (limited) |
Set API Key¶
export GOOGLE_API_KEY="AIzaSy..."
python video_gen.py "prompt" --key "AIzaSy..."
{
"main_projects": {
"default": {
"api_key": "AIzaSy..."
}
}
}
Method 2: OAuth2 via gcloud (Full Access)¶
Setup¶
# Install gcloud CLI
# https://cloud.google.com/sdk/docs/install
# Login to Google Cloud
gcloud auth login
# Set application default credentials
gcloud auth application-default login
# Get access token (for testing)
gcloud auth application-default print-access-token
Usage¶
# Get token
TOKEN=$(gcloud auth application-default print-access-token)
# Use with video_gen.py
python video_gen.py "prompt" --key "$TOKEN"
Method 3: Service Account (Automation)¶
Create Service Account¶
- Go to Google Cloud Console
- Navigate to IAM & Admin → Service Accounts
- Click Create Service Account
- Grant roles:
Vertex AI User,Storage Object Admin - Download JSON key file
Usage¶
# Set credentials path
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"
# video_gen.py will auto-detect
python video_gen.py "prompt"
Endpoint Compatibility Matrix¶
| Auth Method | Gemini API | Vertex AI |
|---|---|---|
API Key (AIzaSy...) | ||
Vertex AI Key (AQ...) | ||
| OAuth2 Token | ||
| Service Account |
Config File (Multi-Project)¶
{
"main_projects": {
"default": {
"api_key": "AIzaSy...",
"gcs_bucket": "my-bucket",
"project_id": "my-project"
},
"work": {
"api_key": "AIzaSy...",
"gcs_bucket": "work-bucket"
}
}
}
# Use specific project
python video_gen.py "prompt" --project work
Troubleshooting¶
"Invalid API key"¶
- Check key prefix:
AIzaSy...for Gemini API - Ensure key is not expired or revoked
"Permission denied"¶
- Enable Vertex AI API in Cloud Console
- Check billing is enabled
"Token expired"¶
- Re-run
gcloud auth application-default login
Next Steps¶
- Quick Start - Generate your first video
- GCS Storage - Set up cloud storage
- Using Skills - Use the
/generativeskill