Nvidia is soaring on the heels of accelerating growth for AI chips, but the stock is already selling at an expensive valuation of 38 times trailing revenue. But even great companies can be lousy investments if you pay too much.

There are better values out there that could soar over the next several years from accelerating demand in artificial intelligence (AI). Here are two alternative AI stocks I would buy today instead of Nvidia.

1. Amazon

After a sluggish year of performance, Amazon (AMZN 1.90%) is on the verge of seeing improving growth. A key catalyst is the growing demand for AI services in the Amazon Web Services (AWS) cloud business.

The growing demand for Nvidia's hardware is a good sign for Amazon. Companies are buying Nvidia's GPU-based AI systems to process large data workloads to train AI models and deliver smart applications and services to customers -- and Amazon is one of them. 

As the market-share leader in cloud services, Amazon is well-positioned to deliver returns to shareholders from the growing demand for AI cloud services. AWS makes up 17% of Amazon's total revenue but generates virtually all of Amazon's operating profit, making it a key driver for the stock. Growing demand for AI services could lead to better-than-expected revenue growth in the next year and fuel the stock higher.

In the most recent quarter, AWS introduced new tools that make it easier to build applications using generative AI. Amazon has also invested in its own chips that are purpose-built for training models with deep learning, which is based on AI. This could lay the foundation for a resurgence in cloud growth over the next few years.

With the stock selling at a decade-low valuation of 2.5 times sales, the stock appears undervalued ahead of a growth acceleration in AWS.

2. Advanced Micro Devices

Advanced Micro Devices (AMD 0.68%) has trailed Nvidia in market share in the GPU market for many years but will almost certainly see growth in AI. Most importantly, investors can buy the stock at a much cheaper valuation.

AI will require a massive amount of computing power across cloud, edge computing, and consumer devices. Over the last decade, AMD has built a broad portfolio of chips to address this opportunity. It now offers data processing units (DPUs) and adaptive SoC (system-on-chip) following the acquisition of Xilinx. This expands the company's addressable market to AI applications at the edge, such as vehicles and other connected devices.

AMD recently launched new products aimed at meeting the growing demand for AI technology in the consumer space. The AMD Ryzen 7040 series processors are specifically designed to handle AI workloads for laptops running Microsoft's Windows 11.

It's clear AMD is making AI a top priority and has the financial resources to do so. Free cash flow has exploded to more than $2.5 billion over the last five years, and the company is already sitting on a $3.4 billion pile of net cash (after debt) on the balance sheet

Growing demand in the data center business, where advanced chips generate higher margins than consumer chips, has bolstered AMD's profitability in recent years and should continue to fuel robust growth in free cash flow over the long term.

The stock trades at a price-to-sales ratio (P/S) of 8.6, which is a huge discount, compared to Nvidia's P/S of 37. AMD stock offers much better value and could outperform its competitor over the next several years.