Artificial intelligence (AI) changed the world in what seems like the blink of an eye. Major breakthroughs dramatically expanded the capabilities and potential applications for AI models, and excitement surrounding the tech has powered big gains for the stock market. 

This revolutionary shift is just getting started. Long-term investors still have big opportunities to benefit from what will likely be this century's most transformative technology trend. 

Of course, taking a selective approach to investing in AI remains the best way to position your portfolio for success. If you're looking to profit from the rise of artificial intelligence, read on for a look at one stock that looks like a sure-fire winner -- and one that appears to be overhyped right now.

Buy Microsoft for its strong competitive advantages

Microsoft's (MSFT -1.00%) transformation over the last decade has been nothing short of remarkable. When Satya Nadella came on board as CEO in 2014, he started implementing a plan to transition the business to primarily focus on cloud infrastructure and subscription-based services.

With its Azure cloud infrastructure service delivering incredible sales growth and its pivot to subscription-based models for its productivity software and other offerings, Microsoft entered a new period of sustained sales and earnings growth. Now it looks like AI is poised to be the driving force in another massive transformation for the software giant.

For starters, Azure will help facilitate the development, launching, and scaling of a wide range of new AI applications. The company also recently rolled out the early-access program for its Microsoft 365 Copilot AI personal assistant for Windows 11 users and is aiming to make the tool the centerpiece of users' digital experiences. Through a $10 billion investment in the company, Microsoft also has a close relationship with ChatGPT creator OpenAI.

In short, it looks like artificial intelligence will have an impact on virtually every core aspect of the company's business. Crucially, the software giant's business is already stronger than it's ever been. 

Microsoft has continued to deliver solid sales growth and impressive earnings and margins. The company grew revenue 8% year over year to reach $56.2 billion in its fiscal fourth quarter, which ended June 30. Meanwhile, net income jumped 20% year over year to hit $20.1 billion -- good for a profit margin of 35.8% in the period.

Microsoft has the capital, technology, and data resources needed to solidify itself as one of the strongest players in the AI field. The software leader is already at the forefront of the category, and it appears its strengths will become even more pronounced with time.  

Even with the stock trading in the range of record highs, Microsoft looks like a smart buy for long-term investors.

Avoid C3.ai due to its speculative outlook and valuation

C3.ai (AI 1.18%) is a software company that's making a big push into the AI space. It even changed its name in 2019 to reflect the importance of the new technology, shifting monikers from C3 IoT to its current name.

As the excitement surrounding AI exploded this year, investors have been piling into the stock in hopes that the company is in the early stages of a massive growth run. Its share price is up 184% in 2023. But while C3.ai may go on to be a long-term winner, I think the massive run-up for the company's share price has tilted the risk-reward dynamic in an unfavorable direction for investors. 

AI PS Ratio (Forward) Chart

AI PS Ratio (Forward) data by YCharts.

On the heels of its year-to-date valuation surge, C3.ai is trading at 12x this year's expected sales. Meanwhile, the software specialist increased its revenue by just 5.6% annually in its last fiscal year, which wrapped up on April 30.

The company's guidance does call for sales growth to accelerate to roughly 15% this year, but that's hardly a torrid rate of expansion in the context of the company's heavily growth-dependent valuation.

It also remains to be seen whether the company can hit that target. C3.ai's Q4 revenue was roughly flat year over year at $72.4 million, so it appears that recent rollouts for new AI services have yet to power much in the way of sales growth. 

While C3.ai forecasts that it will shift into non-GAAP (adjusted) profitability in the fourth quarter of its current fiscal year and continue to be profitable on an adjusted basis from there, the stock looks too pricey in the context of the company's somewhat speculative growth outlook.