LoopAI-103

Exercise: Create a generative AI chat app

Unit 6 of 7 · Module 3: Develop a generative AI chat app with Microsoft Foundry

Read this lesson

Your turn

Time to build it. In this lab, you use the OpenAI SDK and the Responses API to create a chat app that talks to a model you deploy in a Foundry project. For the real thing, you'll need an Azure subscription, Visual Studio Code, Python 3.13, Git, and the Azure CLI, and about forty-five minutes.

The run sheet

First, create a project and deploy GPT five point two. From the project's home page, copy the Azure OpenAI endpoint, not the project endpoint. Clone the lab repo, create a Python environment, install the requirements, and put the endpoint and deployment name in the dot env file. Then write the code: chat with ChatCompletions, switch to the Responses API, keep the context with previous response ID, stream the output, and finally try the asynchronous client. Your test question is about ELIZA, the chatbot from the nineteen sixties. When you're done, delete the resource group.

Before you start

Here, you practice the portal steps in the guided lab, then write every line of the code in the coding exercise, with Lou beside you. Some features are in preview, so things may look a little different. Let's go.

Facts from Microsoft's documentation: Get started with Microsoft Foundry SDKs and endpoints; Use the Azure OpenAI Responses API; Quickstart: Get started with Microsoft Foundry SDK (CC BY 4.0), rewritten in Loop's own words and examples. Narration, animation, and quiz by Loop. The coding lab is based on Microsoft's lab files for the Foundry exercises (MicrosoftLearning/mslearn-ai-studio, MIT License; notice). Microsoft, Azure, and Microsoft Foundry are trademarks of Microsoft. Loop is independent and not affiliated with or endorsed by Microsoft.