Table of Contents
First, create a
.env and add your Azure OpenAI Service details:
OPENAI_API_KEY=xxxxxx OPENAI_API_BASE=https://xxxxxxxx.openai.azure.com/ OPENAI_API_VERSION=2023-05-15
Next, make sure that you have
gpt-35-turbo deployed and used the same name as the model itself for the deployment.
Let’s install/upgrade to the latest versions of
pip install openai --upgrade pip install langchain --upgrade
Here, we’re using
langchain==0.0.240. This is super important, as older versions of the
openai Python SDK do not support the API version needed to access
Finally, we can run our sample code:
By setting the
openai configuration, we force LangChain (which uses the OpenAI Python SDK under the hood) to talk to Azure OpenAI instead of OpenAI directly.
In this blog post, we discussed how we can use the ChatGPT API (
gpt-35-turbo model) with Azure OpenAI Service and LangChain.