Automatically generate beautiful isometric 3D city weather images using Google's Nano Banana (Gemini 2.5 Flash Image) and post them to Instagram, X (Twitter), and TikTok.
- Dynamic City Configuration: Easy YAML config for multiple cities/accounts
- Timezone-Aware Posting: Posts at optimal times based on each city's timezone
- Multi-Platform Support: Instagram, X (Twitter), TikTok
- Real Weather Data: Fetches current weather from OpenWeatherMap
- Beautiful AI Images: Uses Google's Nano Banana for stunning isometric city scenes
- GitHub Actions Powered: Free automated scheduling
city-weather-poster/
├── .github/
│ └── workflows/
│ └── post-weather.yml # GitHub Actions scheduler
├── src/
│ ├── __init__.py
│ ├── config.py # Configuration loader
│ ├── weather.py # OpenWeatherMap integration
│ ├── image_generator.py # Nano Banana (Gemini) integration
│ ├── platforms/
│ │ ├── __init__.py
│ │ ├── instagram.py # Instagram Graph API
│ │ ├── twitter.py # X API v2
│ │ └── tiktok.py # TikTok API
│ └── main.py # Main orchestration
├── config/
│ └── cities.yaml # City configurations
├── requirements.txt
└── README.md
git clone https://github.com/YOUR_USERNAME/city-weather-poster.git
cd city-weather-poster- Go to Google AI Studio
- Click "Get API Key" → Create API key
- Save your API key
- Sign up at OpenWeatherMap
- Go to API keys section
- Copy your API key (free tier: 1000 calls/day)
- Go to Twitter Developer Portal
- Create a new App (Free tier allows posting)
- Generate: API Key, API Secret, Access Token, Access Token Secret
- Create a Meta Business Account
- Convert your Instagram to a Business/Creator account
- Create an app at Meta Developers
- Add Instagram Graph API product
- Generate a long-lived access token
- Get your Instagram Business Account ID
- Go to TikTok for Developers
- Create an app and request Video Publishing permissions
- Complete app review process
- Get Client Key and Client Secret
Go to your repo → Settings → Secrets and variables → Actions → New repository secret
Add these secrets:
GOOGLE_AI_API_KEY=your_google_ai_key
OPENWEATHER_API_KEY=your_openweather_key
# For each city account (example for Tokyo):
TOKYO_TWITTER_API_KEY=xxx
TOKYO_TWITTER_API_SECRET=xxx
TOKYO_TWITTER_ACCESS_TOKEN=xxx
TOKYO_TWITTER_ACCESS_TOKEN_SECRET=xxx
TOKYO_INSTAGRAM_ACCESS_TOKEN=xxx
TOKYO_INSTAGRAM_ACCOUNT_ID=xxx
TOKYO_TIKTOK_ACCESS_TOKEN=xxx
Edit config/cities.yaml:
cities:
tokyo:
name: "Tokyo"
country: "Japan"
timezone: "Asia/Tokyo"
coordinates:
lat: 35.6762
lon: 139.6503
posting_times:
- "08:00" # Morning post
- "18:00" # Evening post
platforms:
twitter: true
instagram: true
tiktok: true
landmarks: "Tokyo Tower, Shibuya Crossing, Mount Fuji in background, cherry blossoms"- Go to your repo → Actions tab
- Click "I understand my workflows, go ahead and enable them"
- The bot will run automatically based on your schedule!
| Field | Description | Example |
|---|---|---|
name |
City display name | "New York" |
country |
Country name | "USA" |
timezone |
IANA timezone | "America/New_York" |
coordinates |
Lat/Lon for weather | {lat: 40.7128, lon: -74.0060} |
posting_times |
Local times to post | ["08:00", "20:00"] |
platforms |
Which platforms to post to | {twitter: true, instagram: true} |
landmarks |
City-specific landmarks for prompt | "Statue of Liberty, Empire State..." |
- Add entry to
cities.yaml - Add corresponding secrets to GitHub
- That's it! Next scheduled run will include the new city.
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export GOOGLE_AI_API_KEY="your_key"
export OPENWEATHER_API_KEY="your_key"
# ... other keys
# Run manually
python -m src.main --city tokyo --dry-run- Check GitHub Actions tab for run history
- Each run logs: weather data, image generation status, posting results
- Failed posts are logged with error details
| Service | Cost | Notes |
|---|---|---|
| Nano Banana | ~$0.04/image | 1290 tokens × $30/1M tokens |
| OpenWeatherMap | Free | 1000 calls/day free tier |
| GitHub Actions | Free | 2000 min/month for public repos |
| X API | Free | Free tier allows posting |
| Free | Via Graph API | |
| TikTok | Free | Via official API |
Example: 5 cities × 2 posts/day = 10 images/day = ~$0.40/day = ~$12/month
- Check Google AI API quota
- Verify API key is correct
- Check prompt isn't triggering content filters
- Verify access tokens haven't expired
- Check platform rate limits
- Instagram requires business account
- Verify city coordinates are correct
- Check OpenWeatherMap API key
MIT License - feel free to use and modify!
PRs welcome! Please open an issue first to discuss changes.