Develop Java 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 Java enterprise chat sample using RAG An article that walks you through deploying and using the Enterprise chat app sample for Java. 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 (Python) A simple Python Quart app that streams responses from ChatGPT to an HTML/JS frontend using JSON Lines over a ReadableStream. (The Python code is provided as a reference and could be adapted to Java.)
Build a LangChain with Azure OpenAI (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. (The Python code is provided as a reference and could be adapted to Java.)
Build a ChatGPT Plugin with Azure Container Apps (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. (The Python code is provided as a reference and could be adapted to Java.)
Azure AI Java 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 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.

Azure OpenAI

End-to-end solutions

Link Description
Get started with the Java enterprise chat sample using RAG An article that walks you through deploying and using the Enterprise chat app sample for Java. 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
Vector Similarity Search with Azure Cache for Redis Enterprise (Python) An article that walks you through using Azure Cache for Redis as a backend vector store for RAG scenarios. (The Python code is provided as a reference and could be adapted to Java.)
OpenAI solutions with your own data using PostgreSQL (Python) 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. (The Python code is provided as a reference and could be adapted to Java.)

SDKs

Package Source code Releases Maven
azure-ai-openai Source code Releases Maven package
azure-ai-openai-assistants Source code Releases Maven package

Samples and guidance

Link Description
Get started using GPT-35-Turbo and GPT-4 An article that walks you through creating a chat completion sample.
Completions A simple example demonstrating how to get completions for the provided prompt.
Streaming Chat Completions A simple example demonstrating how to use streaming chat completions.
Switch from OpenAI to Azure OpenAI An article with guidance 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.
OpenAI with Microsoft Entra ID Role based access control An article that looks at authentication using Microsoft Entra ID.
OpenAI with Managed Identities An article detailing more complex security scenarios that require Azure role-based access control (Azure RBAC). This document covers how to authenticate to your OpenAI resource using Microsoft Entra ID.
More Samples The Azure OpenAI service samples are a set of self-contained Java programs that demonstrate interacting with Azure OpenAI service using the client library. Each sample focuses on a specific scenario and can be executed independently.
More guidance The hub page for Azure OpenAI Service documentation.

Open Source integration

SDKs

Package Source code Releases Maven
langchain4j-azure-open-ai Source code Releases Maven package
langchain4j-azure-ai-search Source code Releases Maven
langchain4j-document-loader-azure-storage-blob n/a Releases Maven

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.

SDKs

Link Description
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.

Samples and guidance

Link Description
Integrate Speech into your apps with Speech SDK Samples A collection of samples for the Azure Cognitive Services Speech SDK. Links to samples for speech recognition, translation, speech synthesis, and more.
Extract structured data from forms, receipts, invoices, and cards using Form Recognizer in Java A collection of samples for the Azure.AI.FormRecognizer client library.
Extract, classify, and understand text within documents using Text Analytics in Java 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 Java A quickstart article that explains how to use Document Translation to translate a source document into a target language while preserving structure and text formatting.
Analyze images Sample code and setup documents for the Microsoft Azure AI Image Analysis SDK