The field of artificial intelligence (AI) has stirred up a burst of enthusiasm among investors in recent times, but that fervor can sometimes wax and wane.

Consider C3.ai (AI 3.85%) and UiPath (PATH 1.11%). Both help organizations streamline their operations with AI tools. C3's AI algorithms can be plugged into an organization's existing software to automate tasks, detect fraud, and improve employee safety. UiPath develops software robots for automating repetitive tasks like entering data, processing invoices, onboarding customers, and sending out mass emails.

Both companies initially dazzled the bulls. C3's stock more than quadrupled from its IPO price of $42 to its all-time high of $177.47 on Dec. 22, 2020. UiPath's stock rallied from its debut price of $56 to a record high of $85.12 on May 24, 2021. But today, C3 and UiPath trade about 30% and 70%, respectively, below their IPO prices.

Both stocks lost their luster as their sales growth cooled off in a tougher macro environment and rising interest rates popped their bubbly valuations. So should you buy either of these fallen tech stocks as a long-term play on the booming AI market?

Androids working on laptop computers in an office.

Image source: Getty Images.

What happened to C3.ai?

C3's revenue rose 17% in fiscal 2021 (which ended in April 2021) and 38% in fiscal 2022. But in fiscal 2023, its revenue only rose 6% as the macro headwinds drove companies to rein in their software spending.

That slowdown was exacerbated by C3's abrupt shift from a subscription-based model to a usage-based one last year. Management said this would attract more customers in a tough market, but it also throttled its near-term revenue growth.

To make matters worse, C3 still generates more than 30% of its revenue from a joint venture with the energy giant Baker Hughes that is set to expire in fiscal 2025 and has yet to be renewed.

C3 expects its revenue to rise 11% to 20% in fiscal 2024 as the macro environment stabilizes and it rolls out its new AI suite to capitalize on the growing demand for generative AI services like OpenAI's ChatGPT. But it also expects its increased investments in marketing those generative AI tools to reduce its adjusted operating margin from negative 26% in fiscal 2023 to negative 28% in fiscal 2024.

In its latest quarter, C3 also withdrew its previous guidance for achieving profitability on an adjusted basis in fiscal 2024. That grim outlook suggests it will sacrifice its near-term margins to squeeze out more sales and hop aboard the generative AI bandwagon as the expiration of its Baker Hughes deal looms on the horizon.

That's not a promising situation for a stock that still trades at 11 times this year's sales.

What happened to UiPath?

UiPath's revenue surged 81% in fiscal 2021 (which ended in January 2021) and grew another 47% in fiscal 2022. But revenue only rose 19% in fiscal 2023 as the macro headwinds throttled the market's demand for its robotic process automation (RPA) tools.

For fiscal 2024, however, UiPath expects revenue to rise 20% to 21% as the economy stabilizes. Unlike C3, UiPath doesn't have any major customer-concentration issues and remains firmly profitable on an adjusted basis. Analysts expect its adjusted earnings to nearly triple for the full year.

UiPath established a first mover's advantage in the RPA market, which Fortune Business Insights expects to have a compound annual growth rate (CAGR) of 23.4% from 2022 to 2029. The company faces intense competition from similar cloud-based automation services like Microsoft's (NASDAQ: MSFT) Power Automate and Salesforce's (NYSE: CRM) MuleSoft RPA in that growing market, but its gross and operating margins are still expanding, while its dollar-based net retention rate -- which gauges its year-over-year revenue growth per existing customer -- remains comfortably above 100%.

UiPath also plans to upgrade its own RPA tools with generative AI features to make it easier to accelerate and automate certain tasks. But some companies could start deploying their own generative AI tools instead of using dedicated RPA tools, so it's still unclear if it can keep pace with this seismic technological shift.

As for its valuations, UiPath looks slightly cheaper than C3 at eight times this year's sales.

The obvious winner: UiPath

C3's catchy ticker symbol brought some bulls back to its stock during the buying frenzy in AI stocks over the past year. But its customer-concentration issues, jarring changes in its business model, and lack of profits all make it a weaker investment than UiPath.

And although UiPath still has a lot to prove, it's growing faster, its margins are higher, it's more diversified, and its stock is cheaper.