The S&P 500 index had a strong first half of 2023 and has gained over 17.5% so far this year -- mainly driven by an artificial intelligence-fueled stock rally and easing inflation. The U.S. economy has also proved resilient and posted an unexpected 2.4% year-over-year growth rate in the second quarter, driven by a 7.7% year-over-year jump in business investment (excluding housing).

Against this backdrop, several analysts believe (with varying degrees of caution and optimism) that Wall Street now may be in the early stages of a bull market, especially since the S&P 500 has rallied by more than 20% from its October 2022 low.

Investors looking to capitalize on the momentum of this bull rally should consider opening small positions in two AI stocks: Palantir (PLTR 1.96%) and Alphabet (GOOG 0.81%) (GOOGL 0.72%). Here's why.  

Palantir

Data mining and analytics specialist Palantir has been a major beneficiary of Wall Street's artificial intelligence (AI) rally. But although the company's shares have gained nearly 209% so far this year, they still have significant growth potential. Veteran Wedbush analyst Dan Ives seems to agree with this premise; he recently initiated coverage for the company with an outperform (buy) rating and a price target of $25.

While many companies are now racing to come up with AI-based solutions, Palantir has been offering AI-based services to its clients for the past two decades. Not resting on its laurels, the company launched a new AI platform (AIP) in April. Palantir AIP enables clients to deploy large language models on the company's internal network and use proprietary data to personalize recommendations, actions, and workflows. Thanks to its customized ChatGPT-like services, AIP has been seeing unprecedented demand from military clients.

While AIP could prove to be a game-changer for Palantir in the long run, the company has also impressed short-term investors with its focus on profitability. The company recorded a GAAP (generally accepted accounting principles) profit for the second consecutive quarter in the first quarter, and expects to remain GAAP profitable in all quarters of 2023. The company is also free-cash-flow positive and had $2.3 billion cash and no debt on its balance sheet at the end of the first quarter.

There is no doubt that Palantir is a pricey stock, trading for roughly 21 times sales -- far higher than the software industry's median price-to-sales ratio of 2.4. However, considering that Goldman Sachs expects generative AI to help increase global GDP by 7% or by $7 trillion in the next decade, a well-established AI stock could see much higher prices in the coming months.

Alphabet

Since the launch of OpenAI's ChatGPT, many analysts and investors have been worried about the growth prospects of Alphabet, which derives over half of its revenue from Google Search. While the dent the generative AI could deal to Alphabet's near-monopoly in the internet search space is now all but obvious, there are still several factors that could propel shares of this trillion-dollar company on an upward trajectory.

First, advertising demand is expected to recover in a growing economy -- and that is driving up Google Search and YouTube revenues. Google Search revenues grew by 4.7% year over year in the second quarter, compared to the 1.9% year-over-year revenue growth it posted in the first quarter. YouTube revenues also rose by 4% in the second quarter, a marked improvement from their 2.6% decline in Q1.

YouTube's audience is also steadily increasing: 2 billion monthly active users are watching short-form videos on the platform, and 150 million people in the U.S. are accessing YouTube on their connected televisions.

Second, Alphabet posted a 28% year-over-year jump in revenues to $8 billion and an operating profit of $395 million (operating margin of 5%) for its Google Cloud business. Currently, 70% of the generative AI unicorn companies are using Google Cloud. While the long-term growth potential of Google Cloud is strong, management has hinted at some cautiousness for the business' growth prospects in the second quarter as customers continue to optimize their cloud spending.

Third, Alphabet is well positioned to benefit from the surge in interest in all things AI. It has built an AI-optimized infrastructure that is being used extensively to train generative AI models. Alphabet's chatbot Bard and next-generation conversational chatbot LAMDA (both based on large language models) could prove to be tough competition for ChatGPT. The company also offers a huge choice for AI supercomputers, and recently launched the A3 AI supercomputer, which is powered by Nvidia's H100 AI chip. Finally, demand for Alphabet's AI models has increased by over 15 times from April 2023 to June 2023. These trends indicate that there is significant monetization potential in Alphabet's AI business.

Thanks to its stellar stock price performance in the second quarter, the king of search is no longer cheap. Alphabet currently trades at 33.4 times earnings, significantly higher than the software industry's median price-to-earnings multiple of 16.9. However, considering the improving advertising environment, the strength of the Google Cloud platform, and its AI initiatives, Alphabet could prove to be an attractive pick even at this elevated valuation.