Technically, "I'm grateful to you", like you said, is correct in the situation you described! Well done :)
Often native English speakers get this wrong too, so everyone would still understand you if you said either "to" or "for". Most of the time in that situation we'd simply cut it short to "I'm grateful," which sounds a bit more natural. A simple "Thank you" would be appropriate too.
But to clarify/answer your question:
Being grateful TO someone tends to suggest that you're thanking them for ONE specific action e.g serving you a dish, helping you --> "I am grateful TO you for your help!"
Being grateful FOR someone usually means that you're saying you are thankful that they are present in your life, or that they exist generally. The most common situation that people say this is to a boyfriend/girlfriend/spouse. And maybe to your friends if you are sentimental. It is quite a big compliment! You would only say it to someone you're very very close to.