Investing in the stock market isn't always peaches and cream, as 2022 showed. All three major U.S. indexes plunged into a bear market and produced their worst single-year returns since 2008.

But even amid a tumultuous environment for stocks, investors tend to find patches of inspiration. In 2023, that source of inspiration is anything that has to do with artificial intelligence (AI).

In its simplest form, AI involves using machines or systems to handle tasks that humans would normally be responsible for. What makes AI so special is the ability for software and machines to grow smarter and evolve over time. This machine-learning capability is what gives AI such broad applications.

A representation of a human face emerging from a sea of pixels.

Image source: Getty Images.

It also doesn't hurt that AI is expected to be one of the fastest sustainably growing opportunities this decade. A recent report from Grand View Research estimates the global AI market will grow by an annualized rate of 37.3% between 2023 and 2030 to reach a cool $1.81 trillion by the turn of the decade. 

With AI chatbot ChatGPT captivating the attention of innovation seekers and investors alike, the valuations of most AI stocks have soared in 2023. At the moment, there's one AI stock you can confidently pay a premium valuation for and not raise an eyebrow. Likewise, there's another pricey AI stock I'd suggest not touching with a 10-foot pole.

The artificial intelligence stock worth paying a premium for: CrowdStrike Holdings

Despite what looks to be a U.S. recession on the horizon, you can confidently put your money to work in end-user cybersecurity stock CrowdStrike Holdings (CRWD 0.13%). Even with CrowdStrike valued at a nosebleed multiple of 57 times Wall Street's consensus forward-year earnings, it brings well-defined competitive advantages to the table.

Before digging into company specifics, it's important to recognize that cybersecurity has evolved into a basic-necessity service over the past 20 years. No matter how poorly the U.S. economy and stock market perform, businesses of all sizes are going to continue to need cybersecurity solutions to protect their sensitive data. After all, hackers don't take time off just because Wall Street or the U.S. economy had a bad day.

CrowdStrike's biggest differentiating factor is Falcon, the company's cloud-native security platform. Falcon leans on AI and machine-learning to become more efficient over time at recognizing and responding to potential threats.

In a typical week, the company notes, Falcon will oversee trillions of events. Each of those events adds to its collective intelligence and makes the platform that much more secure for its more than 21,100 subscribers. 

The testament to Falcon's efficacy can be seen in the company's steadily rising gross retention rate. It's no secret that CrowdStrike's software-as-a-service (SaaS) solutions aren't the cheapest. Nevertheless, the company's gross retention rate has expanded from less than 94% to more than 98% in under six years. Subscribers are sticking with the company.

But the top reason you can confidently pay a premium for shares of CrowdStrike is the willingness of the company's existing subscribers to add on to their original purchase. Roughly six years ago, a single-digit percentage of CrowdStrike 450 customers had purchased four or more of its cloud-module subscriptions. As of its latest quarterly filing, 60% of its 21,146 customers had purchased at least five cloud-module subscriptions. Add-on sales have lifted CrowdStrike's adjusted subscription gross margin to between 78% and 79% over the past three fiscal years (78% through the first nine months of fiscal 2023). 

With an adjusted subscription gross margin of nearly 80%, CrowdStrike's earnings growth has the ability to outpace revenue growth for the foreseeable future. That should help take the sting off of its lofty forward-year price-to-earnings ratio.

Multiple graphics processing units lined up neatly in a row.

Image source: Getty Images.

The pricey artificial intelligence stock to avoid like the plague: Nvidia

On the other end of the spectrum is an ultra-popular AI stock with a premium valuation that you'd be wise to avoid like the plague. I'm talking about semiconductor solutions company Nvidia (NVDA 3.71%), which is going for 50 times Wall Street's forecast earnings in fiscal 2024.

Nvidia is best known for its role in the graphics processing unit (GPU) space. It's responsible for selling close to 20% of global GPUs, and has a veritable stranglehold on the discrete graphics card market, with an 80% share.

Nvidia's GPUs are used by gamers, businesses operating data centers, and cryptocurrency miners. They're also expected to play a key role in the development of a variety of AI products.

In one respect, this means Nvidia will be a key hardware player. Its GPUs will be leaned on for accelerated computing capabilities, which are vital for machine-learning/AI solutions.

It also means Nvidia can become an AI player on its own merit -- i.e., beyond just supplying the necessary hardware. Over the past two years, Nvidia brought a number of AI initiatives to market, including its own virtual digital assistant solutions capable of helping businesses serve their customers by responding to voice commands.

While Nvidia does have a long-term pathway to success in AI, there are a couple of red flags that should keep it off investors' radars for perhaps the next year or few years. For instance, it's going to be awhile before AI is anything more than a marginal revenue driver for Nvidia.

Another reason to be skeptical of Nvidia at a premium valuation is its gaming division. Gaming is incredibly important to Nvidia's profitability. Yet during the fiscal third quarter (note: this write-up is being done prior to Nvidia's fourth-quarter earnings release on Feb. 22), Nvidia noted an unsightly 51% decline in year-over-year gaming revenue. As the COVID-19 pandemic gets placed into the rearview mirror and life returns to some semblance of normal, Nvidia's top segment could struggle to regain its luster, with people no longer stuck in their homes.

Nvidia also tends to ebb and flow with the cryptocurrency industry. Since its GPUs are important to mining certain types of tokens, an extended bear market for crypto often removes a high-growth sales channel for Nvidia.

With absolutely no sales growth expected in fiscal 2023 and practically all semiconductor stocks warning about weakening demand/orders for the current calendar year, Nvidia at 50 times forward-year earnings is an easy stock to avoid.