Files
novafarma/docs/VERTEX_AI_SETUP_GUIDE.md
2026-01-20 01:05:17 +01:00

132 lines
2.7 KiB
Markdown

# 🚀 VERTEX AI SETUP - COMPLETE GUIDE
## **OPTION 1: Application Default Credentials (Easiest)**
### Step 1: Install Google Cloud CLI
```bash
# Check if installed
gcloud --version
# If not, install:
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
```
### Step 2: Login & Set Project
```bash
# Login to Google Cloud
gcloud auth application-default login
# Set your project
gcloud config set project gen-lang-client-0428644398
# Verify
gcloud config get-value project
```
### Step 3: Enable Vertex AI API
```bash
# Enable the API
gcloud services enable aiplatform.googleapis.com
# Verify it's enabled
gcloud services list --enabled | grep aiplatform
```
### Step 4: Test the Script
```bash
# Run test
python3 scripts/test_vertex_ai_simple.py
```
**If successful:** You'll see a `test_vertex_output.png` file generated! ✅
---
## **OPTION 2: Service Account (If Option 1 fails)**
### Step 1: Create Service Account
```bash
# Create service account
gcloud iam service-accounts create vertex-ai-image-gen \
--description="For Vertex AI Imagen image generation" \
--display-name="Vertex AI Image Generator"
```
### Step 2: Grant Permissions
```bash
# Grant Vertex AI User role
gcloud projects add-iam-policy-binding gen-lang-client-0428644398 \
--member="serviceAccount:vertex-ai-image-gen@gen-lang-client-0428644398.iam.gserviceaccount.com" \
--role="roles/aiplatform.user"
```
### Step 3: Download JSON Key
```bash
# Create and download key
gcloud iam service-accounts keys create ~/vertex-ai-key.json \
--iam-account=vertex-ai-image-gen@gen-lang-client-0428644398.iam.gserviceaccount.com
# Verify
ls -la ~/vertex-ai-key.json
```
### Step 4: Set Environment Variable
```bash
# Add to ~/.zshrc
echo 'export GOOGLE_APPLICATION_CREDENTIALS="$HOME/vertex-ai-key.json"' >> ~/.zshrc
# Reload
source ~/.zshrc
# Verify
echo $GOOGLE_APPLICATION_CREDENTIALS
```
### Step 5: Test
```bash
python3 scripts/test_vertex_ai_simple.py
```
---
## **TROUBLESHOOTING:**
### Error: "Permission denied"
```bash
# Grant additional permissions
gcloud projects add-iam-policy-binding gen-lang-client-0428644398 \
--member="serviceAccount:vertex-ai-image-gen@gen-lang-client-0428644398.iam.gserviceaccount.com" \
--role="roles/aiplatform.admin"
```
### Error: "API not enabled"
```bash
gcloud services enable aiplatform.googleapis.com
```
### Error: "Quota exceeded"
Check: https://console.cloud.google.com/apis/api/aiplatform.googleapis.com/quotas
---
## **NEXT STEPS AFTER SUCCESS:**
1. ✅ Test script works
2. 🔄 Integrate into `generate_all_biomes_complete.py`
3. 🚀 Run bulk generation (3000+ images!)
4. 🎉 Complete all biomes!
---
**START HERE:** Try Option 1 first (Application Default Credentials) - it's simpler!