Nvidia (NVDA 6.18%) has been one of 2023's best-performing tech companies, with shares up by more than 200% year to date. That rally, which lifted it to mega-cap status, was largely driven by optimism about the outlook for artificial intelligence (AI) and its ability to supercharge the chipmaker's top and bottom lines.

No doubt, there's plenty of good reason for investor enthusiasm about Nvidia, but with its shares already at lofty levels, is the stock still a buy?

Nvidia's AI opportunity 

Since the launch of OpenAI's generative chatbot ChatGPT in late 2022, AI has taken the investment world by storm, and tech companies have raced to bring their competing platforms to market. But while juggernauts like Alphabet and Microsoft invest billions in consumer-facing chatbots, Nvidia enjoys a potentially more profitable niche as the main supplier of the graphics processing units (GPUs) that provide the computing power necessary for training those applications and running them. 

Nvidia's pick-and-shovel approach shields it from the risk of competition in the crowded AI software space while giving it a significant revenue opportunity as the industry expands. But despite these tailwinds, the company has yet to fully recover from the recent weakness in its core gaming hardware business. 

Poor gaming performance and macroeconomic challenges

While Nvidia's most advanced GPUs can be used to train and run AI platforms, the company's bread and butter remains video gaming, where its hardware is crucial for rendering complex 2D and 3D graphics. Nvidia is the undisputed leader in this space, with a market share of 84% and a deep competitive moat that it maintains through a healthy research and development budget and a consistent product update cycle. But the company can't prevent macroeconomic fluctuations from battering the demand side of the equation. 

According to analysts at Jon Peddie Research, the PC market has been undergoing a sales slowdown because of challenges like inflation and layoffs. In addition, consumers have been more apt to turn to cheaper, last-generation GPUs instead of Nvidia's latest offerings. This challenge has hurt the company's top line. In its fiscal first quarter, revenue dropped 13% to $7.19 billion on a staggering 38% drop in gaming segment revenue to $2.24 billion. 

Darts pinned to a dollar bill symbol

Image source: Getty Images.

The good news is that Nvidia's data center business (where its hardware helps enterprise clients store and analyze data) is picking up some of the slack. First-quarter data center sales grew 14% to a record $4.28 billion. Further, management has provided terrific guidance, expecting revenue to grow by a whopping 64% to $11 billion in the second quarter based on a "steep increase" in AI-related demand. 

Can second-quarter earnings justify the valuation?

Nvidia's optimistic guidance is likely responsible for much of the stock's epic rally in the three months since it reported first-quarter earnings. And to be fair, the shares are far from cheap. At a forward price-to-earnings (P/E) ratio of 55, Nvidia trades at more than twice the S&P 500's average valuation of 25, and the company will have to meet or exceed these high expectations to keep the rally going. 

That said, Nvidia's management expects top-line growth to come from the buoyant data-center business, which isn't suffering from the same macroeconomic challenges as the gaming segment. And investors should remember that you get what you pay for in the stock market. Nvidia's lofty valuation looks somewhat justified considering its wide moat and its pick-and-shovel approach to the fast-growing AI opportunity.