Amazon (AMZN -0.66%) and Costco Wholesale (COST 0.10%) are two giants that have delivered incredible gains for investors and have ample opportunity to do more. They're both feeling some inflationary pressure right now, but in some ways, the current atmosphere just highlights their strengths. Stacked up next to each other, which one is the better buy today?

The case for Amazon: There's nowhere it's not willing to go

Ok, that's probably an exaggeration. But Amazon has its finger in so many pies that it seems like it's everywhere.

Most recently, it turned heads with its foray into generative artificial intelligence (AI), the buzzword of the moment. It has released a competitive version of generative AI that can change how developers code, with generative AI services that can create complete marketing campaigns based on a few prompts, and it can do entire coding processes also based on prompts. 

These services are connected to Amazon Web Services (AWS), which itself was a gamble when Amazon launched it in 2006. It was a completely new business unconnected to Amazon's core e-commerce business, but it offered tech services that Amazon had the capability to build, and it would offer lower prices to undercut the competition, one of Amazon's usual tactics.

It worked, and now AWS is the largest cloud computing company in the U.S. It has grown as a percentage of total Amazon sales as its growth exceeds e-commerce growth, and in the 2023 first quarter, it represented 17% of sales. AWS sales increased 16% over last year in the first quarter, a slowdown, but still higher than company sales growth. It also remained strongly profitable, with $5.1 billion in operating income.

Amazon's foray into healthcare is likely to reap great benefits as well. It has already been in the space since 2019, when it launched a telehealth business, first for its own employees and then for business clients. With the acquisition of One Medical last year, which went into effect this past February, it has a real foothold in the sector, and it again is trying to grab market share through high-tech and lower prices.

Amazon is going through tough times right now, but it's demonstrating resilience, which is the key to a great stock. All companies go through tough times, but winners can keep going.

The case for Costco: Slow and steady wins the race

Costco was a steady gainer prior to the pandemic, with reliable sales growth and robust profitability. The pandemic upended that, in a good way, as sales growth soared to double digits for several years. 

However, that's over and done with now. These days, Costco is eking out slight sales growth and some comparable sales declines. However, investors are still enthusiastic about it because there are so many reasons to love Costco.

Its membership model is a brilliant structure that generates a solid income stream through membership fees while building customer loyalty through rock-bottom pricing. And even as sales growth trickles in the inflationary environment, membership is at record levels. In its fiscal 2023 third quarter (ended May 7), U.S. and Canada renewal rates were 92.6%, while global renewal rates were 90.5%.

Sales may have only increased 1.9% over last year, but membership fee revenue increased 6.1%, and cardmembers increased 7%. This is what investors see in Costco's future potential.

Beyond this, another check in its favor is the ample opportunity for new store openings. It finally opened in China this year, already has three stores there, and has plans for two more before the year is over. That market itself affords enormous opportunities, but it's opening methodically in many global regions.

Which is the better buy today?

As for valuation, both of these stocks are expensive right now, but there's a huge difference. Amazon stock trades at 81 times forward one-year earnings, while Costco stock trades at 39. 

Both of these stocks have outperformed the market over time and are great stocks to own with enormous future opportunity. I frequently recommend them both. But if I had to pick one today, it would be Costco. It's more reliable and less expensive, and the growth runway is long.