The Nasdaq hit a new record high recently, and the good times may be far from over. History shows us that over the past 10 periods of annual market declines -- dating back to the early 1970s -- the index always has climbed for at least two consecutive years afterward. And on all but one occasion, the index posted a double-digit increase during its second year of gains. If this trend continues, the Nasdaq, heading for a 7.4% increase so far, is set to climb higher in 2024.

And the stocks that have led the gains and could continue leading the movement are artificial intelligence (AI) players. Investors are excited about this high-growth, high-potential technology. AI may make game-changing moves -- like bringing lifesaving drugs to patients more quickly -- and could save companies and individuals money and time as it completes tasks and solves problems.

That's why right now is the perfect time to get in on potential AI powerhouses. Let's check out two AI stocks to buy hand over fist before the Nasdaq soars higher.

An investor on a city street traces a line higher in the air.

Image source: Getty Images.

1. Amazon

Amazon (AMZN 3.43%) is benefiting from AI in two ways. The company uses AI across its e-commerce business to streamline operations and improve the customer experience. And Amazon sells AI solutions to customers through Amazon Web Services (AWS), its cloud computing business.

In e-commerce, Amazon's AI will help you choose a product based on your buying history, and AI is helping the company choose the best delivery routes for packages. These and other AI efforts should keep customers coming back and boost Amazon's profitability.

As for AWS, the service offers everything from chips for customers to train their own AI models to a fully managed service that allows customers to customize the most popular large language models (LLMs) to suit their needs. AWS customers can access the company's own lower-cost chips, as well as the fastest, highest-performing chips and services from AI chip market leader Nvidia (NVDA 6.18%).

All of this could make Amazon one of the winners of a potential AI revolution. And Amazon already has a solid earnings track record -- so the company has the resources to invest in this hot area and continue to grow. In the most recent quarter, Amazon's net sales rose in the double digits, and operating income more than quadrupled to surpass $13 billion.

Today, the stock trades for 42x times forward earnings estimates, a fair price for an already solid business with top AI prospects.

2. Nvidia

Nvidia holds 80% of the AI chip market, and though it faces competitors in the space, it's unlikely to lose its lead any time soon for two reasons. First, the company's first-to-market advantage and brand strength should keep at least some customers loyal. Second, Nvidia is pouring investment into research and development to stay ahead.

Investors expect the launch of Nvidia's H200 chip in the second quarter and then potentially the launch of the Blackwell architecture along with the B100 chip later in the year. These newer products are improvements on the company's already fastest-on-the-market chip.

But Nvidia doesn't only design chips. The company also offers a full portfolio of products and services for the AI client, including a software platform that serves as an "operating system" for AI. Nvidia products are offered on AWS, as mentioned, but also through all other major cloud providers. So it's easy for customers to access Nvidia's offerings directly through their cloud service.

Nvidia's earnings have soared, but growth may be far from over considering the company's market leadership -- and likelihood of remaining on top. Today, Nvidia trades for 35x times forward earnings estimates, which seems reasonable for such a solid growth stock. That's why Nvidia makes a no-brainer addition to any AI portfolio.