AI-102 Question 462
Select 4You are developing an Azure-based chatbot using the Azure OpenAI Service. The chatbot should leverage the GPT model to generate context-aware responses for user inputs. You need to submit a prompt to the Azure OpenAI API and receive a response efficiently. Which of the following steps should you include in your implementation to achieve this?
- A
Authenticate to the Azure OpenAI API using an API key or Azure Active Directory token.
- B
Send a POST request to the Azure OpenAI API's endpoint, specifying the model and input prompt in the request body.
- C
Use the Azure CLI to directly query the OpenAI model without any API interaction.
- D
Set the temperature parameter in the request body to control the randomness of the model's output.
- E
Retrieve the response by parsing the JSON response payload returned by the API.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
To use Azure OpenAI APIs effectively, you must authenticate using an API key or Azure Active Directory token and send a POST request to the appropriate endpoint, including necessary parameters like the model, input prompt, and optional configurations such as temperature. The response is returned in JSON format, which needs to be parsed to retrieve the output. The Azure CLI cannot directly query the OpenAI models, so it is not a valid step in this scenario.
- A. Correct.
Authentication is a required step when interacting with the Azure OpenAI API. Without proper authentication, the request will fail.
- B. Correct.
Submitting a POST request to the Azure OpenAI API's endpoint with the required parameters is essential to interact with the model and receive responses.
- C. Incorrect.
The Azure CLI cannot directly query the OpenAI model. API interaction is necessary for submitting prompts and retrieving responses.
- D. Correct.
The temperature parameter allows you to control the randomness of the model’s response, making it an important optional parameter in the request body.
- E. Correct.
The response from the Azure OpenAI API is returned in JSON format, which must be parsed to extract the model's generated output.