This blog post will show how to use Postman to request the REST API to the Azure OpenAI service platform.
Before you start, ensure you have access to the Azure OpenAI service and have resources deployed. Please visit this blog post to learn how to create OpenAI resources and deployment using Terraform.
Create Variables
To connect to Azure OpenAI from Postman, create the following two variables.
AZURE_OPENAI_KEY – Use your Security Key
AZURE_OPENAI_ENDPOINT – URL
You will find the above two values. Open your deployed Azure OpenAI service from the Azure portal under Azure AI Services.
![](https://www.ntweekly.com/wp-content/uploads/2023/09/image-2-1024x462.png)
Click on Keys and Secrets
![](https://www.ntweekly.com/wp-content/uploads/2023/09/image-1.png)
Copy the values and add them to Postman variables. In our case, we are using them in a new environment.
![](https://www.ntweekly.com/wp-content/uploads/2023/09/image.png)
Save the variables and create a new request with the following details.
Request type – POST
Use the URL below, but change the value of openai to your OpenAI resource name. Also, change the value of gpt-35-0613 to the name of your deployment.
{{AZURE_OPENAI_ENDPOINT}}/openai/deployments/gpt-35-0613/chat/completions?api-version=2023-05-15
The REST API request should look like this.
![](https://www.ntweekly.com/wp-content/uploads/2023/09/image-3-1024x177.png)
Use the following body to send a chat completion request in the Body section.
{"messages":[{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "something"},{"role": "assistant", "content": "something."},{"role": "user", "content": "something"}]}
Click on Send and review the reply.