Macroeconomic issues and concerns triggered a dramatic sell-off in the tech market in 2022 as the Federal Reserve boosted benchmark interest rates to fight inflation. However, the recent advances in artificial intelligence (AI) seemed to be precisely what the sector needed to get back on its feet. The surge in interest in AI has caused a host of tech stocks to recover and soar in 2023.

One of the biggest winners of the AI boom so far has been Nvidia (NVDA -0.19%), which has seen its stock rise 242% year to date. The company has become the go-to chip supplier for nearly the entire AI market, and it likely has much to offer stockholders over the long term as the industry continues to develop.

However, software-focused companies like Alphabet (GOOG 0.38%) (GOOGL 0.38%) are another attractive way to back the AI market. The Google parent has used the last year to invest heavily in the sector and plans to launch a highly anticipated large language model, dubbed Gemini, next year.

These companies are at different stages of their journeys into the AI business, and both could be lucrative ways to profit from the sector over the long term. But which looks like the better buy now?

Nvidia

Nvidia has been the preeminent name in graphics processing units (GPUs) for years, controlling 87% of the market as of Q2 2023 (per Jon Peddie Research). Prior to last year, one of Nvidia's biggest advantages was its popularity with PC gamers, who use the company's GPUs to power their custom-built gaming machines. However, advances in AI have changed the dynamic for the company.

Nvidia's most powerful GPUs are crucial hardware for companies seeking to develop, train, and deploy AI models, and demand driven by those uses has sent Nvidia's chip sales skyrocketing this year. In its fiscal Q3 2024 (which ended October 30), revenue rose 206% year over year, while operating income increased by over 1,600%. The company massively benefited from soaring demand for GPUs, which saw its data center segment achieve revenue growth of 279%.

Nvidia's business will likely continue growing as tech companies increasingly require more powerful chips to take their products to the next level. Yet, it will face more competition in 2024 as various chipmakers challenge Nvidia's dominance by launching new GPUs of their own. Consequently, a long-term perspective will be crucial to successfully invest in Nvidia, as its stock might not be able to replicate 2023's growth any time soon.

Alphabet

Alphabet's stock has risen by 54% since Jan. 1. While that figure might pale in comparison to Nvidia's rally this year, Alphabet potentially has more room for growth over the long term.

The company owns some of the world's most recognizable brands, such as Google, YouTube, and Android, giving it almost endless opportunities to monetize its AI technology. These brands attract billions of users daily and could be leading drivers in the public's adoption of AI.

Cloud competitors Amazon and Microsoft have slightly overshadowed Alphabet in AI this year. However, in 2024, Alphabet plans to launch Gemini, a large language model based on massive data sets that is expected to be highly competitive with OpenAI's GPT-4.

Gemini could strengthen Alphabet's position in AI as it uses the model to improve cloud services, offer more efficient advertising on Google Search and YouTube, refine video recommendations on YouTube, and even bring AI upgrades to productivity platforms like Google Docs.

Alphabet has the brand recognition and user base to see significant success in AI over the long term, making its stock an attractive option right now.

Is Nvidia or Alphabet the better buy?

Nvidia and Alphabet operate in very different areas of tech and AI, with one a leader in hardware and the other dominating software and services. Both companies have solid growth potential over the long term, and it would be hard to go wrong with either stock. However, Alphabet's stock is trading at a bargain valuation compared to Nvidia.

NVDA PE Ratio Chart

Data by YCharts

Alphabet's price-to-earnings and price-to-free-cash-flow ratios are significantly lower than Nvidia's, suggesting it offers far more value. Alphabet's metrics could make it the best and cheapest way to invest in AI.

While Nvidia's meteoric rise in 2023 has benefited prior investors, it has made its stock too expensive for new ones. Meanwhile, the Google parent arguably has similar potential in AI, yet is trading at a substantially better value. As a result, Alphabet is the better buy, and an exciting opportunity ahead of Gemini's launch next year.