Investors wanting to earn the maximum returns from artificial intelligence (AI) may look to small- or mid-cap stocks. Because they carry more risk than their large-cap brethren, they often hold the most growth potential.

However, this does not mean AI investors should ignore megacaps. AI stocks like Microsoft (MSFT 1.69%) and Google-parent Alphabet (GOOGL 0.51%) (GOOG 0.50%) have invested heavily in AI technology and incorporated it into their product and service offerings.

They also hold massive cash reserves, allowing them to invest heavily in AI and, by extension, drive investor returns from the technology.

The case for Microsoft

In recent weeks, Microsoft drew AI enthusiasts for something many considered impossible -- competing with Google search. Thanks to its relationship with OpenAI, Microsoft incorporated ChatGPT in its Bing search engine. While it is not yet clear how much progress Bing has made, downloads of the Bing mobile app rose fourfold in two months.

Additionally, the company's AI capabilities go well beyond Bing. Many of the capabilities center around Microsoft's cloud platform Azure as it plays a role in tasks such as cloud security, deploying solutions, and powering machine-learning capabilities. Applications like Microsoft 365, Github, and Teams also utilize AI. And with $104 billion in liquidity, Microsoft can afford whatever AI-related investment it may need to make.

AI likely helped the company's top line as revenue for the third quarter of fiscal 2023 (ended March 31) of $53 billion grew 7% compared with the same quarter in fiscal 2022. The AI-driven segments, intelligent cloud, and productivity and business processes grew revenue by 16% and 11%, respectively, during this time. Still, net income rose 9% over the previous year to $18 billion as cost and expense increases lagged revenue growth.

Its stock is up 5% from 12 months ago despite a brutal bear market in 2022. While that takes its price-to-earnings (P/E) ratio to 33, the valuation partially reflects AI's effect on Microsoft stock.

Why investors should consider Alphabet

However, Microsoft's successes do not mean investors should write off Alphabet. The company is a longtime leader in AI.

The company holds $115 billion in liquidity, a massive cash hoard ensuring that it can afford to buy or develop the AI technology it needs, and it appears to have done some of both. Alphabet bought the AI laboratory DeepMind back in 2014. It employs scientists, machine-learning experts, and engineers to advance scientific discovery and the public benefit.

Moreover, Google AI focuses on more practical applications for AI and has long applied the technology to most of its products, including its popular search engine. One of its latest initiatives is Bard, a solution focused on generative AI. Hence, Bard can generate images and text based on information from the internet in response to specific prompts. This makes it an alternative to ChatGPT and reinforces the sentiment that Google is just fine despite this competitive threat.

Despite these strengths, revenue of $70 billion rose by only 3% year over year, driven primarily by a decline of less than 1% in Google advertising, its largest revenue segment. Additionally, the company reported significant cost and expense growth during that time, leading to a net income of $15 billion, an 8% drop from year-ago levels.

Amid these struggles, the stock has fallen 15% over the last year. Nonetheless, that takes its P/E ratio to 23, well under that of AI competitors such as Microsoft.

Investing in Microsoft and Alphabet

Ultimately, both companies should remain critical players in AI and drive returns for their investors as a result. Massive liquidity positions leave both companies with plenty of cash to invest, and resulting product lines show they have used AI technology effectively.

If choosing between these stocks, the decision may come down to timing. While Microsoft registered faster revenue and profit growth in the most recent quarter, investors can buy Alphabet stock at a significant discount, likely making it the one to choose at this moment. Nonetheless, over time, both companies should beat the market by dominating certain parts of tech, and AI will likely play a role in cementing their market leadership.