This guide provides detailed step-by-step instructions for obtaining all API credentials needed for the WeatherItBetter application.
The Google AI API key is used to access Google's Gemini AI model for generating outfit recommendations.
-
Visit Google AI Studio
- Go to https://aistudio.google.com/app/apikey
- Sign in with your Google account
-
Create API Key
- Click on "Create API Key" button
- Select an existing Google Cloud project or create a new one
- Click "Create API key in new project" (if creating new)
-
Copy Your Key
- Your API key will be displayed (format:
AIza...) - Copy this key immediately
- Store it securely
- Your API key will be displayed (format:
-
Add to .env File
GOOGLE_API_KEY=AIzaSy...your-actual-key-here
- Keep your API key secret - never commit it to Git
- Free tier includes generous quota for testing
- See Google AI pricing for usage limits
The OpenWeatherMap API provides real-time weather data for outfit recommendations.
-
Create Account
- Go to https://openweathermap.org/
- Click "Sign In" → "Create an Account"
- Fill in your details and verify your email
-
Navigate to API Keys
- After logging in, click on your username (top right)
- Select "My API keys" from the dropdown
-
Generate API Key
- You'll see a default API key already created
- Or create a new one by entering a name and clicking "Generate"
- Copy the API key (format: 32-character hexadecimal string)
-
Add to .env File
OPENWEATHER_API_KEY=29eba27f...your-actual-key-here
- API key activation takes about 10-15 minutes
- Free tier allows 60 calls/minute, 1,000,000 calls/month
- Sufficient for personal use and testing
- See OpenWeatherMap pricing for details
Google Calendar integration allows the app to consider your scheduled activities when making recommendations.
-
Create Google Cloud Project
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Name it (e.g., "WeatherItBetter")
- Click "Create"
-
Enable Calendar API
- In your project, go to "APIs & Services" → "Library"
- Search for "Google Calendar API"
- Click on it and press "Enable"
-
Create OAuth Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- If prompted, configure the OAuth consent screen:
- User Type: External
- App name: WeatherItBetter
- User support email: your email
- Developer contact: your email
- Click "Save and Continue"
- Scopes: Click "Add or Remove Scopes", search for and add:
.../auth/calendar.readonly(View your calendars).../auth/userinfo.email(See your email address)- Then click "Update" and "Save and Continue"
- Test users: Add your email
- Click "Save and Continue"
-
Create OAuth Client ID
- Application type: "Desktop app"
- Name: "WeatherItBetter Desktop"
- Click "Create"
-
Download Credentials
- Click "Download JSON" on the credentials you just created
- Save as
credentials.jsonin the root directory of the project
-
First-Time Authorization
- In
src/main.py, changeuse_calendar=Falsetouse_calendar=True - Run the application
- A browser window will open asking for authorization
- Sign in with your Google account
- Grant calendar read permission
- A
token.jsonfile will be created (this is gitignored)
- In
credentials.jsonandtoken.jsonare automatically gitignored- Never share these files publicly
- Token expires after some time; delete
token.jsonto re-authenticate - Calendar integration is required for the app to function properly
Vertex AI Memory Bank provides persistent cloud-based preference storage and advanced memory capabilities for the outfit recommendation system. It enables intelligent semantic search across user preferences and maintains session history.
-
Create or Use Existing Google Cloud Project
- Go to Google Cloud Console
- Select or create a project
-
Enable Required APIs
- Enable "Vertex AI API"
- Enable "Cloud Resource Manager API"
-
Create Agent Engine (formerly "Reasoning Engine")
- Navigate to: Vertex AI → Agents → Agent Engines
- Or direct URL: https://console.cloud.google.com/vertex-ai/agents/agent-engines
- Click "Create" to create a new Agent Engine (if needed)
- Note your Engine ID (numeric ID displayed in the list or details page)
Alternative - List Engines via Python SDK:
import vertexai from vertexai.preview import reasoning_engines vertexai.init(project="your-project-id", location="us-central1") reasoning_engine_list = reasoning_engines.ReasoningEngine.list() print(reasoning_engine_list)
The Engine ID is the numeric value at the end of the resource name (e.g.,
5842963119676063744) -
Get Project Details
- Project NUMBER (required for Memory Bank): Found in project settings (numeric format:
123456789012)- Go to Google Cloud Console
- Select your project
- The project number is shown on the dashboard
- Or run:
gcloud projects describe YOUR_PROJECT_ID --format="value(projectNumber)"
- Location: Usually
us-central1or your preferred region (e.g.,asia-southeast1)
- Project NUMBER (required for Memory Bank): Found in project settings (numeric format:
-
Add to .env File
GOOGLE_CLOUD_PROJECT=225866861023 # Use project NUMBER, not project ID GOOGLE_CLOUD_LOCATION=us-central1 AGENT_ENGINE_ID=5842963119676063744 -
Set Up Authentication
- Install Google Cloud CLI: https://cloud.google.com/sdk/docs/install
- Run:
gcloud auth application-default login - Follow browser prompts to authenticate
- Vertex AI Memory Bank is required for the app to function properly
- Provides persistent cloud storage for user preferences across sessions
- Local backup is automatically maintained at
data/preferences.json - May incur costs - see Vertex AI pricing
- Requires
gcloudCLI authentication for access - Package Requirements: Ensure you have compatible versions installed:
google-genai >= 1.50.0google-adk[vertexai] >= 1.19.0websockets >= 15.0.1
When the app starts successfully, you'll see:
✅ Vertex AI Memory Bank connected successfully!
Storage: Cloud-based (Vertex AI)
Backup: Local file (data/preferences.json)
- Store all credentials in
.envfile only - Keep
.envin.gitignore(already configured) - Use different API keys for development and production
- Regenerate keys if accidentally exposed
- Set up usage quotas and alerts in API dashboards
- Never commit
.envto Git - Never hardcode credentials in source code
- Never share credentials in screenshots or logs
- Never commit
credentials.jsonortoken.json - Never push to public repositories with exposed keys
After setting up credentials, verify everything works:
# 1. Check .env file exists
ls -la .env
# 2. Run the application
python src/main.py
# 3. Try a recommendation
You: recommend Tokyo
# 4. Check for errors
# If you see "Missing required environment variables", review your .env file
# If you see "Invalid API key", verify your keys are correctProblem: .env file not found or incomplete
Solution:
- Make sure
.envexists in the root directory - Copy from
.env.example:cp .env.example .env - Fill in all required values
- Restart the application
Problem: API key is incorrect or doesn't have permissions
Solution:
- Verify key is copied correctly (starts with
AIza) - Check if you have API quota remaining
- Generate a new key if needed
- Wait a few minutes for key activation
Problem: API key is incorrect or not activated
Solution:
- Verify key is 32 characters (hexadecimal)
- Wait 10-15 minutes after creation for activation
- Check account status on OpenWeatherMap dashboard
- Generate new key if needed
Problem: Cannot authenticate with Google Calendar
Solution:
- Make sure
credentials.jsonis in root directory - Delete
token.jsonif it exists - Run application again to re-authenticate
- Check OAuth consent screen is configured
- Verify your email is added as test user
Problem: Cannot connect to Vertex AI
Solution:
- Run
gcloud auth application-default login - Verify project ID matches exactly
- Check all required APIs are enabled
- Verify you have necessary permissions in GCP
- Try different region if connection fails
Google AI (Gemini):
- Free tier: Very generous
- Typical usage: ~10-50 requests/day
- Cost: $0/month (within free tier)
OpenWeatherMap:
- Free tier: 1,000,000 calls/month
- Typical usage: ~50-100 calls/day
- Cost: $0/month (well within free tier)
Google Calendar API:
- Completely free for personal use
- No usage limits for reasonable personal usage
Vertex AI Memory Bank (Optional):
- This may incur costs
- See pricing page
- Set up billing alerts if using
If you encounter issues not covered here:
- Check the main README.md for general troubleshooting
- Review SETUP.md for detailed setup instructions
- Check API provider documentation:
- Open an issue on GitHub
Last Updated: 2025-01-30