How To Use ChatGPT On Azure OpenAI – 2023 Guide

ChatGPT is an advanced conversational AI system created by OpenAI. It can understand natural language prompts and generate human-like responses on a wide range of topics. With the recent launch of the Azure OpenAI service, it is now possible to access ChatGPT and other OpenAI models through the Microsoft Azure cloud platform.

In this guide, we will walk through how to set up and use ChatGPT on Azure step-by-step.


To follow along with this guide, you will need:

  • An Azure subscription – you can sign up for a free account if you don’t already have one.
  • The Azure CLI installed on your local machine.
  • Access to create resources in your Azure subscription.

Step 1 – Create an Azure OpenAI Service Resource

The first step is to create an Azure OpenAI service resource in your Azure subscription.

  1. Login to the Azure Portal with your Azure account credentials.
  2. Click on the “Create a resource” button and search for “Azure OpenAI Service”.
  3. Select the “Azure OpenAI Service” result and click “Create”.
  4. Fill in the basic details:
    • Subscription: Choose your Azure subscription.
    • Resource Group: Create a new resource group or use an existing one.
    • Name: Enter a name for the Azure OpenAI resource.
    • Region: Select the geographic region closest to your users.
  5. Click “Review + Create” to review the settings and create the resource.

Once deployment completes, you will have an Azure OpenAI resource configured in your subscription.

Step 2 – Create an Azure OpenAI API Key

To start making API calls to Azure OpenAI, you need to generate an API key.

  1. In the Azure Portal, go to your newly created Azure OpenAI resource.
  2. On the left menu, click on “Keys and Endpoint” under “Resource Management”.
  3. Click the “+ Create” button to generate a new API key.
  4. Enter a description and click “Create”.
  5. Make note of the API key value that is displayed. This key will be used to authenticate API requests.

You now have an API key to start using the Azure OpenAI APIs.

Step 3 – Install the Azure CLI OpenAI Extension

To simplify interacting with Azure OpenAI from the command line, you can install the OpenAI extension for the Azure CLI.

Run this command to add the extension:

az extension add --name openai

Next, login to the Azure CLI with:

az login

Then set your OpenAI API key:

az openai account set -k YOUR-API-KEY

Replace YOUR-API-KEY with your actual API key value from the Azure Portal.

The Azure CLI and OpenAI extension are now ready to use.

Step 4 – Make Requests to the Azure OpenAI API

With everything set up, you can now start making API calls to Azure OpenAI to access capabilities like ChatGPT.

Here is an example request using the Azure CLI:

az openai ask -q "Explain quantum computing in simple terms

This will send the question “Explain quantum computing in simple terms” to the ChatGPT model and display the response.

You can also try more interactive conversations by omitting the -q parameter:

az openai ask 

This will open an interactive prompt where you can have a back-and-forth conversation with the ChatGPT model:

Human: Hello!

AI: Hello there! Nice to meet you. How can I help you today?

Some other ways you can use the Azure OpenAI API with the CLI:

  • Generate an image from a text prompt:

az openai image generate -p "a cute baby sea otter"

  • Generate code from a text prompt:

az openai code generate -p "write a python function to reverse a string"

  • Moderation to detect harmful content:

az openai moderation -i "offensive content"

The CLI provides a convenient way to test out the API without needing to write any code!

Behind the scenes, it is calling the Azure OpenAI REST API endpoints with your API key for authentication. But the CLI abstracts away these implementation details to make it fast and easy.


With a few simple steps, anyone can now leverage the power of advanced conversational AI through ChatGPT on the Microsoft Azure platform. By deploying an Azure OpenAI resource, configuring authentication, and using the Azure CLI OpenAI extension, you can integrate ChatGPT capabilities into your applications and solutions.


What is ChatGPT?

ChatGPT is an AI-powered conversational chatbot created by OpenAI. It uses machine learning to understand natural language and generate human-like responses.

How can I access ChatGPT?

The easiest way to access ChatGPT is by deploying an Azure OpenAI service in your Azure subscription. This provides managed access to ChatGPT and other OpenAI models.

What are the benefits of using ChatGPT on Azure?

Key benefits include easy deployment, enterprise-scale access, tight integration with Azure services, built-in security and compliance, and streamlined usage through the Azure CLI.

What can I build with ChatGPT on Azure?

ChatGPT can power a wide range of AI applications and solutions including conversational interfaces, intelligent chatbots, natural language processing, content generation, and more.

Is there a cost for using Azure OpenAI?

Yes, Azure OpenAI usage is metered and billed based on the number of tokens processed. But low-cost tier options are available for testing.

Do I need machine learning skills to use ChatGPT on Azure?

No specialized skills are required. The Azure OpenAI service abstracts away the complexity so anyone can leverage conversational AI.

How can I secure access to ChatGPT on Azure?

Use role-based access controls, private endpoints, and network security groups to limit and secure access to your Azure OpenAI resource.

What languages and regions is ChatGPT available in on Azure?

Currently, English language support is available in Azure OpenAI regions including West US, East US, West Europe, and Southeast Asia.

Can I customize ChatGPT responses on Azure?

Yes, Azure OpenAI integrates with Azure tools like LUIS to allow training ChatGPT with your own data and customizing responses.

Leave a Comment