If you've been following the artificial intelligence market closely, then you likely already know a bit about the chip manufacturing company Taiwan Semiconductor Manufacturing (TSM -0.70%) and chip designer Nvidia (NVDA -2.09%).

These two companies are AI leaders in their respective fields, and their share price gains have trounced the market over the past year. But which company is the better artificial intelligence stock right now? Let's dive in and take a look.

A person looking at charts.

Image source: Getty Images.

The case for Taiwan Semiconductor

There are many ways to invest in AI's growth, and one of the most unique is semiconductor manufacturing. While it may not sound as flashy as a company creating an advanced AI chatbot, the results speak for themselves.

Taiwan Semiconductor's sales increased 36% in the third quarter (ending Sept. 30) to $23.5 billion, and its earnings spiked 54% to $1.94 per American depository receipt. That growth was spurred on by large tech companies investing heavily in new AI chip production. Taiwan Semiconductor CEO C. C. Wei said on the company's latest earnings call that "Almost every AI innovator [is] working with us."

The company's unique opportunity stems from its advanced manufacturing techniques, which include producing 3-nanometer chips, and it will ramp up production of 2nm semiconductors beginning in 2025. Its lead in semiconductor manufacturing has given it a 90% market share in making the world's most advanced processors.

Taiwan Semiconductor is benefiting as the world's largest tech companies ramp up their AI infrastructure spending and compete to release the most advanced artificial intelligence services. Goldman Sachs estimates spending on AI will reach $1 trillion over the next few years, which should continue to fuel Taiwan Semiconductor's growth.

The case for Nvidia

Unlike Taiwan Semiconductor, Nvidia focuses on designing, not manufacturing, the semiconductors powering AI data centers. Nvidia's GPUs have long been a preferred choice among tech companies needing high-powered AI data centers, and demand has skyrocketed recently.

Nvidia's sales soared 94% in the third quarter (ended Oct. 27) to $35.1 billion, and its non-GAAP earnings rose 103% to $0.81 per share. The driving force behind those impressive results was the company's 112% increase in data center revenue compared to the year-ago quarter, reaching $30.8 billion.

Like Taiwan Semiconductor, Nvidia is riding a massive wave of investments as companies build new AI infrastructure. Nvidia CEO Jensen Huang estimates that spending in this segment will reach $2 trillion over the next five years, giving his company an unprecedented opportunity to benefit.

While Nvidia's rivals will no doubt grab some of this AI spending as well, the company is well-positioned to be the biggest winner. Nvidia's chips are in an estimated 70% to 95% of AI data centers, giving it a huge advantage as AI infrastructure spending ramps up.

The verdict: Taiwan Semiconductor is the better AI stock

You probably won't go wrong by investing in either of these stocks. Both Nvidia and Taiwan Semiconductor etched out a lead in their respective markets years before the AI boom took off.

However, since this is a comparison of the best AI stock, I'm going to pick Taiwan Semiconductor for this match-up because its shares are technically less expensive than Nvidia's right now. Taiwan Semiconductor has a forward price-to-earnings ratio of 23.0, compared to Nvidia's forward P/E ratio of 32.7.

Both stocks continue to have huge potential as AI grows, but if you're looking for a slightly less expensive stock, then Taiwan Semiconductor is the better choice.