The debut of OpenAI's ChatGPT last November captivated tech enthusiasts and forced the public to rethink what was possible with artificial intelligence (AI). Since then, countless businesses have added AI tools to their workflows in an effort to boost productivity.

Increasing demand for AI services has led companies such as Amazon (AMZN 0.38%) and Microsoft (MSFT -0.45%) to pivot their businesses toward developing the industry, adding several new AI features to their cloud platforms. As the world's first- and second-largest cloud companies, Amazon and Microsoft are in steep competition to snap up market share as the industry expands.

Consequently, Amazon and Microsoft make attractive investments for anyone looking to invest in AI. So, let's assess whether Amazon or Microsoft is the better buy. 

Amazon: Diversifying its position in AI

Amazon has doubled down on AI since the start of the year, with CEO Andy Jassy revealing in the company's second-quarter earnings call that nearly every division is building generative AI applications. Amazon aims to enhance its consumers' experience, whether in entertainment, cloud computing, advertising, or devices that feature its virtual assistant, Alexa.

Despite a major push into the market this year, Amazon is no stranger to AI. It has used the technology for years to make its retail business more efficient in tasks such as making product recommendations, tracking shopping trends, and managing shipping logistics. However, recent months have seen the company greatly expand its AI offerings on Amazon Web Services (AWS).

The cloud platform unveiled several new AI tools since June, including a language-model-based service called Bedrock, a code generator named CodeWhisperer, and one geared toward healthcare professionals called HealthScribe. Meanwhile, Amazon recently announced it was venturing into the hardware side of AI by developing its own chips, promising the best price-to-performance in the market.

Amazon's diversified business allows it to profit from many forms of AI, making its stock a compelling way to back multiple areas of the high-growth market. 

Microsoft: Bolstering its dominating software business

As the home of brands such as Windows, Office, and Azure, Microsoft's dominance in software is immense. Thousands of companies worldwide depend on the tech giant's productivity software for daily operations. As a result, Microsoft's venture into AI has allowed it to enhance several areas of its business and become one of the biggest names in the market.

In 2019, Microsoft invested $1 billion in OpenAI, increasing that figure by $10 billion after the launch of ChatGPT. The partnership gave Microsoft a head start in the lucrative industry, obtaining exclusive licenses to several of the start-up's AI models. With OpenAI's technology, the Windows company has brought AI upgrades to many of its products, including Excel, Word, Azure, and Bing. 

Like Amazon, Microsoft is investing in AI chips. The company is reportedly providing financial and engineering assistance to Advanced Micro Devices as it aims to create an alternative to Nvidia's costly hardware offerings. 

Microsoft's AI expansion is moving quickly, and as the second-most valuable company in the world, it certainly has the resources to continue investing in itself. 

Is Amazon or Microsoft the better stock for investing in AI?

Amazon and Microsoft are two of the best ways to invest in artificial intelligence. One holds leading market shares in cloud computing and e-commerce, two industries that have massive potential for AI. And the other has exclusive access to some of the most advanced AI technology and unparalleled dominance in software. 

However, Amazon may be the better buy if you're looking for a one-stop stock to invest in the booming industry. Microsoft may have gotten a head start in the sector with its early investment in OpenAI, but Amazon's home-grown services and chips could give it an edge over the long term as it has complete ownership of its AI technology.

Moreover, AWS' leading cloud market share could be a powerful tool in attracting customers seeking AI services, making Amazon the better AI stock right now.