"In this example we'll try to go over all operations needed to get completions working using the Azure endpoints. \\\n",
"This example focuses on completions but also touches on the some other operations that are also available using the API. This example is meant to be a quick way of showing simple operations and is not meant as a tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import openai\n",
"from openai import cli"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"For the following sections to work properly we first have to setup some things. Let's start with the `api_type`, `api_base` and `api_version`. To find your `api_base` go to https://portal.azure.com, find your resource and then under \"Resource Management\" -> \"Keys and Endpoints\" look for the \"Endpoint\" value."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"openai.api_type = 'azure'\n",
"openai.api_version = '2022-12-01'\n",
"\n",
"openai.api_base = '' # Please add your endpoint here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We next have to setup the `api_key`. We can either get the key from the portal or we can get it through Microsoft Active Directory Authentication."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup: Portal\n",
"Let's first look at getting the key from the portal. Go to https://portal.azure.com, find your resource and then under \"Resource Management\" -> \"Keys and Endpoints\" look for one of the \"Keys\" values."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"openai.api_key = '' # Please add your api key here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### (Optional) Setup: Microsoft Active Directory Authentication\n",
"Let's now see how we can get a key via Microsoft Active Directory Authentication."
"In this section we are going to create a deployment using the `text-davinci-002` model that we can use to create completions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deployments: Create Manually\n",
"Create a new deployment by going to your Resource in your portal under \"Resource Management\" -> \"Model deployments\". Select `text-davinci-002` as the model."