I moved from "regular" engineering to data engineering in the last few years which is closer to ML which I find very interesting but comprised of all the stuff that actually needs to be done before ML happens and moved up to "higher end" engineering from having worked entirely in startups to my first big corporate job where I make enough money to retire in 6 years if I want. Bonus is this company isn't a FAANG and morally I get to have a neutral to positive impact on the world but they pay roughly L5 Google level total comp.
If things go well, then if this whole industry goes south I'll be insulated.
Also not joking though blunt it may be, don't be in a European country where wages don't even approach our lowest end dev in the US.
BUT
I don't see the industry going south -- I see it being bifurcated where lower end devs who glue APIs together see their wages driven wayyyyyy down. Find a difficult niche that pays well and try to keep skills towards the top like 60th percentile and higher and your life won't change.