How to get started with the Azure AI SDK
Note
Azure AI Studio is currently in public preview. This preview is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
The Azure AI SDK is a family of packages that provide access to Azure AI services such as Azure OpenAI.
In this article, you'll learn how to get started with the Azure AI SDK for generative AI applications. You can either:
- Install the SDK into an existing development environment or
- Use the Azure AI SDK without installing it
Install the SDK into an existing development environment
Install Python
First, install Python 3.10 or higher, create a virtual environment or conda environment, and install your packages into that virtual or conda environment. DO NOT install the Generative AI SDK into your global python installation. You should always use a virtual or conda environment when installing python packages, otherwise you can break your system install of Python.
Install Python via virtual environments
Follow the instructions in the VS Code Python Tutorial for the easiest way of installing Python and creating a virtual environment on your operating system.
If you already have Python 3.10 or higher installed, you can create a virtual environment using the following commands:
Install Python via Conda environments
First, install miniconda following the instructions here.
Then, create and activate a new Python 3.10 environment:
conda create --name ai_env python=3.10
conda activate ai_env
Install the Azure AI Generative SDK
Currently to use the generative packages of the Azure AI SDK, you install a set of packages as described in this section.
Caution
It's recommended to install the SDK either in a virtual environment, conda environment, or docker container. If you don't do this, you might run into dependency issues with the packages you have installed on your system. For more information, see Install Python.
Option 1: Install via pip
pip install azure-ai-generative[index,evaluate,promptflow]
pip install azure-identity
Option 2: Install via requirements.txt
Create a new text file named
requirements.txt
in your project directory.Copy the content from the Azure/aistudio-copilot-sample requirements.txt repository on GitHub into your
requirements.txt
file.Enter the following command to install the packages from the
requirements.txt
file:pip install -r requirements.txt
The Azure AI SDK should now be installed and ready to use!
Use the Azure AI SDK without installing it
You can install the Azure AI SDK locally as described previously, or run it via an internet browser or Docker container.
Option 1: Using VS Code (web) in Azure AI Studio
VS Code (web) in Azure AI Studio creates and runs the development container on a compute instance. To get started with this approach, follow the instructions in Work with Azure AI projects in VS Code.
Our prebuilt development environments are based on a docker container that has the Azure AI Generative SDK, the Azure AI CLI, the prompt flow SDK, and other tools. It's configured to run VS Code remotely inside of the container. The docker container is defined in this Dockerfile, and is based on Microsoft's Python 3.10 Development Container Image.
OPTION 2: Visual Studio Code Dev Container
You can run the Azure AI SDK in a Docker container using VS Code Dev Containers:
- Follow the installation instructions for VS Code Dev Containers.
- Clone the aistudio-copilot-sample repository and open it with VS Code:
git clone https://github.com/azure/aistudio-copilot-sample code aistudio-copilot-sample
- Select the Reopen in Dev Containers button. If it doesn't appear, open the command palette (
Ctrl+Shift+P
on Windows and Linux,Cmd+Shift+P
on Mac) and run theDev Containers: Reopen in Container
command.
OPTION 3: GitHub Codespaces
The Azure AI code samples in GitHub Codespaces help you quickly get started without having to install anything locally.
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for