Microsoft Foundry Generative AI Chat App Practice Question 6: Initialize Project Client
Microsoft Applied Skills: Develop a Generative AI Chat App Using the Microsoft Foundry SDK · Test 1 · question 6 of 10
Your Python chat app needs to send its first prompt to a gpt-5-mini deployment in a Microsoft Foundry project. You have already run az login. Which sequence correctly initializes the client and issues the call?
Show answer and explanation
Answer:
The quickstart pattern is exactly this: create AIProjectClient(endpoint=FOUNDRY_PROJECT_ENDPOINT, credential=DefaultAzureCredential()), then openai = project.get_openai_client(), then openai.responses.create(model="gpt-5-mini", input=...). The SDK exposes two client types: the project client for Foundry-native operations and the OpenAI-compatible client, obtained from it, for the Responses API. az login is what makes DefaultAzureCredential resolve to a usable token.
- A is wrong because https://ai.azure.com is the portal web address, not an API endpoint. The project endpoint has the form https://<resource-name>.services.ai.azure.com/api/projects/<project-name>. - C is wrong because CognitiveServicesManagementClient is the management-plane client used to create, list, and delete Foundry resources and projects. It has no inference surface at all. - D is wrong because https://<resource-name>.openai.azure.com is the OpenAI SDK endpoint, used when you want maximum OpenAI compatibility. AIProjectClient expects the project endpoint, and the samples authenticate with Entra ID rather than a key.
Reference: Quickstart: Get started with Microsoft Foundry SDK