The hot investing trend these days revolves around finding companies that are involved in artificial intelligence (AI). From machine learning to predictive analytics to software development to hardware development, multiple industries and hundreds of companies will have a hand in creating AI products and services or stand to benefit directly (or indirectly) from AI. If it isn't already, it will soon be a multi-trillion-dollar sector of the economy.

There are multiple ways to invest in artificial intelligence (AI), and Alphabet (GOOG -1.96%) (GOOGL -1.97%) and Nvidia (NVDA 3.71%) are often brought up as top picks in the niche. But which one should investors go with to capitalize on the AI revolution?

Nvidia will be a winner regardless of whose AI technology is best

Alphabet and Nvidia each offer a different angle to investing in AI, although some overlap exists.

Alphabet's offering includes an extensive AI programming toolkit, which features generative AI and machine learning building blocks. Another part of AI systems is the need for vast quantities of data to train AI. Alphabet also has plenty of these available for use and a dedicated search engine for datasets not available from the company. Finally, Google Cloud offers the computing capabilities to its customers necessary to train AI models, as few companies have the resources dedicated to training and maintaining an AI system.

Nvidia is more of a hardware play: The computers that power AI technology run on its GPUs (graphics processing units). This makes Nvidia a "picks and shovels" style investment, as it will be a winner regardless of whose AI technology dominates the marketplace. Still, Nvidia also has generative AI tools and AI training solutions in its DGX cloud, which directly competes with Google Cloud. While it's smart for Nvidia to develop these tools and break into this lucrative market, being a primary hardware play is lucrative in its own right.

Both companies are dedicated to the proliferation of AI technology, but how is each doing currently?

Both businesses have been struggling financially

Based on the companies' most recent quarterly results, you probably wouldn't expect most investors to be bullish on these two stocks.

Even though Alphabet is heavily investing in AI technologies, its primary business is advertising, an industry that has struggled amid economic uncertainty. Overall, Alphabet's revenue was up by only 3% year over year in Q1, but its Google Cloud business continued to do well, posting revenue growth of 28%, as well as its first operating profit. With earnings per share (EPS) falling from $1.23 to $1.17, it wasn't Alphabet's best quarter. But it was a whole lot better than Nvidia's latest results.

The PC market has been terrible over the past year, and Nvidia has taken the brunt of that movement. In Q4 of its fiscal 2023 (ending Jan. 29), revenue tumbled 21% year over year, driven by an astounding 46% drop in gaming revenue. Furthermore, revenue in its data center division (which captures many GPUs sold for AI purposes) decreased by 6% since Q3. That decline is concerning, as this division has been practically a line straight up over the past couple of years.

Nvidia's EPS also dropped from $0.88 to $0.57, marking a hefty profit decline. 

With both companies struggling, is either worth taking a position in?

Alphabet's stock is attractively priced

The headwinds Alphabet and Nvidia are facing are temporary. When recession fears start to subside, businesses should reopen their advertising budgets, and Alphabet will capitalize on that spending. Likewise, budgets dedicated to building data centers or consumer discretionary funds should return to buying GPUs when there isn't a general fear of a massive downturn.

I'm not concerned with the current business state of these two companies. But what worries me are the stock valuations.

Nvidia's stock looks hilariously overvalued at the moment.

NVDA PS Ratio Chart

Data by YCharts.

At 162 times earnings and 26 times sales, Nvidia trades at a range few stocks will ever find themselves in. Granted, using Nvidia's trailing price-to-earnings (P/E) ratio may not do the stock justice, as the company has had some bad quarters recently. But, even if you use the forward P/E ratio, Nvidia still trades at an expensive 62 times earnings. Those are incredibly high expectations built into the stock, and even if Nvidia knocks its AI offerings out of the park, the stock may not increase in price much due to its initial high valuation.

Alphabet isn't experiencing those same problems: Its valuation is at a historic low.

GOOGL PS Ratio Chart

Data by YCharts

Alphabet's stock is currently at a great entry point and positioned well in the AI arms race. While I like Nvidia's prospects as a business, the stock is just too expensive to buy right now, giving Alphabet the edge in this head-to-head battle.