A boom in artificial intelligence (AI) kicked off last year and has shown no signs of slowing. The nearly $200 billion industry is projected to expand at a compound annual growth rate of 37% until at least 2030. That trajectory would see the market hit close to $2 trillion before the end of the decade.

AI can potentially boost countless industries, from healthcare to consumer tech, education, e-commerce, cloud computing, autonomous vehicles, and much more. With growth catalysts across multiple sectors, it could be one of the smartest moves to dedicate a portion of your portfolio to AI and profit from its long-term development.

As the world's first- and fourth-most valuable companies, Microsoft (MSFT 1.82%) and Nvidia (NVDA 6.18%) are two attractive options. These companies are heavily investing in AI and have secured powerful roles in the market, with one leading the software side of AI and the other dominating hardware.

MSFT Chart

Data by YCharts

Microsoft and Nvidia stocks have already made more than a few millionaires, with their shares skyrocketing over the last decade (as seen in the chart above). While past growth doesn't always indicate what's to come, I wouldn't bet against these tech firms delivering significant gains thanks to AI long into the future.

So, here are two AI stocks that could set you up for life.

1. Nvidia

Nvidia has become a Wall Street darling since the start of last year after snapping up an estimated 80% to 95% market share in AI graphics processing units (GPUs), the chips necessary for training and running AI models.

Increased interest in AI has led to a spike in demand for GPUs. Meanwhile, Nvidia's years of dominance in the GPU market allowed it to get a head start in the segment while rivals like Advaned Micro Devices and Intel scrambled to catch up. These chipmakers have since unveiled competing AI GPUs, but will likely have difficulties overcoming Nvidia's lead.

NVDA Revenue (Quarterly) Chart

Data by YCharts

Over the last year, Nvidia's quarterly revenue, operating income, and free cash flow have hit new heights as each has delivered triple-digit growth thanks to soaring chip sales.

In fact, Nvidia's free cash flow hit more than $17 billion in 2023, significantly higher than AMD's just over $1 billion and Intel's negative $14 billion. Nvidia's running start in AI has given it the financial resources to continue investing in its business and retain its lead in AI.

The uses for artificial intelligence are rapidly expanding, suggesting GPU demand will continue rising for the foreseeable future.

Nvidia has an exciting long-term outlook as it continues developing in AI and supplies its chips to other areas of tech, such as video game consoles, PCs, and cloud platforms. Its price/earnings-to-growth ratio has dropped 85% in the last six months to an attractive 0.4, indicating it could be trading at a bargain compared to its growth potential.

Nvidia is a screaming buy for anyone looking to invest in AI and could deliver major gains for years.

2. Microsoft

In January, Microsoft surpassed Apple as the world's most valuable company, with its market cap currently at just over $3 trillion. The company is a tech behemoth with positions in multiple areas of the industry, leading in productivity software, game consoles, cloud computing, and operating systems.

Meanwhile, heavy investment in ChatGPT developer OpenAI has led to a lucrative partnership and access to some of the most advanced AI models in the industry. The Windows company has used OpenAI's technology to introduce AI features across its product lineup.

In 2023, Microsoft added new AI tools to its Azure cloud platform, integrated aspects of ChatGPT into its Bing search engine, and boosted productivity in its Office software suite with the help of AI.

Moreover, the company is taking early steps to monetize its new offerings, launching an AI assistant called Copilot through its Microsoft 365 subscription service. The company describes the assistant as "your everyday AI companion." Some of its generative capabilities include creating a first draft in Word, generating a full PowerPoint presentation based on a simple prompt, and producing data visualizations in seconds in Excel.

Copilot has debuted as a $30 monthly add-on to a 365 membership, which could lead to significant earnings boosts for Microsoft.

The tech giant achieved more than $67 billion in free cash flow last year, highlighting the reliability of its business and its value as a long-term investment. The company's stock is slightly overvalued, with its forward price-to-earnings ratio at about 35. However, its long history of growth, dominant role in tech, and expanding venture into AI means it is likely worth its high valuation.

The company is profiting from tailwinds across tech and has excellent prospects in AI, suggesting a long-term investment in Microsoft's stock could set you up for life.