# Vision API Enablement Verification

**Last Updated:** 2026-01-19

## Current Status

Based on API testing, **Vision API is NOT enabled** for project `842128635996` (the project your current API key belongs to).

## Verification Results

**Test Date:** 2026-01-19  
**API Key:** `AIzaSyAcmDVIEYDtmeXj...` (Google Maps API key fallback)  
**Project:** `842128635996`  
**Status:** ❌ NOT ENABLED

**Error Message:**
```
Cloud Vision API has not been used in project 842128635996 before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/vision.googleapis.com/overview?project=842128635996
```

## Important Note About API Keys

**Current Setup:**
- Using **default fallback key** from `v2/config/google-maps.php`
- No environment variables set (`GOOGLE_MAPS_API_KEY` or `GOOGLE_VISION_API_KEY`)
- Key belongs to project `842128635996`

**Production Consideration:**
- In production, you might have a different API key set via environment variables
- That production key might belong to a different project
- Vision API should be enabled in **that production project** instead

## How to Verify Which Key/Project You're Using

### 1. Check Environment Variables

```bash
# Check what's set in your environment
php -r "echo 'GOOGLE_MAPS_API_KEY: ' . (getenv('GOOGLE_MAPS_API_KEY') ? 'SET' : 'NOT SET') . '\n';"
php -r "echo 'GOOGLE_VISION_API_KEY: ' . (getenv('GOOGLE_VISION_API_KEY') ? 'SET' : 'NOT SET') . '\n';"
```

### 2. Run Diagnostic Script

```bash
php v2/scripts/ocr-diagnose-api-key.php
```

This shows:
- Which key source is being used
- Key preview
- Configuration status

### 3. Find Project Number

```bash
php v2/scripts/find-api-key-project.php
```

This shows:
- Which project your API key belongs to
- Direct links to enable Vision API

### 4. Verify API Status

```bash
php v2/scripts/check-vision-api-enabled.php
```

This provides:
- Confirmation of enablement status
- Direct enablement link if disabled

## Enablement Instructions

### If Using Project 842128635996

1. **Enable Vision API:**
   - Visit: https://console.developers.google.com/apis/api/vision.googleapis.com/overview?project=842128635996
   - Click "Enable"
   - Wait 1-2 minutes

2. **Enable Billing (if needed):**
   - Visit: https://console.cloud.google.com/billing?project=842128635996
   - Link billing account

3. **Verify:**
   ```bash
   php v2/scripts/check-vision-api-enabled.php
   ```

### If Using Different Project in Production

1. **Identify production project:**
   - Check production environment variables
   - Run diagnostic script on production server
   - Or check Google Cloud Console → APIs & Services → Credentials

2. **Enable Vision API in that project:**
   - Use the project number/ID from step 1
   - Visit: https://console.cloud.google.com/apis/library/vision.googleapis.com?project=YOUR_PROJECT_ID
   - Click "Enable"

3. **Verify:**
   - Test from production environment
   - Or use project number: `php v2/scripts/check-vision-api-enabled.php YOUR_PROJECT_NUMBER`

## Testing After Enablement

```bash
# Quick test
php v2/scripts/test-vision-api-direct.php

# Comprehensive test
php v2/scripts/test-ocr-complete.php

# Status check
php v2/scripts/check-vision-api-enabled.php
```

## Expected Results

**When Enabled:**
- HTTP Status: `200`
- Response includes valid JSON structure
- No error messages

**When Not Enabled:**
- HTTP Status: `403`
- Error message: "has not been used in project X before or it is disabled"
- Error reason: `SERVICE_DISABLED`

## Troubleshooting

### "API not enabled" but you think it is

1. **Check you're using the right project:**
   - Run `php v2/scripts/find-api-key-project.php`
   - Verify the project number matches where you enabled it

2. **Check propagation delay:**
   - API enablement can take 1-2 minutes
   - Wait and test again

3. **Check API key restrictions:**
   - Ensure Vision API is allowed in key restrictions
   - Visit: https://console.cloud.google.com/apis/credentials

4. **Verify billing:**
   - Vision API requires billing even for free tier
   - Check billing status in Google Cloud Console

### Using wrong API key

If production uses a different key:
1. Set `GOOGLE_MAPS_API_KEY` environment variable in production
2. Or set `GOOGLE_VISION_API_KEY` for Vision-specific key
3. Ensure Vision API is enabled in that key's project
