
I had been using ChatGPT to track nutrients and estimate nutrition for a while — the convenience of a system you can describe food to, upload a photo to, etc. is hard to beat, and tracking food with GPT was easier than any subscription system I've ever used (and I've used a lot). But I wanted a way to enable long term data tracking and metrics, which doesn't work within GPT itself.
As a subscriber, I'm able to create Custom GPTs which can hit APIs, so I built a Google Apps Script to serve up an API to ChatGPT that would let me track nutrition over time.
Now in its fully functioning form, this allows me to:
- Track daily food intake with ChatGPT using photos, voice conversation, text input, etc. GPT has an extensive knowledge of food and nutrition, including foods from any culture, etc., which blows things like MyFitnessPal out of the water.
- Get a daily summary of nutrition, including a breakdown of macronutrients, vitamins, and minerals.
- Set and update goals for nutrition, weight, etc.
- Track metrics like weight on an ongoing basis.
- Get a weekly summary of nutrition and metrics.
I also added an API for my cycling training platform so I can discuss training data at the same time as nutrition. This goes way deeper than just syncing calorie burn from e.g. strava since ChatGPT can understand cycling-specific terms like TSS, Threshold power, etc.
This project includes not just the Google Apps Script code for the API, but also the other items necessary to get it running including:
- OpenAPI specs for the API
- Cloudflare workers I use to proxy requests (to avoid problems GPT has with redirects)
- Intsructions for the chatbot.