Meta’s drive to integrate artificial intelligence into its products yielded strong financial results for the second quarter in a row. The company plans to spend even more on AI in the coming months, though, and its share price slumped more than 15% as the company reported earnings Wednesday. A weak sales forecast and higher spending guidance rattled investors.

Mark Zuckerberg said his main focus for the rest of 2024 and likely 2025 will be “getting millions or billions of people to use Meta AI” rather than generating revenue from it. He cautioned that Meta products such Instagram Reels have in the past not immediately generated revenue as they scaled before they became profitable pieces of Meta’s ad business.

He made the same prediction for Meta AI: “We build out the inventory first and then we monetize it”, saying Meta was “scaling the product before it is making money”.

“We’re more optimistic and ambitious on AI” than last quarter, Zuckerberg added.

Revenue at the world’s largest social media business increased 27% to $36.46bn during the first quarter in contrast to analyst expectations of $36.16bn. Earnings per share more than doubled to $4.71, surpassing expectations on Wall Street of $4.32.

Shareholders were spooked by revenue guidance for the next quarter: $37.75bn, growth of about 18%. Analysts had predicted around $38.3bn.

Forrester’s VP research director Mike Proulx said: “There’s no doubt that Meta is all-in on AI, but to achieve its vision, the company has to make big investments in infrastructure. Mark Zuckerberg’s ‘heads up’ was reminiscent of what he once said about the metaverse, and that didn’t exactly go so well. But this is different than Meta’s metaverse gamble because AI has real and practical use cases now.”

Meta also now expects its capital expenditure to be between $30bn and $40bn this year, up from an earlier forecast of between $35bn and $37bn.

Shares in the firm, which owns Facebook, Instagram and Whatsapp, were down sharply in after-hours trading. The group did not issue a dividend to investors for the first quarter of 2024, having done so for the first time in its history in the last quarter, which bolstered investors’ confidence.

Proulx said: “The question remains whether Meta can contend in the AI race while maintaining a strong financial position. To do this, expect to see more ‘metaverse’ resources diverted from Reality Labs to Meta’s AI initiatives.”

TikTok, a key competitor, is facing extreme regulatory pressure and uncertainty, leading investors to put their money in safer bets. The day before Meta reported earnings, the Senate approved a bill that would ban TikTok if it were not sold to an American company. Joe Biden signed the bill the day of the earnings report.

Meta chief financial officer Susan Li said it was “too early to assess” the effect of the bill on Meta’s business.

Meta’s shares have rallied by nearly 40% this year. Investors have cheered Zuckerberg’s and the company’s pivot from investment in its metaverse products to spending big on artificial intelligence.

Emarketer senior analyst Max Willens said the results were positive, but Meta needed to continue its upward momentum in the face of rising costs.

“For all the recent scrutiny of its effectiveness, Meta’s ad business is humming,” Willens said. “With inventory levels and average price per ad rising, Meta is back to delivering enviable margins even as it continues to invest in opportunities that may be years away from contributing to profits.”

Last week, the company announced it would integrate its partially released Llama 3 large language model across its platforms. The Meta AI assistant will also roll out to Australia, Canada, Singapore, Nigeria and Pakistan. The company also said it would add real-time image generation to its social networks.

Investors also gave their blessing to Zuckerberg’s declaration of a “year of efficiency” in 2023, which in practical terms meant four sweeping rounds of layoffs. According to the earnings report, the company’s workforce was down 10% since last year. The company cut more than 20,000 jobs, reducing its headcount to a figure similar to that of 2021. The company had doubled its workforce from 2020.

Regulatory headwinds have formed a dark cloud on the horizon, however. Zuckerberg testified at a congressional hearing earlier this year, during which lawmakers raised the prospect of stripping Meta of its primary shield from legal liability for what its users post.

Advocates say Meta fails to adequately protect children, and some lawmakers agree. New Mexico’s attorney general is suing the company for allegedly facilitating child predation. More than 30 states are suing the company for allegedly endangering teens’ mental health.

Speaking to parents at the hearing whose children had killed themselves after facing harassment and sex trafficking via social media, Zuckerberg said: “I’m sorry for all that you have been through.”