The AI industry is staring down an uncertain and volatile macroeconomic environment, as well as some signals that demand for AI infrastructure may be starting to cool. AI server manufacturer Super Micro Computer slashed its guidance earlier this week as customers delayed purchasing decisions, and some tech giants reportedly have been pulling back on data center expansion.
But investors remain keen on investing in artificial intelligence (AI). What are the best AI stocks to buy in May? Personally, I'd steer clear of AI hardware companies like Super Micro and Nvidia, as well as hyperscalers like Microsoft that are pouring incredible amounts of capital into AI data centers to power the latest compute-hungry AI models. Instead, I'd focus on companies that are betting on AI inference and small, efficient, specialized AI models and agents. My top two picks this month are International Business Machines (NYSE: IBM) and Cloudflare (NYSE: NET).
Where to invest $1,000 right now? Our analyst team just revealed what they believe are the 10 best stocks to buy right now. Learn More »
There are multiple components to IBM's AI strategy, and all of them focus on real-world use cases for enterprise clients. The company has booked $6 billion in generative-AI-related business so far, adding $1 billion to that total in the first quarter, and much of that comes from the consulting business. While clients are being cautious with discretionary spending, generative AI projects are still getting the green light.
The consulting business feeds into the software business, where IBM's Watsonx AI platform headlines the company's AI efforts. Watsonx enables enterprise clients to build, test, deploy, and manage AI models and agents. The focus here is on small, fine-tuned models aimed at doing specific tasks well. IBM claims that enterprises can reduce costs by as much as 98.5% by switching away from expensive, general-purpose AI models.
Image source: Getty Images.
Lastly, there's IBM's mainframe business. While the mainframe isn't as prolific as it once was, some industries continue to depend on the ultra-powerful systems due to their reliability and backward compatibility with decades-old code. The upcoming z17 mainframe, set to launch in June, can churn through 450 billion AI inferencing operations per day with latency of around 1 millisecond. This makes the system ideal for real-time AI inferencing tasks like detecting credit card fraud.
Taken altogether, IBM has built a broad portfolio of enterprise AI services, software, and hardware. While the company isn't immune to an economic slowdown, AI projects meant to reduce costs or boost efficiency should continue to be in demand from IBM's enterprise clients.
Cloudflare is all about speed. A developer can stick Cloudflare's platform between a user and a web application, performing ultra-fast computations on the fly when a user makes a request. There are many use cases that are covered by Cloudflare's platform, including handling redirects, enforcing authentication, and returning different responses based on the user's location. Another use case is running AI inference tasks using small, efficient, fast models without needing to worry about managing infrastructure or scaling resources.
Cloudflare's AI platform supports more than 50 open-source AI models, including models capable of generating text, classifying images, translating text, converting text into speech, and summarizing content. These models integrate tightly with Cloudflare Workers, the company's serverless computing product, allowing them to be programmatically accessed in response to user requests.
Because Cloudflare focuses on AI inference and running smaller AI models, the company doesn't need the absolute fastest AI accelerators that are typically used for computationally intensive AI training workloads. Instead, the company has some leeway to install older, less expensive AI accelerators while still achieving the necessary performance and latency for AI requests. This takes Cloudflare out of the scramble to secure the latest and greatest GPUs from Nvidia and likely reduces costs considerably.
Cloudflare's revenue grew by 27% year over year in the fourth quarter of 2024, and it gained a record number of large customers spending at least $1 million annually on the platform. With nearly 240,000 paying customers, Cloudflare's AI products are an easy choice for customers looking to deploy AI inference workloads.
Before you buy stock in International Business Machines, consider this:
The Motley Fool Stock Advisor analyst team just identified what they believe are the 10 best stocks for investors to buy now… and International Business Machines wasn’t one of them. The 10 stocks that made the cut could produce monster returns in the coming years.
Consider when Netflix made this list on December 17, 2004... if you invested $1,000 at the time of our recommendation, you’d have $610,327!* Or when Nvidia made this list on April 15, 2005... if you invested $1,000 at the time of our recommendation, you’d have $667,581!*
Now, it’s worth noting Stock Advisor’s total average return is 882% — a market-crushing outperformance compared to 161% for the S&P 500. Don’t miss out on the latest top 10 list, available when you join Stock Advisor.
See the 10 stocks »
*Stock Advisor returns as of April 28, 2025
Timothy Green has positions in International Business Machines. The Motley Fool has positions in and recommends Cloudflare, International Business Machines, Microsoft, and Nvidia. The Motley Fool recommends the following options: long January 2026 $395 calls on Microsoft and short January 2026 $405 calls on Microsoft. The Motley Fool has a disclosure policy.