It's not often that investors can experience a megatrend like artificial intelligence (AI), a technology with the potential to transform the global economy by dramatically boosting worker productivity. Let's discuss why Nvidia (NVDA -1.99%) and Palantir Technologies (PLTR 0.51%) could be great ways for investors to bet on this long-term opportunity.

Nvidia

When betting on a brand-new technology, investors need to be able to distinguish between hype and fundamentals. And despite rising by a jaw-dropping $1,700% over the last five years, Nvidia stock is still deeply grounded in the company's earnings and growth potential.

Nvidia is a quintessential AI stock because of its picks-and-shovels approach -- it sells the graphics processing units (GPUs) that other corporations will need to train and run their consumer-facing software.

But while Nvidia occupies a pretty cozy corner of the market, the company is not without risks. One of the biggest is that its customers may opt to manufacture their own specialized chips instead of relying on its one-size-fits-all solutions like the h100 or h200.

To tackle this challenge, Nvidia is building a new business unit to create custom chips tailor-made for client needs. According to Reuters, management has already met with representatives from Amazon, Meta, Google, and others to discuss this potential $30 billion opportunity.

With a forward price-to-earnings (P/E) multiple of just 34, Nvidia's stock price is still reasonable, considering its rapid growth rate. Fourth-quarter revenue increased 265% year over year to $22.1 billion, while profits surged 769% to $12.3 billion. Granted, the company probably won't maintain this stratospheric expansion forever, but it looks capable of outperforming the wider market over the long term.

Palantir Technologies

While Nvidia is a clear winner in AI hardware, investors should also keep an eye on companies that can tackle the software side of the opportunity. Palantir stands out because of its exceptionally deep economic moat, with public sector clients including the U.S. government and its allies.

Palantir is an established partner for America's classified data mining and analytics needs, even working on sensitive missions like tracking down Osama Bin Laden in 2011. This privileged position could help shield it from competition as it seeks to expand its software offerings to include generative AI, which can give its clients real-time data analytics in fast-paced situations like combat.

Man looking at stock charts in a dark room

Image source: Getty Images.

Palantir's sensitive work could expose it to political risk. According to CEO Alex Karp, the company has lost some employees over his vocal support for Israel, and he expects this trend to continue. That said, so far, this hasn't had much impact on Palantir's ability to attract private-sector clients. Fourth-quarter revenue increased 20% year over year to $608 million, and this was led by a 32% jump in commercial revenue, adding much-needed diversification to the company's revenue streams.

With a forward price-to-earnings (P/E) multiple of 67, Palantir stock is quite expensive compared to the Nasdaq Composite's average of 29. However, the company can grow into its valuation as generative AI technology improves and armed forces adopt it at a greater scale.

Which stock is right for you?

Nvidia and Palantir Technologies are both great ways for investors to benefit from the expansion of artificial intelligence over the coming years. But between the two, Nvidia seems to be the more compelling buy because of its eyewatering growth rate and remarkably moderate valuation.