Microsoft Azure AI Engineer Associate AI-102 Practice Question

You are integrating an Azure OpenAI GPT-4 deployment into an Azure AI Foundry project by using the official OpenAI Python SDK. The following code is executed in a prompt flow but returns HTTP 404 "The deployment was not found":

openai.api_key = os.getenv("AZURE_OPENAI_KEY")
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT")
openai.ChatCompletion.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello"}]
)

The Azure OpenAI resource contains a deployment named gpt4-prod, and the key and endpoint values are correct. Which change will allow the call to succeed when the code runs in Foundry?

  • Set the environment variable OPENAI_API_TYPE to "azure" and replace the model parameter with deployment_id="gpt4-prod" in the ChatCompletion call.

  • Replace the model parameter with engine="gpt4-prod" and set the environment variable OPENAI_API_VERSION to "latest".

  • Append "?api-version=2024-02-15-preview" to the endpoint URL while leaving the model parameter unchanged.

  • Import the azure.ai.generative.openai package instead of openai and keep model="gpt-4" without any other changes.

Microsoft Azure AI Engineer Associate AI-102
Implement generative AI solutions
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot