Develop Python apps that use Azure AI services

This article provides documentation, samples and other resources for learning how to develop applications that use Azure OpenAI Service and other Azure AI Services.

Azure AI reference templates

Azure AI reference templates provide you with well-maintained, easy to deploy reference implementations. These ensure a high-quality starting point for your intelligent applications. The end-to-end solutions provide popular, comprehensive reference applications. The building blocks are smaller-scale samples that focus on specific scenarios and tasks.

End-to-end solutions

Link Description
Get started with the Python enterprise chat sample using RAG An article that walks you through deploying and using the Enterprise chat app sample for Python. This sample is a complete end-to-end solution demonstrating the Retrieval-Augmented Generation (RAG) pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.

Building blocks

Building Block Description
Build a chat app with Azure OpenAI in Python A simple Python Quart app that streams responses from ChatGPT to an HTML/JS frontend using JSON Lines over a ReadableStream.
Build a LangChain with Azure OpenAI in Python An Azure Functions sample that shows how to take a human prompt as HTTP Get or Post input, calculates the completions using chains of human input and templates. This is a starting point that can be used for more sophisticated chains.
Build a ChatGPT Plugin with Azure Container Apps in Python A sample for creating ChatGPT Plugin using GitHub Codespaces, VS Code, and Azure. The sample includes templates to deploy the plugin to Azure Container Apps using the Azure Developer CLI.
Summarize Text using Azure AI Language with Azure Functions Take text documents as input, summarize using Azure AI Language, and then output to another text document using Azure Functions.
Azure AI Python Template Gallery For the full list of Azure AI templates, visit our gallery. All app templates in our gallery can be spun up and deployed using a single command: azd up.
Smart load balancing with Azure Container Apps This sample solution is built using the high-performance YARP C# reverse-proxy framework from Microsoft. However, you don't need to understand C# to use it, you can just build the provided Docker image. This is an alternative solution to the API Management OpenAI smart load balancer, with the same logic.
Smart load balancing with Azure API Management The enterprise sample solution shows how to create an Azure API Management Policy to seamlessly expose a single endpoint to your applications while keeping an efficient logic to consume two or more OpenAI or any API backends based on availability and priority.
Evaulate your chat app Evaluate a chat app's answers against a set of correct or ideal answers (known as ground truth). The evaulation tools can be used with any Chat API which conforms to the Chat protocol.
Load test your chat app with Locust Use a Locust test to validate your chat app can handle the expected load. If your chat app doesn't scale on your App Service due to Azure OpenAI TPM limits, add a load balancer and test your load again. Smart load balancers include Azure API Management and Azure Container Apps.

Azure OpenAI

End-to-end solutions

Link Description
Get started with the Python enterprise chat sample using RAG An article that walks you through deploying and using the Enterprise chat app sample for Python. This sample is a complete end-to-end solution demonstrating the Retrieval-Augmented Generation (RAG) pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.

Building blocks

Link Description
Build a chat app with Azure OpenAI in Python A simple Python Quart app that streams responses from ChatGPT to an HTML/JS frontend using JSON Lines over a ReadableStream.
Build a LangChain with Azure OpenAI in Python A sample shows how to take a human prompt as HTTP Get or Post input, calculates the completions using chains of human input and templates. This is a starting point that can be used for more sophisticated chains.
Build a ChatGPT Plugin with Azure Container Apps in Python A sample for creating ChatGPT Plugin using GitHub Codespaces, VS Code, and Azure. The sample includes templates to deploy the plugin to Azure Container Apps using the Azure Developer CLI.
Vector Similarity Search with Azure Cache for Redis Enterprise A walkthrough using Azure Cache for Redis as a backend vector store for RAG scenarios.
OpenAI solutions with your own data using PostgreSQL An article discussing how Azure Database for PostgreSQL Flexible Server and Azure Cosmos DB for PostgreSQL supports the pgvector extension, along with an overview, scenarios, etc.

SDKs and other samples/guidance

Link Description
OpenAI SDK for Python The GitHub source code version of the OpenAI Python library provides convenient access to the OpenAI API from applications written in the Python language.
Azure OpenAI SDK Releases Links to all Azure OpenAI SDK library packages, including links for .NET, Java, JavaScript and Go.
openai Python Package The PyPi version of the OpenAI Python library.
Get started using GPT-35-Turbo and GPT-4 An article that walks you through creating a chat completion sample.
Streaming Chat completions A notebook containing example of getting chat completions to work using the Azure endpoints. This example focuses on chat completions but also touches on some other operations that are also available using the API.
Switch from OpenAI to Azure OpenAI Guidance article on the small changes you need to make to your code in order to swap back and forth between OpenAI and the Azure OpenAI Service.
Embeddings A notebook demonstrating operations how to use embeddings that can be done using the Azure endpoints. This example focuses on embeddings but also touches some other operations that are also available using the API.
Deploy a model and generate text An article with minimal, straightforward detailing steps to programmatically chat.
OpenAI with Microsoft Entry ID Role based access control A look at authentication using Microsoft Entra ID.
OpenAI with Managed Identities An article with more complex security scenarios requires Azure role-based access control (Azure RBAC). This document covers how to authenticate to your OpenAI resource using Microsoft Entra ID.
More samples A compilation of useful Azure OpenAI Service resources and code samples to help you get started and accelerate your technology adoption journey.
More guidance The hub page for Azure OpenAI Service documentation.

Other Azure AI services

End-to-end solutions

Link Description
Captioning and Call Center Transcription A repo containing samples for captions and transcriptions in a call center scenario.
Use Document Intelligence to automate a paper based process using the New patient registration with Form Recognizer workshop (Code) A workshop style presentation that walks you through how to use Document Intelligence to convert and automate a paper-based process.

Building blocks

Link Description
Use Speech to converse with OpenAI Use Azure AI Speech to converse with Azure OpenAI Service. The text recognized by the Speech service is sent to Azure OpenAI. The Speech service synthesizes the text response from Azure OpenAI.
Translate documents from and into more than 100 different languages using Document Translation sample apps A repo containing both a Command Line tool and Windows application that serves as a local interface to the Azure Document Translation service for Windows, macOS and Linux.

SDKs and samples/guidance

Link Description
Integrate Speech into your apps with Speech SDK Samples Samples for the Azure Cognitive Services Speech SDK. Links to samples for speech recognition, translation, speech synthesis, and more.
Azure AI Document Intelligence SDK Azure AI Document Intelligence (formerly Form Recognizer) is a cloud service that uses machine learning to analyze text and structured data from documents. The Document Intelligence software development kit (SDK) is a set of libraries and tools that enable you to easily integrate Document Intelligence models and capabilities into your applications.
Extract structured data from forms, receipts, invoices, and cards using Form Recognizer in Python Samples for the Azure.AI.FormRecognizer client library.
Extract, classify, and understand text within documents using Text Analytics in Python The client Library for Text Analytics. This is part of the Azure AI Language service, which provides Natural Language Processing (NLP) features for understanding and analyzing text.
Document Translation in Python A quickstart article that uses Document Translation to translate a source document into a target language while preserving structure and text formatting.
Question Answering in Python A quickstart article with steps to get an answer (and confidence score) from a body of text that you send along with your question.
Conversational Language Understanding in Python The client library for Conversational Language Understanding (CLU), a cloud-based conversational AI service, which can extract intents and entities in conversations and acts like an orchestrator to select the best candidate to analyze conversations to get best response from apps like Qna, Luis, and Conversation App.
Analyze images Sample code and setup documents for the Microsoft Azure AI Image Analysis SDK
Azure AI Content Safety SDK for Python Detects harmful user-generated and AI-generated content in applications and services. Content Safety includes text and image APIs that allow you to detect material that is harmful.