Likely the caffeine though I could be wrong. I've been there. I drastically reduced caffeine intact and cut out all coffee for almost a year. I drink from time to time now without issue. If you cut out coffee or caffeine in a few weeks the headaches should cease.
Another option is to get real chocolate and eat a small bit of that to reduce the headache. I've found that can help with headaches that aren't too bad.