The list of companies with a $1 trillion valuation or higher is fairly short: There are only six right now. But two of them that many artificial intelligence (AI) investors focus on are Nvidia (NVDA 2.49%) and Alphabet (GOOG 0.66%) (GOOGL 0.49%). Both companies also have products outside this space, which will help stabilize them should this trend burn out quickly.

But which one is the better buy? Let's dig in since these are completely different types of investments.

Both companies are heavily invested in AI

Nvidia's business is centered around its graphics processing units (GPUs), which process intense calculations, whether it's gaming graphics, engineering simulations, mining cryptocurrency, or generating AI models. These GPUs are considered the best on the market, so the company has seen a massive surge in interest thanks to AI.

Alphabet has multiple AI investments, but it boils down to a couple of business segments. First is advertising, by far the largest revenue driver since its Google Search and YouTube products are driven by ad revenue. AI-driven advertising can ensure the right person sees the ad and may eventually offer full customization for the viewer. It also has another crucial piece of AI infrastructure: Google Cloud.

Most companies don't have the resources to create a sophisticated AI model, so they need to rent additional computing power elsewhere. With Google Cloud's infrastructure optimized for AI workloads, it has solidified itself as a top option despite being third in cloud computing market share.

While both companies are interested in AI proliferation, Nvidia will be in hot water if this trend fizzles out.

Nvidia is all-in on the AI movement

During the second quarter of Nvidia's 2024 fiscal year (ending July 30), data center revenue rose 171% year over year. AI investments ultimately fueled this growth, but the results aren't fantastic if you look past that.

Its consumer-facing segment, gaming, was only up 11% and now is one-fourth the size of the data center division, even though it used to be larger. While Nvidia has given guidance for a fantastic third quarter, it must maintain that rapid growth for its valuation to make sense.

Alphabet isn't seeing the same strength as Nvidia, mainly because it's still an advertising-focused company. And Alphabet is an AI application play, as its own AI technologies and data center infrastructure won't see the benefit immediately. Because Nvidia's GPUs are the basis for creating AI models, it's seeing the first wave of business explosion.

In the second quarter (ending June 30), Alphabet's revenue only rose 7%, with weak advertising revenue growth (up 3.2%). When the recession fears fade away, companies will be more willing to spend on advertising, significantly boosting the company's business. However, there is still one bright spot.

Google Cloud revenue rose 28% year over year and continues to post greater operating profits each quarter. This is a key area to focus on, as it should continue to see strength if AI developers find their infrastructure best suited for the application.

Alphabet is a far cheaper stock than Nvidia

Because of the hype surrounding Nvidia, the stock's valuation is incredibly higher than Alphabet's.

GOOGL PE Ratio Chart

GOOGL PE Ratio data by YCharts.

Because Nvidia is undergoing a significant business transformation, looking at the forward price-to-earnings (P/E) ratio is smart because it factors in the growth. The problem is that the company must hit sky-high analyst expectations over the next 12 months. These projections factor in 162% earnings growth, which is feasible if it maintains its growth rate. But if it misses those projections, the stock could get whacked.

On the other hand, Alphabet doesn't have too expensive a premium, regardless of which ratio you use. As a result, it's a more conservative investment than Nvidia.

So which should you choose? I think investors are better off with Alphabet because it doesn't require perfection to work out as an investment. However, if Nvidia can maintain its expansion for three years (or even two), it will blow Alphabet out of the water in terms of performance.

To best account for the risk and reward here, if you want to buy both, it could be smart to buy a much larger portion of Alphabet than Nvidia. That way, Nvidia's effect is smaller if it underperforms. But if it continues its skyward ascent, you'll still have plenty of exposure.