Whether you're a casual investor or trade professionally, you have likely heard about the boom in artificial intelligence (AI). Last November, the launch of OpenAI's ChatGPT renewed interest in AI and caused many experts to rethink what is possible with the technology. 

According to data from Grand View Research, the $137 billion AI market is projected to have a compound annual growth rate of 37% through 2030. The sector's potential has attracted many of the biggest names in tech, with a race underway to see which companies can snap up the most market share. So it's not a bad idea to consider investing in the sector before it develops further.

Apple (AAPL 0.71%) and Microsoft (MSFT 0.28%) are two attractive options as the first and second most-valuable companies by market cap, respectively. These tech giants have the resources to invest heavily in AI and achieve leading positions in the industry. 

Let's examine whether Apple or Microsoft is the better artificial intelligence stock. 

Apple: Developing a rival to ChatGPT

While Apple might not be the first company that comes to mind in a discussion about AI, the iPhone manufacturer is no stranger to the technology. It has quietly expanded its AI features across its product lineup this year. 

At its Worldwide Developers Conference in June, the company debuted an update to the iPhone's autocorrect, which uses a language model similar to ChatGPT to improve messaging. Meanwhile, an AI-enabled feature will be added to AirPod Pros that will automatically turn off noise canceling when the user begins to speak. 

The company also reportedly developed a custom framework for building large language models and created an AI chatbot that engineers have dubbed Apple GPT.

As a dominating figure in consumer tech with leading market shares in multiple product categories, Apple has the power to become a threat in AI over the long term. Its popular devices could be crucial in getting the technology into millions of homes worldwide as it significantly profits along the way. 

Microsoft: Some of the most powerful AI models at its fingertips

Microsoft shares climbed 40% since Jan. 1, mainly driven by its growing prospects in AI. The company quickly became one of the most prominent names in the field as the largest investor in OpenAI. 

The collaboration allowed Microsoft to obtain exclusive licenses on some of OpenAI's most powerful AI models. Meanwhile, the company used the start-up's technology to bring AI upgrades to several of its homegrown services, including Word, Excel, Azure, and its search engine Bing.

The potency of these apps strengthens Microsoft's potential to become a go-to for consumers and businesses seeking to use AI's abilities. 

Microsoft is continuing to invest in the market by financially backing Advanced Micro Devices' AI chip expansion and providing engineering resources. The goal is to create an alternative to the current industry leader, Nvidia, and bring down the cost of chips. 

Microsoft seems intent on making AI one of the focal points of its business and so far has made progress in the lucrative sector. As Microsoft continues to expand its AI services through Azure and its productivity software, investors won't want to miss out on its potential stock growth. 

Is Apple or Microsoft the better stock to invest in AI?

Apple and Microsoft have solid claims to AI, with both likely to profit significantly from it over the long term. But Microsoft's partnership with OpenAI and its successful cloud platform Azure give it more tangible ways to enjoy boosted earnings from the technology in the not-so-distant future. Meanwhile, it's still early days for Apple's venture into AI, and it remains to be seen how that will benefit its business. 

Microsoft's investment of $1 billion in OpenAI in 2019 gave it a massive advantage, beating companies like Apple, Amazon, and Alphabet to the market. As a result, it's one of the most reliable ways to back the booming technology.

So if you're trying to decide between Apple or Microsoft as a way to invest in AI, Microsoft is the way to go. But it's still a good idea to keep Apple in mind for future investment.