There are many ways to invest in artificial intelligence (AI). Choosing companies directly involved with launching or integrating an AI product might be more flashy, but plenty of opportunities exist with businesses that supply crucial components.

That's where ASML (ASML -0.94%) and Taiwan Semiconductor Manufacturing (TSM -0.48%) fit in. Both are vital to the technology because of their products; without either, AI wouldn't be where it is today. Let's see if these two stocks would be good additions to your portfolio now.

Taiwan Semiconductor

Taiwan Semiconductor (or TSMC) is the world's largest contract chip manufacturer. This means it makes the chips for companies that want to design their own microchips but don't have the facilities to produce them. This makes TSMC a go-to partner for companies like Apple, Nvidia, and AMD because it has some of the most powerful technologies available.

Its 3-nanometer chips represent its most advanced technology, offering improvements over previous generations through decreased power consumption and greater computing capacity. It's also developing its 2nm chips and plans to have them available in 2025.

The company continuously pushes the limits of what's possible to give its customers the ability to develop more powerful and efficient products. It's a vital part of the AI value chain.

TSM PE Ratio (Forward) Chart

TSM PE ratio (forward) data by YCharts; PE = price-to-earnings.

TSMC is also a solid investment. In 2023, it dealt with a chip oversupply, which caused many customers to reduce their orders. So far in 2024, however, that hasn't been the case. In January and February, revenue rose 8% and 11%, respectively, year over year. Wall Street analysts expect this strength to continue this year and next, forecasting 21% and 20% revenue growth in 2024 and 2025, respectively.

With the stock trading at a reasonable 22 times expected earnings this year, the company is a strong investment in AI.

ASML

While TSMC gets praise for its advanced chipmaking ability, ASML is the company which helps enable that outcome. The term 3nm or 2nm refers to the distance between conductive traces on the chip (the lower the number, the better). Getting the space that small requires specialized equipment that only ASML makes.

Because of the advanced technology that ASML's extreme ultraviolet lithography machines require, it's the only company in the world that makes those machines. So it's virtually a technological monopoly.

But this comes with a premium price tag. At nearly 48 times forward earnings, ASML is a very expensive stock. It has this premium because many investors know that chipmakers like TSMC or Intel need to increase their high-end chip production. That requires machines from ASML, so investors expect lots of growth ahead.

Because its machines take a long time to build, that effect won't immediately be realized. In 2024, analysts only expect about 2% revenue growth, but that forecast jumps up to 27% in 2025.

ASML PE Ratio (Forward) Chart

ASML PE ratio (forward) data by YCharts.

If you're investing in ASML, you should be focused on the long term because its results can be quite lumpy if a machine or two isn't sold before the quarter ends. For example, in the fourth quarter, the company sold 113 new machines and 11 old ones.

But if there's a down year for chip production (such as 2023), there might not be as much demand for increased manufacturing capacity the next year. This is the effect ASML is currently feeling, but it isn't expected to last long.

ASML's technological monopoly is a top reason to invest in the stock, but you must have the right mindset to own it for the long term. If you can do that, it could make a fantastic AI investment.