How to Use Postman to Call Azure OpenAI’s API — A Step-by-Step Tutorial

In today’s article, we will introduce how to use Postman to call the Azure OpenAI API.

The article will be divided into several stages:


  1. Creating Azure OpenAI Service, obtaining the service Key and Endpoint
  2. Establishing a new Collection on Postman and connecting to Azure OpenAI
  3. Enhancing security measures, writing Key and Endpoint into environment variables


Now let’s dive into the main subject of this tutorial, integrating Azure OpenAI with Postman. Let’s get started!

Creating Azure OpenAI Service, Obtaining the Service Key and Endpoint

(1) Go to Azure Portal

(2) Search for “OpenAI” and create a service



Once the service is created,

  1. Navigate to “Keys and Endpoint” under “Resource Management”
  2. Obtain the KEY value for later use


Next, click on Go to Azure OpenAI Studio

  1. Go to “Deployments" and deploy the model
  2. Proceed to “Playground” chat



Once the model is confirmed to be usable,

  1. click on “View code” and switch the setting to “json”.
  2. Copy the code.
  3. Then copy the service endpoint (Endpoint).



That concludes the Azure part!

Remember to keep the copied data safe for later use 

Establishing a New Collection on Postman and Connecting to Azure OpenAI

For first-time Postman users,

  1. Create a new “Workspaces”
  2. Choose “New” to create a new “Collection”
  3. After creation, select “Add a request”


Adjust the newly created Request

  1. change GET to “POST”,
  2. Select the “raw” option under “Body”
  3. switch “Text” to “JSON” format



Paste the “Endpoint” and code copied earlier and try sending a “POST” Request


However, you will find that the HTTP status code returns “401 Permission Denied” because we have not provided the Key for the service


So let’s add our API KEY to our Postman requests:

  1. Select “Params,” add the parameter “api-key”
  2. Paste the key copied earlier in the Value section, and
  3. Send the “POST” request again.

Seeing the HTTP status code display “200 OK,” and getting the content indicates that we have successfully called the Azure OpenAI API!

It’s exciting to successfully call the API, but exposing sensitive keys still feels odd. After all, data security is a serious issue we all need to be cautious about. If it’s leaked, it could lead to confidentiality breaches or significant financial losses.

Next, let’s look at how to enhance security measures to use Postman more securely.

Enhancing Security Measures, Writing Key and Endpoint into Environment Variables

Writing the Key and Endpoint into environment variables is a great protective measure!

  1. Click on the “Environment” beside, add the Key and Endpoint, and set the Type to “secret”


  1. Change the URL for sending the “POST” request to the following format and send the request. If you get the content, it means the request is successful!






Adopting this approach brings many benefits. It not only enhances security but also makes the program easier to maintain. Firstly, it prevents sensitive information from being written directly into the program, protecting the key from unauthorized use or exposure. Secondly, if we delete the original Azure OpenAI Service and create a new one, we only need to change the variables in the environment without modifying any code. This significantly reduces the complexity of maintenance and improves efficiency.

Now, store your keys in environment variables and add more protection to your programs!



Through this article, we’ve walked step-by-step on how to use Postman to call Azure OpenAI’s API. From basic introductions of API and Postman, to practical operations and security enhancements through Postman’s user-friendly interface, we can easily interact with Azure OpenAI. Storing keys and endpoints in environment variables not only makes our programs safer but also facilitates maintenance.