Use Azure OpenAI With REST API

In this blog post, we will show how to use Azure OpenAI with REST API and interact with an OpenAI model.

REST APIs, or Representational State Transfer APIs, serve as a bridge between OpenAI’s powerful AI models, like GPT-4, and various applications across the web.

These APIs facilitate seamless communication by allowing developers to send requests and receive responses using standard HTTP methods.

This architecture not only supports scalability by handling large volumes of requests but also ensures that developers can integrate OpenAI’s cutting-edge models into their own applications with minimal friction.

The following table shows how the relationships between functions and the REST API method.

Retrieve GET
Create POST
REST API Functions

JSON Rules

In the context of OpenAI’s REST APIs, JSON (JavaScript Object Notation) plays a crucial role in structuring the request body for efficient and effective communication between clients and the AI models.

JSON is a lightweight data-interchange format that is easy for humans to read and write, and simple for machines to parse and generate.

When developers craft a request to OpenAI’s APIs, such as when submitting text to the GPT-4 model, they typically encapsulate the necessary parameters in a JSON-formatted payload.

The following code shows an example of the most common JSON rules and objects.

Below is an example of a JSON object that you can directly use in Postman to make a request to the OpenAI GPT-4 API

Use Azure OpenAI With REST API

To use Azure OpenAI REST API with Postman, you will need the following.

  • Azure OpenAI Resource (including API Key)
  • Azure OpenAI deployment model (I recommend you keep the deployment name the same as the model name)

Once you have the above, create a REST API POST request and use the the following.

In the Body tab, add the JSON code.

In the Authorization, add an API Key with the name api-key and the API Key from the Azure OpenAI resource.

Success! You're on the list.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.