What's been the best way to grow a stock portfolio in 2023? Halfway through the year, the answer is clear -- own some artificial intelligence (AI) stocks.

Nvidia (NVDA -1.54%), for example, is up a staggering 211% year to date. With those sorts of eye-popping returns, many investors want to know: Is it now too late to buy AI stocks?

So, let's have a look at one green flag and one red flag for the hottest sector in the stock market.

An AI data center room full of servers.

Image source: Getty Images.

Green flag: We've only seen the tip of the iceberg

Unsurprisingly, there are plenty of reasons to be bullish on AI stocks, and AI generally. The mania that surrounded ChatGPT back in March spread far beyond financial circles and entered the cultural mainstream. Much of the hype has centered on AI-created art or language, but there's more to AI than just chatbots and photo generators.

AI can create efficiencies in multiple industries, from optimizing agricultural techniques to streamlining vehicle assembly lines. Cybersecurity firms like CrowdStrike use AI to monitor and secure client networks. Financial companies like Visa (V -1.19%) use AI to monitor transactions and root out fraud. 

Granted, scientists, politicians, and artists have all chimed in with concerns about how AI may alter or disrupt industries and usher in negative consequences. However, AI is here to stay. That's because AI will alter the competitive landscape in favor of companies that use AI and the innovations it makes possible. Alternatively, companies that resist AI will likely see their competitive advantages erode.

Red flag: Valuations have become stretched

There are also downsides to this year's AI stock rally. The most obvious example is that stock prices have risen much faster than earnings for several AI-related stocks. 

Take Nvidia, for example. The stock has rallied from around $145 to nearly $455 today. However, earnings haven't kept pace. That explains why Nvidia's price-to-earnings (P/E) ratio has skyrocketed from 60x to 235x. 

Nvidia is the clearest example, but this same process is playing out with other AI stocks. In short, these stocks have rallied thanks to their potential rather than their results. And that's a recipe for a pullback if earnings fall short of expectations or if guidance disappoints.

Is it too late to buy AI stocks?

It's common for growth-oriented investors to find themselves in this position: On the one hand, AI is a game-changing technology that will usher in staggering innovation and efficiency. On the other, many of the stocks best positioned to benefit from the AI revolution have already rallied significantly, and their valuations are sky-high.

There are, however, many companies that will reap enormous benefits from AI but remain attractively priced. For example, Visa.

As I noted earlier, the company has already integrated AI into its fraud detection monitoring and also uses machine learning to thwart cyberattacks. Visa trades at a P/E ratio of 33, which is below its five-year average of 36. Moreover, analysts expect Visa to earn $8.60 per share this year -- up from $7.50 last year. As the company's AI efficiencies grow, it's possible Visa could increase its already impressive 51% net profit margin. That's well ahead of rival Mastercard, which has a 42% profit margin.

AI stocks like Nvidia might be too hot to handle for some, but for investors willing to dig beneath the surface, there are plenty of AI stocks that remain screaming buys. You just have to know where to look.