This guide will walk you through creating your own application that uses the Anthropic API to generate responses and schedules tasks using the Heroku Scheduler add-on.
- Heroku account Login with Heroku credentials from Bitwarden
- Heroku CLI installed
- Git installed
- Python 3.7+ installed
- Anthropic API key
If you haven't already, install the Heroku CLI:
# On macOS
brew tap heroku/brew && brew install heroku
# On Windows
choco install heroku-cli
# On Linux (Ubuntu)
curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
We have an example in that repo
mkdir anthropic-scheduler-app
cd anthropic-scheduler-app
git init
We have an example in that repo
Create a requirements.txt file with the following content to specify the project dependencies:
anthropic
Create a Procfile to tell Heroku how to run your app:
web: python main.py
7.1. Log in to Heroku Log in to your Heroku account:
heroku login
Then proceed with a link, you should be loged in the browser already
7.2. Create a Heroku App Create a new Heroku app:
heroku create
7.3. Set Your Anthropic API Key Replace your_api_key with your actual API key:
heroku config:set ANTHROPIC_API_KEY=your_api_key
7.4. Add, Commit, and Push Your Code to Heroku Add your files to Git, commit, and push to Heroku:
git add .
git commit -m "Initial commit"
git push heroku main
Add the Heroku Scheduler add-on to your app:
heroku addons:create scheduler:standard
In the Heroku UI, you will find "Configure Add-ons" in the Overview section:
Select Heroku Scheduler. Press the "Add job" button. Specify the schedule and run command, for example: python main.py.
Check your Heroku app logs to verify that the scheduled tasks are running correctly:
heroku logs --tail