AI-102 Question 453
Select 3You are designing an Azure AI solution that uses Azure OpenAI Service to generate Python code snippets based on user prompts. Which steps must you include to correctly submit a prompt and retrieve a code response?
- A
Authenticate using Azure Active Directory (Azure AD) or an API key for the Azure OpenAI Service.
- B
Format the user prompt in JSON format and include the 'code' parameter to indicate code generation.
- C
Specify the appropriate deployment name for the OpenAI model in the API request.
- D
Set the response type to 'code' in the API headers to ensure only code is returned.
- E
Send a POST request to the Azure OpenAI endpoint with the prompt and required parameters.
Show answer and explanation
Correct answers: A, C, E
Explanation
To generate code using Azure OpenAI Service, you must authenticate, specify the correct deployment name, and send a POST request to the endpoint with the prompt and other parameters. There is no specific 'code' parameter or header to indicate code generation; the model interprets the prompt and generates a response accordingly.
- A. Correct.
Authentication is mandatory to interact with Azure OpenAI Service. You must use Azure AD or an API key to securely access the service.
- B. Incorrect.
While the prompt is included in the API request body, there is no specific 'code' parameter for indicating code generation in the Azure OpenAI API.
- C. Correct.
The deployment name specifies which model deployment to use, and it is a required parameter in the API request.
- D. Incorrect.
There is no 'code' response type option in the API headers for Azure OpenAI Service. The response type is determined by the model and the nature of the prompt.
- E. Correct.
A POST request is required to send the prompt and other parameters to the Azure OpenAI Service endpoint for processing.