An easy Python example to chat with Azure OpenAI Service, based on the Code section from the Chat playground on Azure OpenAI Service.
Create a Python virtual environment (virtualenv) and install the requirements:
python3 -m venv .venv
source .venv/bin/activateInstall the requirements:
pip install -r requirements.txtReview the requirements.txt file to see the dependencies.
export OPENAI_API_BASE="https://RESOURCE_NAME.openai.azure.com/"
export OPENAI_API_KEY="API_KEY"Replace both RESOURCE_NAME and API_KEY with the values from the Azure OpenAI Service resource.
python chat.py