if you're on expert difficulty you are already racing vs legend ai.
When starting a new GP in career mode in your trailer, you can set difficulty there. Scroll down and you'll see what level the ai is at. You can not access this when already in the GP.
Sadly legend ai is real crap on some tracks, including the first 2 GPs of the season where they are quite off the pace of a competent human driver. They are decent enough on some tracks, and are only really challenging on Catalunya (even too fast there lol).
Your best bet is to get some PC mods for the ai to make them more of a challenge, notably 'slow corner fix'.