Wall Street is already talking about two stocks that could reach $4 trillion market caps as soon as next year.

Artificial intelligence (AI) has been the driving force behind these two companies in 2023, and it'll likely continue to be the story of the year in 2024. Recent advancements in the technology popularized by OpenAI's ChatGPT have ushered in a new era of AI investments.

With businesses and investors clamoring for more AI hardware and software, there are bound to be a lot of winners. Wedbush analyst Dan Ives sees trillions of dollars flowing into tech stocks with AI applications over the next couple of years. And he thinks there's a reasonable chance at least $2 trillion of that goes into Apple (AAPL 2.48%) and Microsoft (MSFT -1.00%), pushing each of their market caps past $4 trillion.

Here's why it could happen.

Apple is quietly an artificial intelligence giant

Apple made huge advancements in artificial intelligence over the last decade. It just doesn't call it out like a lot of other companies have over the last year.

True to Apple form, it talks about the consumer benefit of new AI-powered features across its product line. It doesn't try to explain the AI magic behind those features. During Apple's fiscal fourth-quarter earnings call in early November, CEO Tim Cook pointed to personal voice and live voicemail features on the new iOS as well as fall detection, crash detection, and abnormal ECG detection on Apple Watch. Those are all powered by AI.

Cook also says the company's investing quite a bit in generative AI. In fact, it's built its own large language model and it's internally testing its own ChatGPT-style chatbot, according to Bloomberg. The company's on track to spend about $1 billion per year on its generative AI efforts.

Apple can afford to take its time in developing AI because its real advantage is that it owns the computing platform people use most. It has over 2 billion active devices, and it's the most popular smartphone platform in the United States. So when Apple launches a generative AI app like a Siri or iMessage chatbot, it has a built-in audience.

Ives sees Apple leveraging its position to support AI next year through an "AI app store." Apple can highlight and support generative AI applications that run on-device, maintaining user privacy and security. If Apple takes its standard 30% cut, it could be a big business.

To reach a $4 trillion market cap, Apple shares will have to climb about 35% in 2024. Investors can reasonably expect a turnaround in revenue growth, continued expansion in margins, and potential tailwinds from Apple's own AI-powered products and services as well as the industrywide trend. Apple can outperform the market again in 2024, and it'll likely reach $4 trillion at some point, if not next year.

Redefining Microsoft with artificial intelligence

Microsoft managed to redefine itself multiple times, and it's using AI to do it again.

Its core AI service is called Copilot, and it's applying the technology across business applications. It's helping sales teams at over 15,000 organizations personalize customer interactions. It's helping clinicians document patient care and draft notes. It's working on dozens of applications for enterprise-level software. It also foresees everyday knowledge workers using Copilot in its Office suite to be more creative or find new insights in their data.

Importantly, Microsoft's current position as a leading enterprise software provider makes it easy to upsell its Copilot applications (at $30 per seat) to its massive existing customer base.

Microsoft has been more outspoken about its AI investments than Apple. It increased its investment in OpenAI at the start of 2023, and it now owns 49% of the company. It's integrated OpenAI's technology closely with its own.

Microsoft generates tens of billions of dollars from its operating system and enterprise software business that it can reinvest in advancing AI technology. That kind of capital gives it a huge advantage over smaller competitors working on similar problems.

But Microsoft's main advantage is similar to Apple's. It's a platform owner. Its investment in OpenAI was a smart move because it positioned Microsoft's cloud computing business, Azure, as the leading public cloud for AI developers. Indeed, management called out higher-than-expected AI consumption as a key driver of Azure's outperformance last quarter. The business grew revenue 29%, significantly faster than its competitors.

To reach a $4 trillion market cap, Microsoft shares will have to climb about 42%. With its strong cloud computing performance and the momentum of Copilot, it should see accelerating revenue growth while maintaining its stellar margins. Reaching $4 trillion will give it a valuation above 40x FY2025 earnings, but considering its potential for strong earnings growth for years to come thanks to its AI investments, it could actually reach the milestone before Apple.