Generate motivational social media posts with AI and LeBron James
- Generate beautiful motivational images with AI-powered captions
- Upload images as draft slideshows to TikTok
- Cloudflare R2 integration for image hosting
- Interactive CLI interface
# Clone the repository
git clone https://github.com/makors/levibes
cd levibes
# Install dependencies using uv
uv sync
# Or with pip
pip install -e .Create a .env file in the project root with the following variables:
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
# TikTok API Configuration
TIKTOK_CLIENT_ID=your_tiktok_client_id
TIKTOK_CLIENT_SECRET=your_tiktok_client_secret
# Cloudflare R2 Configuration
CLOUDFLARE_R2_ENDPOINT_URL=https://abc123def456.r2.cloudflarestorage.com
CLOUDFLARE_R2_ACCESS_KEY_ID=your_r2_access_key_id
CLOUDFLARE_R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
CLOUDFLARE_R2_BUCKET_NAME=my-levibes-bucket
# R2 Public URL (r2.dev subdomain - recommended)
CLOUDFLARE_R2_PUBLIC_URL_BASE=https://my-levibes-bucket.r2.devOPENAI_API_KEY=your_openai_api_key_hereTIKTOK_CLIENT_ID=your_tiktok_client_id
TIKTOK_CLIENT_SECRET=your_tiktok_client_secret# Required R2 variables
CLOUDFLARE_R2_ENDPOINT_URL=https://your-account-id.r2.cloudflarestorage.com
CLOUDFLARE_R2_ACCESS_KEY_ID=your_r2_access_key_id
CLOUDFLARE_R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
CLOUDFLARE_R2_BUCKET_NAME=your_r2_bucket_name
# Optional: Public URL base for accessing files
# Use r2.dev subdomain: https://your-bucket-name.r2.dev
# Or custom domain: https://your-custom-domain.com
CLOUDFLARE_R2_PUBLIC_URL_BASE=https://your-bucket-name.r2.dev-
Create a Cloudflare R2 Bucket:
- Go to Cloudflare Dashboard
- Navigate to R2 Object Storage
- Create a new bucket with a unique name
- Note the bucket name for your
.envfile
-
Create R2 API Token:
- Go to "Manage R2 API Tokens"
- Create a new API token with read/write permissions
- Note the Access Key ID and Secret Access Key
-
Configure Public Access:
- In your bucket settings, enable public access
- This will give you an r2.dev subdomain:
https://your-bucket-name.r2.dev - Set
CLOUDFLARE_R2_PUBLIC_URL_BASE=https://your-bucket-name.r2.dev - Alternatively, configure a custom domain if desired
π‘ Using r2.dev Subdomain
If you're using an r2.dev subdomain (like
https://my-bucket.r2.dev), this is the recommended and simplest approach:
- Enable public access on your R2 bucket
- Use the provided r2.dev URL as your
CLOUDFLARE_R2_PUBLIC_URL_BASE- The app will upload via the R2 API and serve files via the r2.dev subdomain
Example configuration:
CLOUDFLARE_R2_PUBLIC_URL_BASE=https://my-levibes-bucket.r2.dev
- Set R2 Endpoint URL:
- Format:
https://your-account-id.r2.cloudflarestorage.com - Replace
your-account-idwith your actual Cloudflare account ID - This is used for uploads via API, not for public access
- Format:
-
Create TikTok Developer Account:
- Go to TikTok for Developers
- Create a developer account
- Create a new app
-
Configure App Settings:
- Set redirect URI to:
https://tiktoklocal.com:8080/callback - Enable the following scopes:
user.info.basicuser.info.profilevideo.upload
- Note the Client ID and Client Secret
- Set redirect URI to:
-
Domain Configuration:
- Add
tiktoklocal.comto your hosts file pointing to127.0.0.1 - On macOS/Linux:
echo "127.0.0.1 tiktoklocal.com" | sudo tee -a /etc/hosts - On Windows: Add to
C:\Windows\System32\drivers\etc\hosts
- Add
# Run the application
python main.py
# Or use the CLI directly
levibes# Generate images only
python main.py --no-upload
# Upload existing images
python main.py --upload-only
# Specify custom output directory
python main.py --output-dir ./my-images
# Set custom caption
python main.py --caption "Follow for more motivation!"-
Authentication:
- The app will open a browser for TikTok OAuth
- You may see a security warning (SSL certificate)
- Click "Advanced" and "Proceed to tiktoklocal.com"
- Authorize the app
-
Image Upload:
- Images are first uploaded to Cloudflare R2
- R2 URLs are then used to create TikTok draft
- Draft appears in your TikTok app inbox
-
Publishing:
- Open TikTok app on your phone
- Go to inbox and find the draft
- Edit and publish as desired
levibes/
βββ src/levibes/
β βββ caption_generation.py # AI caption generation
β βββ generate_images.py # Image creation
β βββ upload.py # TikTok/R2 upload
β βββ cli.py # Command line interface
β βββ config.py # Configuration management
βββ output/ # Generated images
βββ main.py # Entry point
βββ .env # Environment variables
- TikTok API: 6 requests per minute per user
- R2 Storage: Check your Cloudflare plan limits
- OpenAI API: Based on your plan and usage
-
"Missing required environment variables"
- Ensure all required variables are set in
.env - Check for typos in variable names
- Ensure all required variables are set in
-
"Authorization failed"
- Verify TikTok Client ID and Secret
- Check that redirect URI is correctly configured
- Ensure
tiktoklocal.comis in your hosts file
-
"Failed to upload to R2"
- Verify R2 credentials and bucket name
- Check bucket permissions
- Ensure endpoint URL is correct
- If using r2.dev subdomain, make sure public access is enabled on the bucket
-
SSL Certificate Warning
- This is normal for local development
- Click "Advanced" and "Proceed to tiktoklocal.com"
Set DEBUG=1 in your .env file for detailed logging:
DEBUG=1- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details.
