Skill 2.1.3
Create a lightweight chat client application by using the Foundry SDK
Key Concepts
The Foundry SDK for Python is the azure-ai-projects package. An AIProjectClient connects to the project endpoint (https://<resource>.services.ai.azure.com/api/projects/<project>) with a credential, normally DefaultAzureCredential from azure-identity, which uses your Azure CLI or Visual Studio Code sign-in during development and a managed identity in Azure. The project's get_openai_client() method returns an OpenAI client that is already authenticated for the project.
The client calls the Responses API with responses.create(), passing the deployment name as model, the instructions and the user's input, and reads the reply from output_text. Language models are stateless, so a chat client must supply context on every turn: by resending the message history, by passing previous_response_id so that the service links the new turn to the stored previous response, or by using a conversation object. A loop that reads input, calls the model and prints the reply until the user types quit is a complete lightweight chat client.