Which Sonic Games Is Sonic X Based On?

Primarily Sonic Adventure and Sonic Adventure 2. The series borrowed heavily from those two games for its characters and settings — Shadow and Rouge arriving with the second, and the general look of the world drawn from the Dreamcast era.

It was never a straight adaptation of either, though. Sonic X tells its own story with humans in the lead, and treats the games as a foundation rather than a script.