Alphabet (GOOGL -0.16%) (GOOG 0.01%) and Palantir Technologies (PLTR -7.29%) two obvious artificial intelligence (AI) beneficiaries. Alphabet's shares have climbed as the company integrates new AI features into Google and YouTube, while Palantir has rallied on accelerating growth as it benefits from "the astonishing impact of AI leverage," as Palantir's Alex Karp put it in the company's second-quarter earnings call.

The two businesses, however, couldn't be more different. Alphabet is the parent of Google, YouTube, Google Cloud, and Gmail (among other digital properties), making most of its money from advertising and a growing sum from cloud computing. Meanwhile, Palantir sells software that helps governments and companies use data to inform decisions.

But which AI stock is a better buy? I believe the choice comes down to two factors: business durability and valuation -- and one of the two stocks wins on both.

Palantir: rapid growth at a wild price

Palantir's latest numbers justify enthusiasm for the business. Its second-quarter revenue rose 48% year over year to about $1 billion. This growth rate was up from 39% growth in the prior quarter. Palantir's second-quarter growth was driven by 53% year-over-year growth in U.S. government revenue and 93% growth in commercial revenue.

But perhaps a more important achievement during the quarter than accelerating revenue growth was its substantial profit. Palantir posted GAAP operating margin of 27%, $569 million in adjusted free cash flow, and ended the quarter with $6 billion in cash and no debt.

CEO Alex Karp called it "a phenomenal quarter," highlighting a Rule-of-40 score of 94% (a software-industry shorthand that combines a company's revenue growth rate and its adjusted operating margin to gauge the balance between growth and profitability). Note that a score above 40, hence the name "rule of 40," is considered good. So, Palantir's score is exceptional.

The biggest issue, however, is that Palantir's stock price already assumes near-flawless execution. The company has a forward price-to-earnings ratio above 200 and a price-to-sales ratio well above 100 -- valuation levels that leave almost no room for unexpected detours or competitive pressure.

Alphabet: a diversified business at a compelling price

Alphabet may not be delivering the extraordinary growth Palantir is, but it's still growing at a robust rate -- especially in the context of its much more reasonable valuation.

The online search giant's revenue rose 14% year over year to $96.4 billion, its operating margin was 32.4%, and its earnings per share increased 22%.

Importantly, Alphabet saw broad-based double-digit growth across its segments, including search, YouTube ads, and Google Cloud.

"AI is positively impacting every part of the business," CEO Sundar Pichai said in the company's second-quarter earnings release, adding that its cloud computing business's (Google Cloud) annualized revenue run-rate is now more than $50 billion.

This breadth across the tech giant's business, including Google-owned digital properties Google Search and Android, Google Cloud, YouTube, and its advertising business that scales across Alphabet's network partners' properties, puts it on another level when compared to Palantir. These diversified growth drivers make the business more durable and ultimately easier to bet on. Additionally, Alphabet has a number of businesses that are leaders in their categories, giving them competitive advantages unlikely to erode anytime soon.

And valuation arguably seals the deal, making Alphabet the clear winner in a comparison with Palantir. Shares of the Google parent trade around a forward price-to-earnings ratio in the low-20s and a price-to-sales ratio of about 8. For a company posting double-digit growth and robust margins, this is quite compelling.

Sure, Palantir's business momentum is impressive -- and it could exceed expectations going forward. But investors are paying a staggering premium for it. Alphabet, on the other hand, offers a more balanced way to participate in AI: multiple growth engines, substantial cash generation to fund both growth investments and buybacks, and an attractive price tag.